Abstract
Modern clinical practice requires rapid and accurate differential diagnosis—the process of distinguishing between conditions with overlapping symptoms. While Large Language Models (LLMs) offer significant potential for parsing unstructured clinical text, their reliance on cloud-based infrastructures poses substantial privacy and ethical risks. This paper presents a privacy-preserving, locally deployable medical diagnosis platform powered by a fine-tuned Llama-3.1-8B model. By utilizing Low-Rank Adaptation (LoRA) and task-specific classification heads, the system achieves state-of-the-art performance on the DDXPlus benchmark, providing clinicians with a transparent, high-accuracy tool for pathology prediction and differential diagnosis without compromising patient data security.
1. Introduction
Medical document analysis is a cornerstone of effective healthcare, yet it remains one of the most complex tasks due to the nuanced nature of patient symptoms and medical histories. Differential diagnosis requires a sophisticated understanding of how various conditions manifest, often sharing subtle clinical indicators. While frontier models like GPT-4 have demonstrated remarkable reasoning capabilities, their deployment in healthcare is hindered by the necessity of sending sensitive patient data to external servers, raising concerns regarding HIPAA compliance and data sovereignty.
To address these challenges, this research introduces a localized AI solution that brings the reasoning power of modern LLMs directly to hospital hardware. By focusing on local deployment and specialized fine-tuning, the proposed system ensures that patient data never leaves the clinical environment while maintaining diagnostic accuracy that rivals or exceeds existing cloud-dependent models.
2. Methodology
2.1 Model Architecture and Fine-Tuning
The platform is built upon the Meta-Llama-3.1-8B-Instruct architecture. To adapt this general-purpose model to the specialized medical domain efficiently, the authors employed Low-Rank Adaptation (LoRA). This technique allows for high-performance domain adaptation without the prohibitive compute costs of full-parameter fine-tuning.
Specifically, LoRA was applied to the self-attention modules within the Transformer blocks, while the Multi-Layer Perceptron (MLP) modules remained frozen. To enable the model to perform diagnostic tasks, sequence classification linear heads were appended to the architecture. These heads were designed to handle two distinct outputs:
- Pathology Prediction: Identifying a single, primary condition.
- Differential Diagnosis: Generating a variable-length list of potential conditions based on symptom overlap.
2.2 Local Deployment and Interface
The system is deployed via a local web application using a Flask backend and a JavaScript/Chart.js frontend. This architecture allows clinicians to input symptoms and receive real-time diagnostic probabilities. The interface provides visual feedback through radar and bar charts, facilitating a more intuitive understanding of the model's confidence across various pathologies.
3. Experimental Setup
3.1 Dataset
The model was trained and evaluated using DDXPlus, the largest publicly available benchmark for differential diagnosis. The dataset comprises approximately 1.3 million synthetic patient records covering 49 distinct pathologies. Each record includes detailed symptom profiles and medical histories, providing a robust foundation for training automated diagnostic systems.
3.2 Training
Training was conducted on a single NVIDIA A40 GPU, requiring approximately 108 hours per task. This highlights the feasibility of developing high-performance medical AI on relatively modest hardware configurations compared to the massive clusters required for foundational model training.
4. Results and Discussion
4.1 Diagnostic Performance
The proposed model achieved state-of-the-art (SOTA) results across both primary tasks:
- Pathology Prediction: The model reached 99.81% accuracy, with a precision of 96.54%, recall of 94.34%, and an F1 score of 94.81%.
- Differential Diagnosis: The system achieved a Ground Truth Pathology Accuracy (GTPA) of 99.94%. This performance surpasses previous benchmarks, including BASD (99.30%) and AARLC (99.92%).
- F1 Score Improvement: In the context of differential diagnosis, the model achieved an 98.01% F1 score, a significant improvement over the previous best-performing model, DDxT (94.72%).
4.2 Explainability and Clinical Utility
A key focus of this research was the transparency of the model's reasoning. By visualizing self-attention maps across different layers, the authors observed a hierarchical feature extraction process. Shallow layers extract broad clinical features, middle layers focus on specific, high-impact symptoms (e.g., "wheezing" or specific pain intensities), and deeper layers consolidate these signals into a final diagnostic classification.
Furthermore, the research highlighted the importance of threshold tuning. In cases of complex differential diagnosis, a standard 0.5 confidence threshold may be too restrictive. The authors found that lowering the threshold to approximately 0.35 allowed the model to capture the full range of ground-truth conditions in edge cases, providing a more comprehensive safety net for clinicians.
5. Limitations and Future Work
Despite its high accuracy, the model faces challenges related to the nature of the training data. The DDXPlus dataset provides unranked lists of conditions, meaning the model must learn to estimate probabilities without explicit ground-truth rankings. Additionally, error analysis revealed that in rare failure cases, the attention mechanism may fixate on contradictory terms, leading to unstable predictions (e.g., identifying symptoms of asthma but predicting COPD).
Future work will focus on enhancing the platform's ability to process real-world, unstructured patient records and integrating the tool into existing clinical workflows to facilitate earlier disease detection and improved patient outcomes.
6. Conclusion
This study demonstrates that locally deployable, 8B-parameter LLMs, when properly fine-tuned, are highly viable for specialized medical tasks. By achieving SOTA results on the DDXPlus benchmark while maintaining strict data privacy, this platform offers a trustworthy path forward for AI integration in clinical environments.
Summary updated