MTB is usually diagnosed using sophisticated and expensive methods that include molecular and microscopic examination, making the process tedious and lengthy. This research proposes an innovative approach to enhance MTB detection through a novel biosensor design that integrates Terahertz refractive index measurements with a Gated NasNet Running City Game Axial Attention Network. The proposed diamond-shaped biosensor harnesses the unique properties of Terahertz waves to measure refractive index variations in biological tissues, specifically targeting MTB infections. A thorough optimization process was carried out to obtain an optimal sensor design, which included optimizing several design aspects such as size and materials. The sensor exhibits exceptional characteristics, including processing time of 0.1 s for 40000 iterations and 0.04 Confinement loss among other models. To optimize the weight parameters and reduce computational complexity, the Gated NasNet Running City Game Axial Attention Network is integrated into this research. The model demonstrates impressive performance of nearly 99.1% sensitivity in detecting MTB. The exceptional results indicate the substantial capability of the proposed biosensor for quick and accurate detection of MTB. The sensor’s exceptional performance metrics, along with its simple design, signify a significant breakthrough in the realm of biosensing technology.