Abstract
Traditional Chinese Medicine (TCM) formula generation requires a deep understanding of complex herb interactions and clinical reasoning. We present ZhiFangDanTai, a framework integrating Graph-based Retrieval-Augmented Generation (GraphRAG) with fine-tuned Large Language Models (LLMs). By leveraging structured knowledge graphs and Direct Preference Optimization (DPO), the model achieves high medical accuracy and explainability, significantly reducing hallucinations compared to standard RAG approaches.
Introduction
Traditional Chinese Medicine (TCM) is a holistic medical system where formulas are meticulously balanced based on specific herb roles—sovereign, minister, assistant, and courier—and nuanced patient indicators like tongue and pulse diagnosis. Existing AI approaches for TCM formula generation often fall into two traps: traditional deep learning models act as "black boxes" focusing only on herb associations, while standard LLMs and Retrieval-Augmented Generation (RAG) systems frequently "hallucinate" incorrect medical advice due to a lack of deep domain knowledge and an inability to synthesize global context from unstructured text.
Methodology
The ZhiFangDanTai framework bridges the gap between structured medical knowledge and generative flexibility through a multi-stage pipeline.
GraphRAG Module
Instead of simple text retrieval, the system constructs a Knowledge Graph (KG) from TCM documents. It utilizes the Leiden community detection algorithm to group related entities into "communities" (e.g., specific diseases or herb categories). The model generates summaries for these communities, allowing it to retrieve both local details and global context during the query process.
Knowledge Graph Construction
The KG maps complex relationships between diseases, symptoms, and ingredients. This structured approach allows the model to move beyond simple herb lists by defining a seven-category taxonomy for TCM information, including contraindications and preparation methods.
Fine-tuning (SFT + DPO)
The model undergoes Supervised Fine-tuning (SFT) on an enhanced instruction dataset. Crucially, it also employs Direct Preference Optimization (DPO) to align outputs with expert-level reasoning. This process effectively "teaches" the model to prefer medically sound formulas over plausible-sounding but incorrect hallucinations.
Datasets and Evaluation
The study utilized approximately 80,000 TCM formulas from the Chinese Formula Database and ancient catalogues, alongside a clinical dataset of 30,400 real-world patient records from Haodf.com.
ZhiFangDanTai significantly outperformed state-of-the-art baselines, including vanilla LLaMA and standard RAG, across both machine translation metrics and TCM-specific indicators. It achieved an average score of 0.8373 across all metrics, compared to 0.6959 for standard RAG. Notably, the model scored high on the Compatibility Compliance Rate (CCR) and Correct Sovereign-minister-assistant-messenger Compatibility Rate (CSCR), indicating strict adherence to traditional medical rules.
Key Insights
- Community Summarization: By summarizing entire "communities" of knowledge rather than just retrieving text snippets, the model gains a global understanding of disease patterns essential for TCM.
- DPO as a Guardrail: DPO proved highly effective at suppressing "hallucinated" herbs that might appear plausible to a general LLM but violate TCM principles.
- Synergy of Retrieval and Tuning: Retrieval provides "open-book" facts, while fine-tuning provides the "internalized" ability to synthesize those facts correctly.
Conclusion and Future Work
ZhiFangDanTai demonstrates that combining GraphRAG with advanced alignment techniques can produce a robust decision-support tool for TCM. While the GraphRAG process adds slight computational latency, the gains in accuracy and explainability are substantial. Future work will explore more complex graph structures and expand the dataset to include diverse regional TCM practices. The authors emphasize that this model is intended for decision support and should not replace professional medical judgment.
Summary updated