Traditional Chinese medicine prescription generation method based on graph attention network and large language model
By combining graph attention networks with a large language model, the problems of sequential dependence of Chinese medicinal materials and ambiguity of drug relationships in the generation of Chinese medicine prescriptions are solved, realizing the rationality and safety of Chinese medicine prescriptions and supporting the generation of multiple reasonable schemes.
Patent Information
- Application Number
- CN202610131377.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-30
- Publication Date
- 2026-05-15
AI Technical Summary
Existing technologies for generating traditional Chinese medicine prescriptions suffer from problems such as dependence on the order of medicinal materials, difficulty in supporting multiple prescriptions for one symptom, and ambiguity in drug relationships, resulting in unreasonable generated results and potential safety hazards.
By combining graph attention networks with large language models, and through symptom semantic modeling, latent syndrome feature fusion, multi-label prediction, and dual constraints of drug synergistic contraindications, we can achieve safe and accurate generation of traditional Chinese medicine prescriptions.
The generated traditional Chinese medicine prescriptions have significantly improved rationality and medication safety, effectively supporting the multi-solution modeling of "one symptom, multiple prescriptions", and uniformly modeling drug synergy relationships and contraindications during the generation process.
Smart Images

Figure CN122050683A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of artificial intelligence technology and traditional Chinese medicine information processing, specifically to a method for generating traditional Chinese medicine prescriptions based on graph attention networks and large language models, belonging to the interdisciplinary technical fields of intelligent healthcare, traditional Chinese medicine auxiliary decision-making, and computer natural language processing. Background Technology
[0002] Traditional Chinese medicine (TCM) is a traditional medical system that has gradually formed in long-term medical practice. Its theoretical basis is based on the holistic concept and syndrome differentiation and treatment. It emphasizes inferring the internal pathogenesis of the human body through comprehensive analysis of symptoms and manifestations, and achieving the therapeutic goal through the rational combination of Chinese medicine prescriptions [1][2]. Chinese medicine prescriptions not only reflect the physician's comprehensive judgment on symptoms, syndromes and differences in constitution, but also contain a large number of empirical rules about drug synergy, antagonism and drug safety [3]. Therefore, the accuracy and rationality of Chinese medicine prescriptions are directly related to clinical efficacy and patient safety.
[0003] With the development of information technology and intelligence in traditional Chinese medicine, using computer technology to model and automate the process of generating Chinese medicine prescriptions has become an important direction in the research and application of traditional Chinese medicine [4][5]. However, in clinical practice of traditional Chinese medicine, there is a common phenomenon of "one symptom, multiple prescriptions", that is, the same or similar symptom descriptions often correspond to multiple different but reasonable combinations of Chinese medicine prescriptions; at the same time, Chinese medicine prescriptions are essentially a disordered set of multiple medicinal materials, and the order of each medicinal material in the prescription does not affect its clinical efficacy. This characteristic makes the task of generating Chinese medicine prescriptions different from the traditional sequence prediction problem, which increases the difficulty of automatic modeling.
[0004] Early related studies mainly used topic models, rule matching, or statistical association-based methods to model the relationship between symptoms and medicinal materials [6][7]. These methods can uncover co-occurrence patterns between symptoms and medicinal materials to a certain extent, but their ability to model complex drug compatibility relationships and individual differences is limited, and they are difficult to cope with large-scale and diverse clinical symptom inputs. Subsequently, with the development of deep learning technology, some studies have modeled the problem of traditional Chinese medicine prescription generation as a sequence-to-sequence task, directly generating medicinal material sequences from symptom texts through neural network models [8][9]. However, these methods usually assume that prescriptions have a fixed order, which can easily introduce unnecessary sequence dependencies, and tend to learn high-frequency prescription combinations during training, thus ignoring the equally important long-tail compatibility patterns in clinical practice.
[0005] On the other hand, TCM diagnosis and treatment emphasizes "differentiation of syndromes and treatment based on syndrome differentiation", that is, different syndrome types often correspond to the symptoms, and syndrome information has key guiding significance for medication plans
[10] . Some existing TCM prescription generation methods directly establish the mapping relationship between symptoms and medicinal materials, without effectively modeling the intermediate level of syndrome, making it difficult to distinguish clinical situations with similar symptoms but different pathogenesis, resulting in insufficient targetedness and interpretability of the generated prescriptions.
[0006] In addition, the rationality of Chinese medicine prescriptions depends not only on whether the single herb matches the symptoms, but also on the compatibility between the herbs. Chinese medicine formularies clearly record a large number of drug synergy and antagonism rules. Some herb combinations have synergistic effects, while some combinations have contraindications or require caution when used together [3]. Some studies have attempted to introduce knowledge graphs or graph neural networks to model the relationships between herbs in order to improve the rationality of drug recommendations
[11]
[12] . However, most methods are still data-driven and lack a constraint mechanism that integrates drug synergy and contraindication rules into the generation process. The generated results may still contain unreasonable or potentially risky drug combinations.
[0007] In recent years, large language models have made significant progress in the field of natural language understanding and generation, and have been gradually introduced into research related to TCM diagnosis and treatment
[13]
[14] . These models have advantages in symptom semantic understanding and context modeling, but their generation mechanism mainly relies on large-scale text statistical patterns and lacks the inherent modeling ability of TCM professional knowledge, drug compatibility principles and drug safety constraints. If large language models are directly applied to TCM prescription generation, problems such as uncontrollable generation results and lack of constraints on drug selection may easily occur, making it difficult to meet the requirements of safety and reliability for actual clinical applications.
[0008] In summary, existing technologies still have the following shortcomings in the task of generating traditional Chinese medicine prescriptions: it is difficult to eliminate the dependence of medicinal material order while simultaneously supporting multiple solutions for "one symptom, multiple prescriptions"; it is difficult to effectively incorporate TCM syndrome information to distinguish different pathogenesis situations; and it is difficult to uniformly model drug synergistic relationships and contraindications during the generation process, thereby ensuring the rationality and safety of prescriptions. Therefore, it is necessary to propose a new TCM prescription generation technology to overcome the above problems.
[0009] 1.F. Cheung. TCM: made in China[J]. Nature, 2011, 480(7378): S82–S83.
[0010] Traditional Chinese Medicine: A Medical System Originating in China, Nature Journal
[0011] 2. Cui Ji, Xu Jiatuo. Application and prospect of TCM diagnosis and treatment technology under the background of artificial intelligence [J]. Journal of the Second Military Medical University, 2018, 39(08):846-851. DOI:10.16781 / j.0258-879x.2018.08.0846.
[0012] 3.Y. Huang, S. Wang, L. Wang, et al. Exploring the rules of li-fa-fang-yao on diabetes mellitus within traditional Chinese medicine throughtext mining[C]. IEEE ICCCT, 2012: 1369–1373.
[0013] [A Study on the Patterns of Traditional Chinese Medicine's "Theory-Method-Prescription-Medicine" in Diabetes Based on Text Mining, IEEE International Conference on Computing and Communication Technologies]
[0014] 4.H. Yang, J. Chen, S. Tang, et al. New drug R&D of traditional Chinese medicine: Role of data mining approaches[J]. Journal of BiologicalSystems, 2009, 17(03): 329–347.
[0015] [The Role of Data Mining Methods in the Development of New Traditional Chinese Medicine Drugs, Journal of Biosystems]
[0016] 5.
[0017] [Construction of a Traditional Chinese Medicine Clinical Data Warehouse for Medical Knowledge Discovery and Decision Support, *Medical Artificial Intelligence*]
[0018] 6.L. Yao, Y. Zhang, B. Wei, et al. A topic modeling approach fortraditional Chinese medicine prescriptions[J]. IEEE TKDE, 2018, 30(6): 1007–1021.
[0019] [A Method for Analyzing Traditional Chinese Medicine Prescriptions Based on Topic Modeling, IEEE Transactions on Knowledge and Data Engineering]
[0020] 7.X. Wang, Y. Zhang, X. Wang, et al. A knowledge graph enhanced topicmodeling approach for herb recommendation[C]. DASFAA, 2019: 709–724.
[0021] [A Thematic Modeling Method for Traditional Chinese Medicine Recommendation Integrating Knowledge Graphs: International Conference on Advanced Applications of Database Systems]
[0022] 8. W. Li, Z. Yang. Exploration on generating traditional Chinese medicine prescriptions from symptoms with an end-to-end approach[C]. NLPCC, 2019: 486–498.
[0023] [A Symptom-to-TCM Prescription Generation Method Based on an End-to-End Model, Conference on Natural Language Processing and Chinese Computing]
[0024] 9. W. Zhong, L. Zhao, Z. Yang, et al. Graph convolutional network approach to investigate potential selective Limk1 inhibitors[J]. Journal ofMolecular Graphics and Modelling, 2021, 107: 107965.
[0025] [Research on potential Limk1 inhibitors based on graph convolutional networks, *Journal of Molecular Graphics and Modeling*]
[0026] 10.M. Jiang, C. Lu, C. Zhang, et al. Syndrome differentiation in modern research of traditional Chinese medicine[J]. Journal ofEthnopharmacology, 2012, 140(3): 634–642.
[0027] [Modern Research Progress on Traditional Chinese Medicine Syndrome Differentiation and Treatment, Journal of Ethnic Pharmacology]
[0028] 11.Y. Jin, W. Ji, W. Zhang, et al. A KG-enhanced multi-graph neural network for attentive herb recommendation[J]. IEEE / ACM TCBB, 2021, 19(5):2560–2571.
[0029] [A Multi-Graph Neural Network Approach to Traditional Chinese Medicine Recommendation Integrating Knowledge Graphs, IEEE / ACM Transactions on Computational Biology and Bioinformatics]
[0030] 12.Y. Yang, Y. Rao, M. Yu, et al. Multi-layer information fusionbased on graph convolutional network for knowledge-driven herb recommendation[J]. Neural Networks, 2022, 146: 1–10.
[0031] [A Multi-Layer Information Fusion Method for Traditional Chinese Medicine Recommendation Based on Graph Convolutional Networks, *Neural Networks*]
[0032] 13. Chen Qitao, Ni Jingwen, Xu Jun, et al. Research on Traditional Chinese Medicine Prescription Generation Driven by Generative Artificial Intelligence GPT-4 [J]. China Pharmacy, 2023, 34(23):2825-2828.
[0033] 14.
[0034] [TCM-FTP: A Fine-tuning Method for Large Language Models for Traditional Chinese Medicine Prescription Prediction, IEEE Bioinformatics and Biomedical Conference]
[0035] 15. H. Pu, J. Mi, S. Lu, et al. RoKEPG: RoBERTa and KnowledgeEnhancement for Prescription Generation of Traditional Chinese Medicine[C]. IEEE BIBM, 2023: 4615–4622.
[0036] [RoKEPG: A Traditional Chinese Medicine Prescription Generation Method Integrating RoBERTa and Knowledge Augmentation, IEEE Bioinformatics and Biomedical Conference] Summary of the Invention
[0037] The purpose of this invention is to address the problems in traditional Chinese medicine (TCM) prescription generation, such as the dependence of medicinal material order, difficulty in supporting multiple prescriptions for a single symptom, and ambiguity in drug relationships. It provides a TCM prescription generation method based on graph attention networks and a large language model. Through collaborative modeling of symptom semantics, potential syndrome features, and drug compatibility relationships, it achieves safe, accurate, and controllable TCM prescription generation.
[0038] The technical solution adopted by this invention to solve the technical problem is:
[0039] (1) Symptom semantic modeling and representation acquisition: Acquire the symptom text information input by the user, and use a pre-trained large language model to perform semantic encoding on the symptom text to obtain a symptom representation vector that can characterize the overall semantic features of the symptoms. This approach enhances the model's semantic understanding of complex, unstructured symptom descriptions, providing a unified semantic representation foundation for subsequent prescription generation.
[0040] (2) Modeling and fusion of latent syndrome features, based on symptom representation vectors A latent syndrome modeling branch is constructed to learn the latent syndrome features corresponding to symptoms, and the symptom representation and syndrome features are fused to obtain a joint feature representation. Its form can be expressed as in, This represents the syndrome embedding vector obtained by learning from the latent syndrome branch.
[0041] (3) Generation of traditional Chinese medicine prescriptions based on multi-label prediction, based on the joint feature representation For the predefined complete set of Chinese medicinal materials Parallel prediction is performed, modeling the traditional Chinese medicine prescription generation task as a multi-label classification problem to obtain the predicted probability of each Chinese medicinal herb being selected into the prescription. ,in:
[0042] (5)
[0043] This approach eliminates the dependence on the order of medicinal materials in a prescription, allowing the model to directly learn the selection relationships at the level of medicinal material sets, which is more in line with the essential characteristics of traditional Chinese medicine prescriptions.
[0044] (4) Support for a multi-solution alignment training mechanism for "one symptom, multiple prescriptions": During the model training phase, for multiple combination Chinese medicine prescriptions corresponding to the same symptom text, a multi-solution alignment mechanism is introduced to match the model prediction results with multiple sets of reference prescriptions respectively, and select the set with the smallest loss as the optimization target of the current sample, as shown in formula (6):
[0045] (6)
[0046] (5) Based on the dual-constraint prescription optimization of drug synergy and contraindication, a drug relationship graph is constructed according to the drug co-occurrence relationship in historical prescriptions, and the synergy relationship between drugs is modeled using graph attention network to obtain drug synergy weights; at the same time, combined with the pre-constructed drug contraindication rules, a synergy-antagonism dual-constraint scoring mechanism is introduced for candidate Chinese medicine prescriptions to comprehensively score and optimize the candidate prescriptions. The scoring form can be expressed as formula (7):
[0047] (7)
[0048] in, This indicates a positive scoring item based on drug synergy. This indicates a penalty based on drug contraindication rules.
[0049] The beneficial effects of this invention are: This invention can significantly improve the rationality of prescriptions and the safety of medication. Attached Figure Description
[0050] Figure 1 This is a schematic diagram of the overall process of a method for generating traditional Chinese medicine prescriptions based on graph attention networks and large language models according to the present invention.
[0051] Figure 2 A schematic diagram of the structure for fusing symptom semantic modeling with implicit syndrome features;
[0052] Figure 3 This is a schematic diagram of the process of generating traditional Chinese medicine prescriptions based on multi-label prediction.
[0053] Figure 4This is a schematic diagram of collaborative relationship modeling and dual-constraint prescription optimization based on drug relationship graphs. Specific implementation methods
[0054] The specific implementation steps of a method for generating traditional Chinese medicine prescriptions based on graph attention networks and large language models are as follows:
[0055] (I) Symptom Text Input and Semantic Encoding:
[0056] The system obtains symptom text information input by the user, which may include medical text in natural language form, such as the patient's chief complaint, symptom description, and accompanying symptoms. Figure 2 As shown, a pre-trained large language model is used to semantically encode the symptom text, obtaining a symptom semantic representation vector to characterize the overall semantic information and contextual relationships in the symptom text. This step maps the unstructured symptom text into a unified continuous vector representation, providing fundamental semantic features for subsequent prescription generation.
[0057] (II) Modeling and feature fusion of implicit syndrome features:
[0058] like Figure 2 As shown, based on the obtained symptom semantic representation vector, a latent syndrome modeling branch is constructed to further map the symptom semantic representation and learn the potential syndrome features corresponding to the symptoms. These latent syndrome features do not correspond to specific explicit syndrome names but participate in subsequent calculations as continuous vectors.
[0059] Specifically, for a given piece of data ,Will As input symptom text, the context-sensitive hidden state matrix is first obtained through a symptom encoder, and then the global symptom representation is obtained through pooling. To simulate syndrome inference in dialectical treatment, a latent variable branch is added to the hidden state: first, a fully connected layer is used to generate the logits of each syndrome category, and then a second projection layer is used to obtain the latent syndrome vector z. The symptom representation and the syndrome representation are concatenated along the feature dimension to form a fusion vector. This vector preserves both the semantic context of the symptoms and the potential syndrome information. Through this step, the principles of syndrome differentiation and treatment in traditional Chinese medicine are introduced into the prescription generation process without relying on manual syndrome annotation.
[0060] (III) Generation of Traditional Chinese Medicine Prescriptions Based on Multi-Label Prediction:
[0061] like Figure 3As shown, based on the joint feature representation, parallel prediction is performed on the predefined complete set of Chinese medicinal materials, modeling the Chinese medicine prescription generation task as a multi-label classification problem, and calculating the predicted probability of each Chinese medicinal material being selected into the prescription. Based on the predicted probabilities and a preset threshold, a candidate set of Chinese medicinal materials is determined, thus obtaining an initial candidate Chinese medicine prescription. Since this step directly predicts the set of medicinal materials, it avoids the influence of the order of medicinal materials on the generated result, and is more consistent with the actual expression form of Chinese medicine prescriptions.
[0062] (iv) Supporting a multi-solution alignment training mechanism for "one symptom, multiple treatments":
[0063] During the model training phase, for multiple combinations of traditional Chinese medicine prescriptions that may correspond to the same symptom text, the model's prediction results are matched with multiple sets of reference prescriptions, and the set with the smallest loss is selected as the training target for the current sample. In this way, the model can automatically select the one that best matches the semantics of the current symptom from a variety of reasonable prescription schemes for learning, thus naturally supporting the phenomenon of "one symptom, multiple prescriptions" that is common in TCM clinical practice.
[0064] (v) Prescription optimization based on dual constraints of drug synergy and contraindications:
[0065] like Figure 4 As shown, a drug relationship graph is constructed based on the co-occurrence relationships of Chinese medicinal herbs in historical prescription data. Using these herbs as graph nodes, a graph attention network is used to model the synergistic relationships between drugs, obtaining their synergistic weights. Simultaneously, a set of drug contraindication rules, including contraindicated or caution-required drug combinations, is pre-constructed. When generating candidate prescriptions, both drug synergies and contraindication rules are considered. A dual-constraint scoring mechanism (DCSA) is used to comprehensively evaluate candidate prescriptions, penalizing prescriptions containing contraindicated drug combinations and enhancing prescriptions with good synergistic relationships, thereby filtering or generating the final Chinese medicine prescription results.
[0066] DCSA first binarizes the medicinal herb recommendation probability vector p based on a threshold τ to obtain the candidate prescription vector. Subsequently, a hard penalty term was calculated for set C using prohibited drugs. The soft collaborative score is obtained by combining the attention coefficient extracted by GAT with the prediction probability. Finally, construct the matching regularization term. and binary cross-entropy loss aligned with multiple solutions Add them together to get the final loss. During the training phase, incompatible drug combinations are explicitly punished while synergistic drug pairs commonly found in clinical practice are encouraged.
[0067] Algorithm 1: A Dual-Constraint Scoring Algorithm (DCSA)
[0068] I. Input Parameters
[0069] II. Algorithm Steps
[0070] Step 1: Candidate Prescription Generation
[0071] For each medicinal herb The selection of a prescription is determined based on the predicted probability and a threshold. ;
[0072] in, Indicates the first The medicinal herbs were selected as candidate prescriptions.
[0073] Step 2: Calculation of hard constraint penalties for contraindicated drug pairs
[0074] Initialize hard constraint penalty term For taboo sets Each pair of drugs If the following conditions are met: ;
[0075] If a forbidden co-occurrence occurs, the penalty term is incremented by 1. The final hard constraint penalty value is then obtained. ;
[0076] Step 3: Calculation of Soft Collaborative Scoring Based on Graph Attention
[0077] Initialize soft collaborative scoring items For each Chinese herb Iterate through the set of adjacent Chinese medicines in the drug co-occurrence graph. For each neighbor Add the following items: ;
[0078] in, This represents the drug learned by the graph attention network. and The synergy weights between them are then used to arrive at the final weighted soft synergy score. ;
[0079] Step 4: Constructing the Double-Constraint Regularization Term and the Total Loss Function
[0080] Constructing a double-constraint regularization term: ;
[0081] The hard constraint penalty term is used to suppress the co-selection of incompatible drug pairs, while the soft synergy term is used to encourage the joint appearance of traditional Chinese medicines with synergistic relationships. The final loss function is defined as: ;
[0082] Output the final loss function value after correction by the double-constraint scoring algorithm. .
Claims
1. A method for generating traditional Chinese medicine prescriptions based on graph attention networks and large language models, characterized in that, Includes the following steps: 1) Obtain the symptom text information input by the user, encode the symptom text, and obtain the symptom semantic representation; 2) Based on the symptom semantic representation, a latent syndrome branch is constructed, the potential syndrome features corresponding to the symptoms are learned, and the symptom semantic representation and syndrome features are fused to obtain a joint feature representation; 3) Based on the joint feature representation, perform multi-label prediction on the predefined set of Chinese medicinal materials to obtain the probability value of each Chinese medicinal material being selected into the prescription; 4) Construct a drug graph based on drug co-occurrence relationships and use a graph attention network to learn synergistic relationships between drugs; 5) Combining drug synergy relationships with preset drug contraindication rules, the predicted medicinal materials obtained in step 3) are subjected to dual-constraint scoring and optimization to generate the final Chinese medicine prescription.
2. The method according to claim 1, characterized in that: During the model training phase, multiple combination-method traditional Chinese medicine prescription tag sets corresponding to the same symptom text are used. Each prescription label vector Indicates the first The method considers the selection status of each Chinese medicinal herb in a reference prescription, without simultaneously constraining the multiple sets of prescription labels, but rather applying the model-predicted probability vector of the medicinal herbs. The multi-label loss function is calculated for each group of reference prescription labels, and the minimum loss is selected as the optimization objective for that sample. The calculation method is shown in Equation (1): (1); in, This represents the total number of candidate Chinese medicinal materials. Indicates the first The predicted probability of Chinese medicinal herbs being selected into a prescription; the minimization operation is used to guide the model to automatically select the group that best matches the semantics of the current symptom in a multi-combination prescription for alignment learning.
3. The method according to claim 1, characterized in that: In the candidate traditional Chinese medicine prescription generation stage, a dual-constraint scoring mechanism based on drug synergy and drug incompatibilities is introduced. This mechanism is based on a pre-constructed set of drug incompatibilities. For candidate prescription label vectors The hard antagonistic penalty term is calculated as shown in formula (2): (2); Meanwhile, based on the drug relationship graph constructed with Chinese medicinal materials as nodes, the collaborative weights between drugs are learned through graph attention networks. And combined with the predicted probability vector of medicinal materials The soft synergy scoring item is calculated according to formula (3). (3); Finally, the soft synergistic scoring term and the hard antagonistic penalty term are weighted and fused to obtain the comprehensive scoring function of the candidate prescription. (4); in, This is a penalty weighting coefficient used to suppress the generation of traditional Chinese medicine prescriptions containing prohibited drug combinations.