Enhanced Language Models for Predicting and Understanding HIV Care Disengagement: A Case Study in Tanzania

Waverly Wei, Junzhe Shao, Rong-Kuo Lyu, Rebecca Hemono, Xinwei Ma, Joseph Giorgio, Zeyu Zheng, Ji Feng, Xiaoya Zhang, Emmanuel Katabaro, Matilda Mlowe, Amon Sabasaba, C.j. Lister, Siraji Shabani, Prosper Njau, Sandra I. McCoy, Jingshen WangResearch Square 2025

Abstract

The study was supported by a grant from the US National Institutes of Health (NIH): NIH NIMH 1R01MH125746. This research explores the application of fine-tuned Large Language Models (LLMs) to address the "leaky bucket" problem in HIV care, where patients disengage from treatment. By utilizing textual serialization of electronic medical records (EMRs) from Tanzania, the study demonstrates that LLMs can outperform traditional machine learning models while providing interpretable, clinically relevant justifications for their predictions.

Introduction

The global fight against HIV is guided by the "95-95-95" targets: ensuring 95% of people living with HIV (PLHIV) know their status, 95% of those diagnosed are on antiretroviral therapy (ART), and 95% of those on ART achieve viral suppression. However, sub-Saharan Africa faces a significant challenge in patient retention, particularly within the first two years of treatment. In resource-constrained environments, healthcare providers require efficient tools to identify which patients are at the highest risk of disengagement to prioritize limited follow-up resources.

Traditional machine learning (ML) models often require extensive manual feature engineering and function as "black boxes," making it difficult for clinicians to trust or act upon their outputs. This study investigates whether LLMs, specifically Llama 3.1, can leverage longitudinal EMR data to provide more accurate and interpretable risk assessments.

Methodology

The core innovation of this study is the use of textual serialization to transform structured EMR data into natural language narratives. Instead of processing a spreadsheet of numerical values, the model "reads" a patient's history—including demographics, clinical visit patterns, and medication refills—much like a human clinician would.

Figure 1: Overview of the study workflow, including data preprocessing, model training via LoRA, and multi-faceted evaluation.

The researchers fine-tuned a Llama 3.1 (8B) model using Low-Rank Adaptation (LoRA), an efficient technique that updates only a small subset of parameters. This allowed the model to be specialized for the Tanzanian medical context. The performance of this enhanced LLM was benchmarked against a state-of-the-art gradient boosting model (CatBoost) and a "zero-shot" (un-tuned) version of the LLM.

Data and Validation

The study utilized a massive dataset from Tanzania’s National HIV Care and Treatment Program (CTC3), comprising 4.8 million EMR records for 261,192 PLHIV from 2018 to 2023. To ensure the model's robustness, it was trained and internally validated on data from the Kagera region and then externally validated on data from the Geita region. The dataset included 99 variables covering demographics, clinical biomarkers (such as CD4 counts and viral load), and detailed medical histories.

Key Results

The enhanced LLM demonstrated significant improvements over existing methods:

  • Superior Accuracy: The model achieved an AUC of 0.77 for predicting Loss to Follow-Up (LTFU), outperforming the supervised ML model (0.71) and the zero-shot LLM (0.57).
  • High Sensitivity: By identifying the top 25% of patients at highest risk, the model correctly captured 78% of those who eventually disengaged from care.
  • Human-AI Alignment: In blind tests, Tanzanian HIV physicians agreed with the LLM’s predictions in 65% of cases. Crucially, when they agreed, they rated the AI’s natural language justifications as "sensible" 92.3% of the time.

Discussion and Interpretability

A major advantage of the LLM approach is its inherent interpretability. By generating natural language justifications (e.g., noting a history of missed appointments combined with fluctuating viral loads), the model provides actionable insights that clinicians can use to inform patient care. Analysis of attention scores revealed that the narrative summaries of patient history were the most critical factors in the model's decision-making process.

Despite these successes, the authors noted limitations, including the lack of social determinants of health (such as income or distance to clinics) in the EMR data and the infrastructure requirements for deploying such models in rural settings. Future work will focus on expanding the geographic scope of the data and integrating these tools directly into clinical workflows to measure their impact on long-term patient outcomes.

Summary updated

BibTeX
@inproceedings{wei2025enhanced,
  author = {Waverly Wei and Junzhe Shao and Rong-Kuo Lyu and Rebecca Hemono and Xinwei Ma and Joseph Giorgio and Zeyu Zheng and Ji Feng and Xiaoya Zhang and Emmanuel Katabaro and Matilda Mlowe and Amon Sabasaba and C.J. Lister and Siraji Shabani and Prosper Njau and Sandra I. McCoy and Jingshen Wang},
  title = {{Enhanced Language Models for Predicting and Understanding HIV Care Disengagement: A Case Study in Tanzania}},
  booktitle = {Research Square},
  year = {2025},
  doi = {10.21203/rs.3.rs-6608559/v1},
}
Figure