Abstract:
Objective To develop a clinical decision and prescription generation system (CDPGS) specifically for diarrhea in traditional Chinese medicine (TCM), utilizing a specialized large language model (LLM), Qwen-TCM-Dia, to standardize diagnostic processes and prescription generation.
Methods Two primary datasets were constructed: an evaluation benchmark and a fine-tuning dataset consisting of fundamental diarrhea knowledge, medical records, and chain-of-thought (CoT) reasoning datasets. After an initial evaluation of 16 open-source LLMs across inference time, accuracy, and output quality, Qwen2.5 was selected as the base model due to its superior overall performance. We then employed a two-stage low-rank adaptation (LoRA) fine-tuning strategy, integrating continued pre-training on domain-specific knowledge with instruction fine-tuning using CoT-enriched medical records. This approach was designed to embed the clinical logic (symptoms → pathogenesis → therapeutic principles → prescriptions) into the model’s reasoning capabilities. The resulting fine-tuned model, specialized for TCM diarrhea, was designated as Qwen-TCM-Dia. Model performance was evaluated for disease diagnosis and syndrome type differentiation using accuracy, precision, recall, and F1-score. Furthermore, the quality of the generated prescriptions was compared with that of established open-source TCM LLMs.
Results Qwen-TCM-Dia achieved peak performance compared to both the base Qwen2.5 model and five other open-source TCM LLMs. It achieved 97.05% accuracy and 91.48% F1-score in disease diagnosis, and 74.54% accuracy and 74.21% F1-score in syndrome type differentiation. Compared with existing open-source TCM LLMs (BianCang, HuangDi, LingDan, TCMLLM-PR, and ZhongJing), Qwen-TCM-Dia exhibited higher fidelity in reconstructing the “symptoms → pathogenesis → therapeutic principles → prescriptions” logic chain. It provided complete prescriptions, whereas other models often omitted dosages or generated mismatched prescriptions.
Conclusion By integrating continued pre-training, CoT reasoning, and a two-stage fine-tuning strategy, this study establishes a CDPGS for diarrhea in TCM. The results demonstrate the synergistic effect of strengthening domain representation through pre-training and activating logical reasoning via CoT. This research not only provides critical technical support for the standardized diagnosis and treatment of diarrhea but also offers a scalable paradigm for the digital inheritance of expert TCM experience and the intelligent transformation of TCM.