Paper · Evaluation and safety · Version 1
Real-world performance of open-source large language models in diabetes diagnosis
First published: Frontiers in Endocrinology, . Original
Copyright the authors. Licensed under Creative Commons Attribution 4.0 International.
This page holds the text of the paper, converted to HTML; figures may be left out.
Several open-source language models read the clinical notes of over 11,000 diabetes patients to identify subtypes and related conditions. The study shows how model size, prompting style and language (English or Chinese) change the results.
Abstract
Background
This study aimed to evaluate the performance of diverse open-source large language models (LLMs) in diagnosing diabetes subtypes and comorbidities from unstructured clinical text, assessing the impact of model characteristics, prompting, and language.
Methods
We conducted a retrospective analysis of 11,329 adult diabetes patients from a large Chinese tertiary center (2010–2020). Various open-source LLMs were tested using four prompting strategies in English and Chinese. Primary outcomes were F1-scores for multi-class diabetes subtyping and binary classification of diabetic kidney disease (DKD) and metabolic syndrome (MetS).
Results
LLMs demonstrated high performance in complex subtyping (peak F1 0.951) but showed limitations in rule-based DKD (F1 0.570) and MetS (F1 0.650) diagnosis. Chain-of-Thought prompting improved MetS classification but degraded DKD performance. Optimal model size was approximately 32B parameters. Notably, English prompts outperformed Chinese prompts on native Chinese text.
Conclusion
Open-source LLMs exhibit strong holistic pattern recognition for complex classification but struggle with rule-based procedural reasoning. These models are promising as clinical co-pilots to augment expert decision-making rather than serving as autonomous diagnostic tools.
Keywords: artificial intelligence, diabetes, diabetes complication disease, diagnosis, large language model
Introduction
Effective management of Diabetes Mellitus (DM) hinges on the accurate diagnosis of its subtypes and comorbidities, a process often challenged by overlapping phenotypes and complex criteria that can lead to poor patient outcomes (1, 2).
Large Language Models (LLMs) are transforming medical informatics (3). While initial research on proprietary models confirmed their potential (4, 5), the recent proliferation of open-source LLMs offers greater transparency and customizability, making them a highly promising approach for specialized medical tasks (6). This has spurred the creation of comprehensive specialized medical benchmarks, such as MedQA and PubMedQA, which show that leading open-source models can be competitive, especially with effective prompting (7–9). However, while these standardized datasets have advanced the field, a critical gap remains: the evaluation of LLMs on real-world, non-English clinical narratives is still underexplored. The complex reasoning required for such high-stakes tasks using real-world data is therefore underexplored.
To address the critical gap, the primary objective of this study is to evaluate and compare the diagnostic performance of various open-source LLMs across three specific endocrinological tasks (diabetes subtyping, diabetic kidney disease, and metabolic syndrome) using a large dataset of 11,329 real-world Chinese clinical narratives. Furthermore, our secondary objectives are to systematically analyze the impact of advanced prompting strategies like Chain-of-Thought (CoT) (10), model characteristics (size, family, and fine-tuning), and language-specific tuning on diagnostic accuracy.
Materials and methods
Study population
This retrospective, cross-sectional study was approved by the Ethics Committee of the Second Xiangya Hospital, Central South University. We analyzed de-identified discharge summaries from inpatients in the endocrinology department between January 2010 and December 2020. Inclusion was based on a specialist-confirmed diabetes diagnosis and complete records; patients with other confounding primary diseases were excluded. Patient confidentiality was maintained through a standardized de-identification process. The study was approved by the institutional ethics committee and adhered to the Declaration of Helsinki.
Disease definitions
We defined all diagnostic outcomes based on established clinical guidelines. Diabetes mellitus (DM) classification was determined through a comprehensive clinical assessment that included onset characteristics, disease progression, autoantibody status, islet function, genetic testing, and treatment response, ultimately categorizing patients into type 1 DM (T1DM), type 2 DM (T2DM), specific types of diabetes (SD), or gestational DM (GDM), in alignment with American Diabetes Association (ADA) principles (11). Diabetic kidney disease (DKD) was diagnosed according to ADA criteria, defined as persistent albuminuria (urinary albumin-to-creatinine ratio [UACR] ≥30 mg/g or 24-hour albumin excretion rate [AER] ≥20 μg/min) for over three months, after the exclusion of other nephropathies (12). Metabolic syndrome (MetS) was identified using the 2017 Chinese Diabetes Society (CDS) criteria, requiring the presence of at least three of the following five components: 1) central obesity (waist circumference ≥90 cm for men, ≥85 cm for women); 2) hyperglycemia (fasting plasma glucose [FPG] ≥6.1 mmol/L, 2-hour post-load glucose ≥7.8 mmol/L, or diagnosed diabetes); 3) hypertension (blood pressure ≥130/85 mmHg or receiving antihypertensive therapy); 4) hypertriglyceridemia (fasting triglycerides [TG] ≥1.70 mmol/L); and 5) low high-density lipoprotein cholesterol (HDL-C) (<1.04 mmol/L) (13).
LLM selection and setting
We selected a diverse set of open-source LLMs based on four key principles. The selection covered: 1) a wide range of parameter scales (2B to 72B); 2) diverse architectures [Llama (14), Qwen (15–18), DeepSeek (19, 20)]; 3) a balance between general-purpose models and medically fine-tuned counterparts [MMedLM2 (21), HuatuoGPT-2 (22)]; and 4) models with strong community support and available quantized versions to ensure practical relevance (Supplementary Appendix 1). Model deployment was scaled-dependent. Larger models including Qwen2.5-72B, DeepSeek-32B were accessed via APIs, while smaller models were run locally on A100/RTX 3090 GPUs using the Hugging Face Transformers library, accelerated by vLLM and int4/fp8 quantization. Key inference parameters were set (temperature: 0.35–0.6, top_p: 0.7, max_tokens: 64–2048), with unspecified parameters at their defaults (Supplementary data sheet 2).
Data preparation
We developed a systematic pipeline to transform raw clinical text from diabetes discharge summaries into a structured format for LLM evaluation. Initially, regular expressions were used to extract the distinct sections including “Admission Diagnosis,” “Admission Condition,” and “Hospitalization Process” sections from each record. Next, ground-truth labels for three tasks (diabetes classification, metabolic syndrome, and diabetic kidney disease) were automatically generated from the “Admission Diagnosis” text via pattern matching and predefined keyword dictionaries. The extracted narratives and labels were then integrated into a tabular dataset, which was subsequently deduplicated based on a unique health event ID. Crucially, to rigorously prevent label leakage, a prevalent issue where explicit diagnostic terms in the input artificially inflate model performance, the “Admission Diagnosis” field was strictly masked and excluded from the downstream LLM prompts (23). Finally, for model input, only the unstructured narrative sections of the “Admission Condition” and “Hospitalization Process” were concatenated and appended with a standardized, task-specific prompt, forcing the models to deduce diagnoses entirely from contextual clinical descriptions (Figure 1).To evaluate the models’ performance under true real-world clinical conditions, missing critical variables were not explicitly masked or annotated with placeholders in the input text. Instead, the LLMs were provided with the raw, unstructured clinical narratives. Consequently, the models were required to independently process the text and infer the absence of these variables if they were not explicitly documented.
Figure 1 Overview of the LLM-based pipeline for clinical diagnosis. Original patient records were first anonymized and processed to extract relevant text. This text was then used to construct a task-specific prompt that queries a LLM. The LLM performed inference to produce a diagnosis, which was then evaluated for accuracy against true labels.
We used a three-tiered protocol to standardize model predictions for evaluation. Tier 1 used prompt engineering to constrain outputs to a predefined format. For non-conforming outputs, Tier 2 applied a rule-based parser with keyword matching. Any remaining ambiguous outputs were adjudicated in Tier 3. Critically, to preserve clinical nuance, detailed analytical responses from medical-specific LLMs were exempted from this forced categorization and instead retained for qualitative analysis, ensuring both robust quantitative metrics and valuable qualitative insights (Figure 1).
Prompting strategies
We evaluated four prompting strategies of progressively increasing complexity to assess their impact on model performance. These strategies ranged from a baseline Zero-shot direct query (Prompt 1) to Reference-guided prompting (Prompt 2) that provided a specific guide, manual, or standard framework. We further incorporated Criteria-driven prompting (Prompt 3), and finally employed Chain-of-Thought (CoT) prompting (Prompt 4) to elicit a step-by-step rationale prior to the final diagnosis. This hierarchical framework enabled a systematic analysis of the model’s response to varying levels of guidance (Table 1) (Supplementary data sheet 3).
Table 1 Summary of prompting strategies.
| Prompt | Strategy name | Description | Key feature |
|---|---|---|---|
| Prompt 1 | Zero-Shot Direct Query | A simple, direct question posed to the model | Minimal guidance |
| Prompt 2 | Reference-Guided Prompting | Providing a specific guide, manual, or standard framework. | Anchoring the output to an authoritative standard |
| Prompt 3 | Criteria-Driven Prompting | Providing explicit instructions and a specific list of criteria. | Specifying evaluation rubrics |
| Prompt 4 | Chain-of-Thought (CoT) Prompting | Guides the model to provide a step-by-step analysis before the final answer | Elicits explicit reasoning process |
Statistical analysis
Model performance was assessed using standard classification metrics (accuracy, precision, recall, F1-score). We prioritized the macro-F1 score for the multi-class task and the F1-score for binary tasks. Statistical robustness was ensured by calculating 95% confidence intervals (CIs) via bootstrapping (n=1,000). To evaluate the statistical significance of pairwise performance differences, McNemar’s test (p<0.05) was applied. Specifically, for Task 1, it was utilized to compare the efficacy of different prompting strategies on the top-performing model, as well as to assess performance variations among distinct LLMs under an optimal prompt. Additionally, a sensitivity analysis on balanced data subsets was conducted to evaluate performance on rare classes. All analyses utilized Python’s scikit-learn and statsmodels libraries.
Results
Characteristics of study populations
A total of 11,329 patients with diabetes were initially included. After excluding 1,488 patients with unclassified subtypes, 9,841 patients were included in the final diabetes subtyping analysis. The distribution was as follows: 8,911 (90.5%) with T2DM, 737 (7.5%) with T1DM, 147 (1.5%) with specific types of diabetes (SD), and 46 (0.5%) with GDM. Separately, the entire initial cohort (n = 11,329) was assessed for comorbidities, revealing 3,753 cases of metabolic syndrome (MetS) and 2,374 cases of diabetic kidney disease (DKD).
Overall performance
We comprehensively evaluated the performance of a series of open-source LLMs on three core diabetes-related diagnostic tasks. In the diabetes classification task (Task 1), the DeepSeek-V3 model with Chinese Prompt 1 achieved the best F1 score of 0.951. For the DKD diagnosis task (Task 2), the DeepSeek-R1 model combined with Chinese Prompt 2 performed best, achieving an F1 score of 0.570. In the metabolic syndrome diagnosis task (Task 3), the DeepSeek-32B model paired with Chinese Prompt 3 obtained the highest F1 score of 0.650. The initial findings revealed the optimal performance of DeepSeek models.
Performance by task
Task 1: diabetes classification diagnosis
For the primary task of diabetes classification, we evaluated all models using accuracy, macro F1-score, and weighted F1-score. The DeepSeek-V3 model, when paired with Chinese Prompt 1, achieved the highest overall accuracy (95.21%) and weighted F1-score (0.951; 95%CI [0.947-0.955]) (Supplementary Table 1 and Supplementary Table 2 in the Supplementary Tables). Across all prompt configurations, DeepSeek-V3 demonstrated exceptional performance stability, consistently maintaining high F1-scores (Figure 2).
Figure 2 Distribution of weighted F1-scores (95%CIs) for different models on the diabetes subtyping task. This figure showed the distribution of Weighted F1-scores (95%CIs) for different models on the diabetes subtyping task using (a) Chinese prompt 1, (b) English prompt 1, (c) Chinese prompt 2, (d) English prompt 2, (e) Chinese prompt 3, (f) English prompt 3, (g) Chinese prompt 4, and (h) English prompt 4.
A confusion matrix analysis revealed the top-performing model (DeepSeek-V3, Chinese Prompt 1) suffered from significant class imbalance, misclassifying high proportions of minority classes like GDM (61%) and SD (42%) as T2DM. Systematically refining the prompts proved effective. The optimal performance balance (highest macro F1-score) was achieved with DeepSeek-V3 using English Prompt 4, which markedly improved recall for minority classes and delivered the most balanced diagnostic performance, despite some residual misclassification (Figure 3) (Supplementary Table 1 in the Supplementary Tables).
Figure 3 Confusion matrix for the diabetes classification task using the DeepSeek-V3 model. This figure demonstrated the confusion matrix for the diabetes classification task using the DeepSeek-V3 model with (a) Chinese Prompt 1, (b) Chinese Prompt 2, (c) Chinese Prompt 3, (d) Chinese Prompt 4, (e) English Prompt 1, (f) English Prompt 2, (g) English Prompt 3, (h) English Prompt 4.
To assess robustness, a sensitivity analysis was conducted on a class-balanced subset (n=46 per class). The DeepSeek models (V3 and R1) emerged as the most robust, achieving the highest average F1-scores (69.74% and 69.67%), while models like Llama-3.2-11B showed significant performance decline (Supplementary Figure 3 and Supplementary Figure 4 in the Supplementary Figures). We also identified the performance ceiling: DeepSeek-V3 with Chinese Prompt 4 achieved the peak F1-score of 77.39%, outperforming the next-best models (Supplementary Figure 5 in the Supplementary Figures). Furthermore, the analysis revealed a clear language bias, with English prompts yielding a superior mean F1-score (61.38%) compared to Chinese prompts (56.65%) across all models (Supplementary Figure 6 and Supplementary Figure 7 in the Supplementary Figures).
Task 2: diabetic kidney disease diagnosis
In the DKD diagnosis task, the DeepSeek-R1 model performed best when combined with Chinese Prompt 2, achieving the highest F1 score of 0.570 (95%CI [0.556, 0.583]). And the combination of Qwen2-2B and Chinese Prompt 2 exhibited the greatest stability, as evidenced by yielding the tightest 95%CI of [0.354, 0.374] with a width of 0.020 (Supplementary Table 3 and Supplementary Table 4 in the Supplementary Tables, Supplementary Figure 8 in the Supplementary Figures). Regarding the impact of prompting strategies, for the DKD diagnosis task, simple queries (Prompt 1) or prompts with more explicit instructions (Prompt 2) generally performed better. It was noteworthy that Prompt 4, which introduced Chain-of-Thought (CoT), did not perform optimally in this task; especially under Chinese prompts (Figure 4B and Supplementary Figure 16 in the Supplementary Figures).
Figure 4 Average macro F1 comparison across tasks and prompts. (a) Performance of different prompts, as measured by Macro F1-score, on the diabetes classification diagnosis task (Task 1), evaluated under both Chinese and English language conditions. Prompt 1 showed the best performance in both conditions. (b) Performance of different prompts, as measured by Macro F1-score, on the diabetic kidney disease diagnosis task (Task 2), evaluated under both Chinese and English language conditions. (c) Performance of different prompts, as measured by Macro F1-score, on the metabolic syndrome diagnosis task (Task 3), evaluated under both Chinese and English language conditions.
Task 3: metabolic syndrome diagnosis
For the metabolic syndrome diagnosis task, models like Qwen2-2B, the Llama series, and Gemma2-9B showed commendable stability, with consistent confidence interval widths of 0.019–0.022 under multiple prompts. The DeepSeek-32B model, when combined with Chinese Prompt 3, achieved the highest F1-score of 0.650 (95% CI, 0.638–0.660) (Supplementary Table 5 and Supplementary Table 6 in the Supplementary Tables, Supplementary Figure 9 in the Supplementary Figures). Regarding prompting, Prompt 4 was generally superior, improving performance for smaller or reasoning-sensitive models (e.g., MMedLM2-7B). Conversely, its impact was less effective for models with strong inherent generalization or insensitivity to CoT, such as Qwen2.5-14B-int4 (Figure 4C and Supplementary Figure 17 in the Supplementary Figures).
Impact of model characteristics
Model size
We investigated the relationship between model parameter scale and diagnostic performance in the Qwen and DeepSeek series. A general upward trend in F1 scores with increasing size confirmed enhanced capabilities in larger models. However, this scaling was not linear. In the Qwen series, performance peaked at the 32B scale and then slightly declined at 72B (Supplementary Figure 10A in the Supplementary Figures). For the DeepSeek series, the 671B model (DeepSeek-R1) showed only a marginal advantage over the smaller 32B distilled version. Notably, the 671B model’s average F1-score was even slightly lower than the 32B model’s under English prompts, indicating that advanced distillation can yield competitive performance in smaller models (Supplementary Figure 10B in the Supplementary Figures).
Model family
When comparing the performance of different model families, we focused on the performance of the Qwen series and DeepSeek series in Task 1.By calculating the average and optimal values of the average Weighted F1 scores for these two-model series under Chinese (zh) and English (eng) prompts, the results showed that although the Qwen model family demonstrated superior performance on average, as measured by weighted F1 scores across Chinese and English prompts, the optimal scores for both series were closely matched (Supplementary Figure 11 in the Supplementary Figures).
General vs. medical models
We compared general-purpose (Qwen, Llama and Gemma) and medically fine-tuned (HuatuoGPT, MMedLM2) models at the ~7B scale, revealing a strong task-dependent effect. In the broad diabetes classification task, the general-purpose Qwen2.5-7B showed exceptional bilingual performance (mean F1: ~0.93), outperforming medical models. While HuatuoGPT-o1-7B also performed strongly (mean F1: ~0.91-0.92), another medical model, MMedLM2-7B, exhibited poor English generalization (F1: 0.697), highlighting inconsistency (Supplementary Figure 12A in the Supplementary Figures). Conversely, for the specialized DKD and MetS tasks, HuatuoGPT-o1-7B demonstrated a clear advantage, surpassing even larger general-purpose models. In contrast, other medical models like HuatuoGPT2 and MMedLM2 performed poorly on these tasks, particularly under English prompts, suggesting issues with their inherent capabilities or our secondary evaluation strategy (Supplementary Figures 12B, C in the Supplementary Figures).
Quantization
To evaluate the impact of INT4 quantization on model performance, we compared the Qwen2.5-14B and Llama-3.2-11B models and their corresponding INT4 quantized versions. The results showed that INT4 quantization of these models led to a slight decrease in overall performance, but they generally maintained high usability. Specifically, the INT4 quantized version of Qwen2.5-14B experienced an average F1 score decrease of 0.002 and 0.006 on Chinese and English prompts, respectively, with an overall average F1 score decrease of 0.004. For the INT4 quantized version of Llama-3.2-11B, the performance decrease was slightly larger, with the average F1 score decreasing by about 0.011 on Chinese tasks, and increasing by 0.005 on English tasks, resulting in an overall average F1 score decrease of 0.003. Although there were minor differences in performance, these decreases were generally within acceptable limits (Supplementary Figure 13 in the Supplementary Figures).
Distillation
We investigated the impact of knowledge distillation techniques on model performance, specifically comparing the performance of distilled DeepSeek series models (DS-R1-Distill-Qwen) with the original Qwen 2.5 models of corresponding parameter scales. The distilled DeepSeek models, in most cases, did not outperform their corresponding original Qwen models of the same parameter scale. At the 14B and 32B parameter levels, the distilled DS-R1-Distill-Qwen models in Chinese and English prompts generally had similar average F1 scores compared to the corresponding Qwen2.5 models. But at 7B parameter level, the distilled DS-R1-Distill-Qwen model was substantially lower than that of the corresponding Qwen2.5 model (Supplementary Figure 14 in the Supplementary Figures).
Prompting strategy
Our evaluation of four prompting strategies revealed that their effectiveness varied significantly across tasks. For diabetes classification (Task 1), while CoT (Prompt 4) showed potential for minority class recall, the simplest prompt (Prompt 1) achieved the highest average macro F1-score, with English prompts generally outperforming Chinese ones (Figure 4A and Supplementary Figure 15 in the Supplementary Figures). In DKD diagnosis (Task 2), simpler queries (Prompts 1 & 2) were more effective; CoT was largely detrimental, especially in English prompts (Figure 4B and Supplementary Figure 16 in the Supplementary Figures). In contrast, for MetS diagnosis (Task 3), CoT (Prompt 4) was superior, yielding the best average F1-scores in both languages. It significantly boosted performance for smaller or reasoning-sensitive models, but its effect was less pronounced for models with strong inherent generalization (Figure 4C and Supplementary Figure 17 in the Supplementary Figures).
Qualitative error analysis
To precisely pinpoint the failure loci in rule-based diagnostic tasks, we conducted a supplementary structured-output experiment using DeepSeek-R1. The model was mandated to explicitly extract key diagnostic criteria alongside its final predictions for DKD and MetS, enabling a traceable audit of its reasoning process. Our analysis revealed that severe clinical data absence was a primary driver of diagnostic failure. In the DKD task, the overall missing rates for UACR and AER were 64.19% and 59.36%, respectively. Specifically, within incorrectly predicted cases, UACR and AER were missing in 52.01% and 46.09% of instances, with both completely absent in 24.13% of failures (Supplementary Figure 18A). While this widespread missingness frequently forced the model into a default “conservative” negative prediction, the explicit extraction exposed a critical “hallucination” vulnerability: in 0.83% of cases where diagnostic indicators were entirely absent, the model still baselessly generated a positive diagnosis. Furthermore, even when at least one indicator was successfully extracted, the diagnostic error rate remained at 27.02%. The audit further exposed inherent logical inconsistencies in complex rule execution. For the MetS task, significant missing rates persisted among incorrectly predicted cases. Beyond data absence, the model demonstrated severe reasoning disconnects during threshold integration and conditional counting: 49.77% of cases where the model explicitly extracted and self-identified meeting ≥3 criteria were still misclassified. Conversely, 21.94% of cases with <3 extracted criteria incorrectly received positive predictions (Supplementary Figure 18B). Ultimately, these findings demonstrate that while pervasive real-world data incompleteness heavily restricts rule-based LLM performance, the models also suffer from intrinsic reasoning biases and hallucinations when navigating complex, multi-conditional clinical logic.
Discussion
Our systematic evaluation of open-source large language models (LLMs) on diagnostic tasks from 11,329 real-world patient records revealed a key paradox: models excelled at the cognitively demanding, multi-class task of diabetes subtyping but faltered on the seemingly simpler, rule-based binary diagnoses of diabetic kidney disease (DKD) and metabolic syndrome (MetS). This principal finding suggested that LLM performance in the clinical domain was dictated not by superficial task simplicity but by a sophisticated interplay between the nature of the required clinical reasoning, model architecture, and prompting strategy.
A pivotal finding was the models’ superior performance on diabetes subtyping, a task that necessitated synthesizing sparse, heterogeneous data from unstructured clinical narratives. The high fidelity achieved, particularly by the DeepSeek series, indicated a robust capacity for high-dimensional pattern recognition, a departure from rigid, rule-based execution. This successful translation of performance from standardized benchmarks to the ecologically valid challenge of processing noisy, real-world clinical text marked a significant step toward clinical implementation. Conversely, the models exhibited brittle performance on DKD and MetS tasks, revealing a core limitation in executing procedural rules that demand strict quantitative and logical adherence. This deficit, analogous to the “factual hallucination” and “computational weakness” observed in other domains (4, 24, 25), suggested that the probabilistic nature of LLMs inhibited their function as reliable “rule engines,” a limitation that was particularly acute when diagnostic criteria were fragmented across clinical text.
Our results underscored that the utility of prompt engineering was highly task dependent. For the complex diabetes subtyping, Chain-of-Thought (CoT) prompting enhanced the identification of minority classes by structuring the model’s pattern-matching process, consistent with prior work (26). For MetS diagnosis, CoT’s value derived from its ability to decompose a complex rule set into a verifiable checklist, thereby promoting “faithful reasoning” (27, 28). In contrast, the superiority of simpler prompts for DKD diagnosis suggested that tasks involving complex exclusionary logic remain a significant challenge for LLMs, where excessive guidance may paradoxically increase the risk of logical fallacies (29–31).
Our investigation into model characteristics yielded several nuanced insights. First, the “bigger is better” paradigm exhibited non-linear scaling effects, with performance plateauing around the 32B parameter scale, aligning with observations of diminishing returns at massive scales (32). Second, the trade-off between general-purpose and medically specialized models was evident. While generalist models demonstrated robust reasoning, our findings, in line with studies on models like HuatuoGPT, affirmed that domain-specific fine-tuning provided a critical advantage for certain nuanced tasks, suggesting a hybrid approach might be optimal (33).
Furthermore, for clinical deployment, our findings on model compression were particularly relevant. The negligible performance penalty from INT4 quantization confirmed its viability for resource-constrained environments, consistent with research on QLoRA and GPTQ (34, 35). In contrast, the inconsistent efficacy of knowledge distillation highlighted its complexity, suggesting that simple distillation might be insufficient for multifaceted clinical reasoning tasks (36, 37).
A consistent and critical finding was the superior performance of English prompts on Chinese clinical text, highlighting the Anglocentric bias of many foundational models. This aligned with large-scale multilingual evaluations (38) and underscored an urgent need for developing high-quality, non-English medical LLMs and advancing cross-lingual transfer learning to ensure AI fairness and inclusivity in global health (21, 39).
The findings from our qualitative error analysis provide critical insights into the limitations of applying rigid rule-based LLM frameworks to real-world clinical data. By designing a structured evaluation that required the models to explicitly extract key clinical indicators alongside the final diagnosis, we demonstrated that the models’ underperformance in identifying specific diagnostic criteria for comorbidities is not strictly an algorithmic reasoning deficit but is heavily a consequence of data absence and extraction challenges within complex, unstructured narratives. This highlights a fundamental reality in clinical informatics: while forcing LLMs to evaluate each explicit diagnostic criterion exposes the brittleness of rule-based logic when confronted with missing values, it simultaneously underscores the necessity of holistic contextual synthesis. Ultimately, improving LLM utility in specialized fields like endocrinology will require advancing not only their deductive logic capabilities but also developing robust computational strategies to handle the pervasive data incompleteness characteristic of real-world medical records (23, 40).
The qualitative analysis demonstrates that guiding LLMs with criteria-driven prompts significantly improves their diagnostic extraction for complex conditions. This aligns seamlessly with recent findings by Washington et al. (41), who demonstrated the clear efficacy of using clinical scoresheets to facilitate LLM diagnostic classification from unstructured text. By decomposing complex diagnostic rule sets into structured, step-by-step checklists, LLMs can more effectively navigate clinical narratives, thereby reducing hallucinations and significantly improving the transparency and traceability of their clinical reasoning.
Interestingly, our results indicate that generalist models sometimes outperform medical-specific models in holistic, semantic tasks like complex diabetes subtyping. However, this observation does not diminish the value of domain-specific adaptation; rather, it highlights that the advantage of specialized models is highly task-dependent. For instance, Abdur et al. (42) demonstrated the significant benefits of domain-specific fine-tuning by developing “nBERT” specifically for emotion recognition in psychotherapy. While large generalist models excel at broad semantic reasoning in our holistic subtyping tasks, specialized fine-tuning remains a crucial and powerful strategy for extracting highly nuanced, domain-specific clinical features where off-the-shelf generalist capabilities may lack precision.
Our study had several key strengths. First, its foundation in real-world, unstructured Chinese clinical narratives provided a realistic testbed for LLM utility, complementing studies that relied on standardized datasets (4). Second, our in-depth, domain-specific analysis of endocrinological reasoning offered a granular perspective that complements broad evaluation frameworks like the BRIDGE Benchmark (7). Third, our focus on the open-source ecosystem provided actionable insights for developing reproducible and accessible clinical AI solutions. Despite these strengths, several limitations need to be acknowledged. The retrospective, single-center design might limit the generalizability of our findings. Additionally, the use of automated methods for ground-truth labeling introduced a potential for bias, and the data was confined to discharge summaries, omitting other valuable clinical data sources. Specifically, evaluating complex comorbidities like DKD and MetS as binary classifications from single-encounter summaries ignores inherent temporal and missing data challenges, such as absent longitudinal eGFR changes or missing laboratory values required for MetS criteria. Therefore, the observed failure of rule-based reasoning in these specific tasks is partly attributable to real-world data incompleteness rather than purely an algorithmic reasoning deficit. Future multi-center, prospective studies incorporating multi-modal data were warranted to validate and extend these findings.
Conclusion
In conclusion, LLMs demonstrated a fundamental trade-off between holistic pattern recognition and procedural fidelity. Their success in complex classifications and failure in rule-based tasks underscored that their core strength was contextual synthesis, not logical reasoning. This transformed them from inscrutable black boxes into optimizable systems. These findings suggest that rather than functioning as autonomous diagnostic agents, the most appropriate future application of these models may be as “clinical co-pilots,” augmenting expert decision-making. However, because this study focused on computational evaluation without human-in-the-loop experiments, rigorous clinical trials involving direct clinician interaction are necessary to formally test and validate their efficacy and safety in this collaborative role.
Data availability statement
Due to the sensitive nature of the patient information contained in the unstructured clinical notes, the raw data used in this study are confidential and cannot be shared to protect patient privacy. Requests to access the datasets should be directed to Zhiguang Zhou, [email protected].
Ethics statement
The studies involving humans were approved by National Clinical Research Center for Metabolic Diseases, The Second Xiangya Hospital of Central South University. The studies were conducted in accordance with the local legislation and institutional requirements. The participants provided their written informed consent to participate in this study.
Author contributions
SY: Visualization, Data curation, Validation, Conceptualization, Supervision, Writing – original draft, Writing – review & editing. SL: Data curation, Methodology, Software, Writing – review & editing, Writing – original draft. YM: Data curation, Writing – original draft, Investigation, Methodology, Writing – review & editing. BG: Writing – review & editing, Methodology, Data curation, Visualization, Validation. JL: Validation, Investigation, Writing – review & editing, Supervision. LW: Visualization, Writing – review & editing, Validation, Funding acquisition, Resources, Supervision. FG: Validation, Conceptualization, Visualization, Writing – review & editing, Supervision. ZZ: Visualization, Resources, Conceptualization, Supervision, Investigation, Writing – review & editing, Validation, Data curation.
Conflict of interest
The author(s) declared that this work was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.
Generative AI statement
The author(s) declared that generative AI was not used in the creation of this manuscript.
Any alternative text (alt text) provided alongside figures in this article has been generated by Frontiers with the support of artificial intelligence and reasonable efforts have been made to ensure accuracy, including review by the authors wherever possible. If you identify any issues, please contact us.
Publisher’s note
All claims expressed in this article are solely those of the authors and do not necessarily represent those of their affiliated organizations, or those of the publisher, the editors and the reviewers. Any product that may be evaluated in this article, or claim that may be made by its manufacturer, is not guaranteed or endorsed by the publisher.
Supplementary material
The Supplementary Material for this article can be found online at: https://www.frontiersin.org/articles/10.3389/fendo.2026.1747468/full#supplementary-material
References
- [1] Gloyn AL Drucker DJ. Precision medicine in the management of type 2 diabetes. Lancet Diabetes Endocrinol. (2018) 6:891–900. doi: 10.1016/s2213-8587(18)30052-4. PMID: 29699867
- [2] Thomas NJ Lynam AL Hill AV Weedon MN Shields BM Oram RA et al. Type 1 diabetes defined by severe insulin deficiency occurs after 30 years of age and is commonly treated as type 2 diabetes. Diabetologia. (2019) 62:1167–72. doi: 10.1007/s00125-019-4863-8. PMID: 30969375
- [3] Moor M Banerjee O Abad ZSH Krumholz HM Leskovec J Topol EJ et al. Foundation models for generalist medical artificial intelligence. Nature. (2023) 616:259–65. doi: 10.1038/s41586-023-05881-4. PMID: 37045921
- [4] Singhal K Azizi S Tu T Mahdavi SS Wei J Chung HW et al. Large language models encode clinical knowledge. Nature. (2023) 620:172–80. doi: 10.1038/s41586-023-06291-2. PMID: 37438534
- [5] Omiye JA Gui H Rezaei SJ Zou J Daneshjou R. Large language models in medicine: The potentials and pitfalls: A narrative review. Ann Intern Med. (2024) 177:210–20. doi: 10.7326/m23-2772. PMID: 38285984
- [6] Touvron H Martin L Stone K Albert P Almahairi A Babaei Y et al. Llama 2: Open foundation and fine-tuned chat models. arXiv:2307.09288. (2023). Available online at: https://ui.adsabs.harvard.edu/abs/2023arXiv230709288T.
- [7] Wu J Gu B Zhou R Xie K Snyder D Jiang Y et al. BRIDGE: benchmarking large language models for understanding real-world clinical practice text. arXiv preprint arXiv:250419467. (2025).
- [8] Ahlqvist E Prasad RB Groop L. Subtypes of type 2 diabetes determined from clinical parameters. Diabetes. (2020) 69:2086–93. doi: 10.2337/dbi20-0001. PMID: 32843567
- [9] Skjervold K Sævig HN Ræder H Lundervold A Lundervold AS. DiaGuide-LLM-Using large language models for patient-specific education and health guidance in diabetes. Front Artif Intell. (2025) 8:1652556. doi: 10.3389/frai.2025.1652556. PMID: 41395370
- [10] Vilakati S. Prompt engineering for accurate statistical reasoning with large language models in medical research. Front Artif Intell. (2025) 8:1658316. doi: 10.3389/frai.2025.1658316. PMID: 41159127
- [11] American Diabetes Association Professional Practice Committee. Diagnosis and classification of diabetes: Standards of care in diabetes-2025. Diabetes Care. (2025) 48:S27–49. doi: 10.26463/rjms.15_1_12. PMID: 41813583
- [12] Tuttle KR Bakris GL Bilous RW Chiang JL de Boer IH Goldstein-Fuchs J et al. Diabetic kidney disease: a report from an ADA Consensus Conference. Diabetes Care. (2014) 37:2864–83. doi: 10.2337/dc14-1296. PMID: 25249672
- [13] Society CD. Chinese guideline for the prevention and treatment of type 2 diabetes mellitus(2017 edition). Chin J Diabetes Mellitus. (2018) 10:4–67. doi: 10.3760/cma.j.issn.1674-5809.2018.01.003, PMID: 40668938
- [14] Grattafiori A Dubey A Jauhri A Pandey A Kadian A Al-Dahle A et al. The Llama 3 Herd of Models. arxiv:240721783. [csAI,csCL,csCV].
- [15] Qwen Yang A Yang B Zhang B Hui B Zheng B et al. Qwen2.5 Technical Report. arxiv:241215115. [csCL].
- [16] Yang A Yang B Hui B Zheng B Yu B Zhou C et al. Qwen2 Technical Report. arxiv:240710671. [csCL,csAI].
- [17] Wang P Bai S Tan S Wang S Fan Z Bai J et al. Qwen2-VL: Enhancing Vision-Language Model's Perception of the World at Any Resolution. arxiv:240912191. [csCV,csAI,csCL].
- [18] Bai J Bai S Yang S Wang S Tan S Wang P et al. Qwen-VL: A versatile vision-language model for understanding, localization, text reading, and beyond. arxiv:230812966. [csCV,csCL].
- [19] DeepSeek AI Guo D Yang D Zhang H Song J Zhang R et al. DeepSeek-R1: Incentivizing reasoning capability in LLMs via reinforcement learning. arxiv:250112948. [csCL,csAI,csLG].
- [20] DeepSeek AI Liu A Feng B Xue B Wang B Wu B et al. DeepSeek-V3 Technical Report. arxiv:241219437. [csCL,csAI].
- [21] Qiu P Wu C Zhang X Lin W Wang H Zhang Y et al. Towards building multilingual language model for medicine. Nat Commun. (2024) 15:8384. doi: 10.1038/s41467-024-52417-z. PMID: 39333468
- [22] Chen J Wang X Ji K Gao A Jiang F Chen S et al. (2024). HuatuoGPT-II, One-stage Training for Medical Adaption of LLMs, in: First Conference on Language Modeling, .
- [23] Rasool A Shahzad MI Aslam H Chan V Arshad MA. Emotion-aware embedding fusion in large language models (Flan-T5, Llama 2, DeepSeek-R1, and ChatGPT 4) for intelligent response generation. AI. (2025) 6:56. doi: 10.3390/ai6030056. PMID: 41725453
- [24] Hager P Jungmann F Holland R Bhagat K Hubrecht I Knauer M et al. Evaluation and mitigation of the limitations of large language models in clinical decision-making. Nat Med. (2024) 30:2613–22. doi: 10.1038/s41591-024-03097-1. PMID: 38965432
- [25] Kim J Podlasek A Shidara K Liu F Alaa A Bernardo D. Limitations of large language models in clinical problem-solving arising from inflexible reasoning. Sci Rep. (2025) 15:39426. doi: 10.1038/s41598-025-22940-0. PMID: 41219270
- [26] Wei J Wang X Schuurmans D Bosma M Chi E Le Q et al. Chain of thought prompting elicits reasoning in large language models. (2022).
- [27] Turpin M Michael J Perez E Bowman SR. Language models don't always say what they think: Unfaithful explanations in chain-of-thought prompting. (2023). doi: 10.52202/075280-3275
- [28] Ayoub M Zhao H Li L Yang D Hussain S Wahid JA. Structured clinical approach to enable large language models to be used for improved clinical diagnosis and explainable reasoning. Commun Med. (2026) 6:86. doi: 10.1038/s43856-025-01348-x. PMID: 41507533
- [29] Hamid R Brohi S. A review of large language models in healthcare: Taxonomy, threats, vulnerabilities, and framework. Big Data Cogn Computing. (2024) 8:161. doi: 10.3390/bdcc8110161. PMID: 41725453
- [30] Niess G Razouk H Mandic S Kern R. Addressing hallucination in causal Q&A: The efficacy of fine-tuning over prompting in LLMs. Abu Dhabi, UAE: Association for Computational Linguistics (2025).
- [31] Ghanem H Cruz C. Fine-tuning or prompting on LLMs: Evaluating knowledge graph construction task. Front Big Data. (2025) 8:1505877. doi: 10.3389/fdata.2025.1505877. PMID: 40636754
- [32] Thirunavukarasu AJ Ting DSJ Elangovan K Gutierrez L Tan TF Ting DSW. Large language models in medicine. Nat Med. (2023) 29:1930–40. doi: 10.1038/s41591-023-02448-8. PMID: 37460753
- [33] Lu W Luu RK Buehler MJ. Fine-tuning large language models for domain adaptation: Exploration of training strategies, scaling, model merging and synergistic capabilities. NPJ Comput Mater. (2025) 11:84. doi: 10.1038/s41524-025-01564-y. PMID: 41803196
- [34] Dettmers T Pagnoni A Holtzman A Zettlemoyer L. Qlora: Efficient finetuning of quantized llms. Adv Neural Inf Process Syst. (2023) 36:10088–115. doi: 10.52202/075280-0441
- [35] Frantar E Ashkboos S Hoefler T Alistarh D. GPTQ: Accurate post-training quantization for generative pre-trained transformers. (2022).
- [36] Yang C Zhu Y Lu W Wang Y Chen Q Gao C et al. Survey on knowledge distillation for large language models: Methods, evaluation, and application. ACM Trans Intell Syst Technol. (2025) 16:Article 143. doi: 10.1145/3699518. PMID: 40727313
- [37] Ding S Ye J Hu X Zou N. Distilling the knowledge from large-language model for health event prediction. Sci Rep. (2024) 14:30675. doi: 10.1101/2024.06.23.24309365. PMID: 41723302
- [38] Lai VD Ngo N Amir Pouran Ben V Hieu M Franck D Trung B et al. ChatGPT beyond English: Towards a comprehensive evaluation of large language models in multilingual learning. Singapore: Association for Computational Linguistics (2023).
- [39] Celi LA Cellini J Charpignon ML Dee EC Dernoncourt F Eber R et al. Sources of bias in artificial intelligence that perpetuate healthcare disparities-a global review. PloS Digit Health. (2022) 1:e0000022. doi: 10.1371/journal.pdig.0000022. PMID: 36812532
- [40] Gianfrancesco MA Tamang S Yazdany J Schmajuk G. Potential biases in machine learning algorithms using electronic health record data. JAMA Intern Med. (2018) 178:1544–7. doi: 10.1001/jamainternmed.2018.3763. PMID: 30128552
- [41] Lin K Rasool A Surabhi S Mutlu C Zhang H Wall DP et al. Aiding large language models using clinical scoresheets for neurobehavioral diagnostic classification from text: Algorithm development and validation. JMIR AI. (2025) 4:e75030. doi: 10.2196/75030. PMID: 41118647
- [42] Rasool A Aslam S Hussain N Imtiaz S Riaz W. nBERT: Harnessing NLP for emotion recognition in psychotherapy to transform mental health care. Information. (2025) 16:301. doi: 10.3390/info16040301. PMID: 41725453
Notes
Edited by: Xiantong Zou, Peking University People’s Hospital, China
Reviewed by: Abdur Rasool, University of Hawaii at Manoa, United States Sifiso Vilakati, University of the Free State, South Africa