Abstract
Sustained engagement in HIV care and adherence to ART are crucial for meeting the UNAIDS “95-95-95” targets. Disengagement from care remains a significant issue, especially in sub-Saharan Africa. Traditional machine learning (ML) models have had moderate success in predicting disengagement, enabling early intervention. We developed an enhanced large language model (LLM) fine-tuned with electronic medical records (EMRs) to predict individuals at risk of disengaging from HIV care in Tanzania. Using 4.8 million EMR records from the National HIV Care and Treatment Program (2018–2023), we identified risks of ART non-adherence, non-suppressed viral load, and loss to follow-up. Our enhanced LLM may outperform traditional machine learning models and zero-shot LLMs. HIV physicians in Tanzania evaluated the model’s predictions and justifications, finding 65% alignment with expert assessments, and 92.3% of the aligned cases were considered clinically relevant. This model can support data-driven decisions and may improve patient outcomes and reduce HIV transmission.
Similar content being viewed by others
Data availability
The electronic medical records data from Tanzania’s National HIV Care and Treatment Program used in this study contains protected health information and, therefore, cannot be shared publicly.
References
Frescura, L. et al. Achieving the 95 95 95 targets for all: a pathway to ending AIDS. PLoS ONE 17, e0272405 (2022).
Plazy, M., Orne-Gliemann, J., Dabis, F. & Dray-Spira, R. Retention in care prior to antiretroviral treatment eligibility in sub-Saharan Africa: a systematic review of the literature. BMJ Open 5, e006927 (2015).
Penn, A. W. et al. Supportive interventions to improve retention on ART in people with HIV in low- and middle-income countries: a systematic review. PLOS ONE 13, e0208814 (2018).
Fahey, C. A. et al. Financial incentives to promote retention in care and viral suppression in adults with HIV initiating antiretroviral therapy in Tanzania: a three-arm randomised controlled trial. Lancet HIV 7, e762–e771 (2020).
Olatosi, B., Vermund, S. H. & Li, X. Power of Big Data in ending HIV. AIDS 35, S1–S5 (2021).
Akanbi, M. O. et al. Use of electronic health records in sub-Saharan Africa: progress and challenges. J. Med Trop. 14, 1–6 (2012).
Audere & Desmond Tutu Health Foundation. Artificial intelligence to enhance HIV prevention in age ofdisruptions: Recommendations from the Audere and Desmond Tutu Health Foundation expert consultation. Audere Africa (2025).
Fahey, C. A. et al. Machine learning with routine electronic medical record data to identify people at high risk of disengagement from HIV care in Tanzania. PLOS Glob. Public Health 2, e0000720 (2022).
Meta AI. The Llama 3 herd of models. https://ai.meta.com/research/publications/the-llama-3-herdof-models/ (2024).
Bedi, S. et al. Testing and evaluation of health care applications of large language models: a systematic review. JAMA. https://doi.org/10.1001/jama.2024.21700. (2024).
Thirunavukarasu, A. J. et al. Large language models in medicine. Nat. Med. 29, 1930–1940 (2023).
Esra, R. T. et al. Historical visit attendance as predictor of treatment interruption in South African HIV patients: extension of a validated machine learning model. PLOS Glob. Public Health 3, e0002105 (2023).
Maskew, M. et al. Applying machine learning and predictive modeling to retention and viral suppression in South African HIV treatment cohorts. Sci. Rep. 12, 12715 (2022).
Xie, Z. et al. Prevention of adverse HIV treatment outcomes: machine learning to enable proactive support of people at risk of HIV care disengagement in Tanzania. BMJ Open 14, e088782 (2024).
PEPFAR Fiscal Year 2023 Monitoring, Evaluation, and Reporting (MER) Indicators. United States Department of State. https://www.state.gov/pepfar-fy-2023-mer-indicators/ (accessed Dec 20, 2024).
Fang, X. et al. Large Language Models(LLMs) on Tabular Data: Prediction, Generation, and Understanding -- A Survey. https://doi.org/10.48550/arXiv.2402.17944. (2024).
Yu, B., Fu, C., Yu, H., Huang, F. & Li Y. Unified language representation for question answering over text, tables, andimages. In Findings of the Association for Computational Linguistics: ACL 2023, 4756–4765, https://doi.org/10.18653/v1/2023.findings-acl.292 (Toronto, Canada, 2023).
Gong, H. et al. TableGPT: Few-shot Table-to-Text Generation with Table Structure Reconstruction and Content Matching. In Proc. 28th International Conference on Computational Linguistics. Barcelona, Spain (Online) (eds Scott D., Bel N., Zong C.) 1978–1988 (International Committee on Computational Linguistics, 2020).
Hegselmann, S. et al. TabLLM: few-shot classification of tabular data with large language models. In Proc. 26th International Conference on Artificial Intelligence and Statistics (PMLR, 2023).
Hu, E. J. et al. LoRA: Low-Rank Adaptation of Large Language Models. https://doi.org/10.48550/arXiv.2106.09685. (2021).
Prokhorenkova, L., Gusev, G., Vorobev, A., Dorogush, A. V. & Gulin, A. CatBoost: unbiased boosting with categorical features. In Proc. 32nd International Conference on Neural Information Processing Systems (Curran Associates Inc., 2018).
Hand, D. J. & Till, R. J. A simple generalisation of the area under the ROC curve for multiple class classification problems. Mach. Learn. 45, 171–186 (2001).
Vaswani, A. et al. Attention is all you need. In Proc. 31st International Conference on Neural Information Processing System. 6000–6010 (Curran Associates Inc., 2017).
Yeh, C. et al. AttentionViz: a global view of transformer attention. In IEEE Trans Visual Comput Graphics (IEEE, 2023).
Acknowledgements
The study was supported by a grant from the US National Institutes of Health (NIH): NIH 1R01MH125746. We thank the review team for their valuable suggestions and comments, which significantly improved our paper.
Author information
Authors and Affiliations
Contributions
W.W., J.S., and R.Q.L. conducted the model training and data analysis and organized the study results, including figures and tables. X.M., J.G., Z.Z., X.Z., R.H., and F.J. provided guidance on methodology development. E.K., M.M., A.S., C.L., S.S., P.N., and S.I.M. facilitated data access, offered administrative support, and contributed domain knowledge and insights during manuscript development. J.W. drafted the manuscript, guided the study design, and supervised the project. All authors contributed to study results interpretation and major revision of the manuscript. All authors have read and approved the final version of the manuscript.
Corresponding author
Ethics declarations
Competing interests
The authors declare no competing interests.
Additional information
Publisher’s note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Supplementary information
Rights and permissions
Open Access This article is licensed under a Creative Commons Attribution 4.0 International License, which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons licence, and indicate if changes were made. The images or other third party material in this article are included in the article’s Creative Commons licence, unless indicated otherwise in a credit line to the material. If material is not included in the article’s Creative Commons licence and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder. To view a copy of this licence, visit http://creativecommons.org/licenses/by/4.0/.
About this article
Cite this article
Wei, W., Shao, J., Lyu, R.Q. et al. Enhanced language models for predicting and understanding HIV care disengagement: a case study in Tanzania. npj Digit. Med. (2026). https://doi.org/10.1038/s41746-026-02349-3
Received:
Accepted:
Published:
DOI: https://doi.org/10.1038/s41746-026-02349-3


