Traditional Chinese herbal medicine recommendation method and system based on structured evidence sub-graph retrieval enhancement generation

By introducing multi-hop structured evidence subgraphs and Hopfield network associative retrieval into the TCM knowledge graph, combined with graph neural network encoding and cross-modal alignment, the problems of data sparsity and model illusion in TCM herbal medicine recommendation are solved, achieving highly accurate and interpretable recommendation results.

CN121687367APending Publication Date: 2026-03-17ZHEJIANG CHINESE MEDICAL UNIVERSITY
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202511857346.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-10
Publication Date
2026-03-17

AI Technical Summary

Technical Problem

Existing methods for recommending TCM herbal medicines have shortcomings in terms of data sparsity, insufficient utilization of structured knowledge, high risk of model illusion, and poor interpretability of recommendation results. They are difficult to effectively utilize the multi-source heterogeneous knowledge in TCM knowledge graphs, and traditional methods have limited accuracy and reliability in recommendation.

Method used

We employ multi-hop structured evidence subgraphs as retrieval and reasoning units, combine them with Hopfield networks for associative subgraph retrieval, and integrate symptom text semantics through graph neural network encoding and cross-modal alignment mechanisms to construct a TCM knowledge graph, thereby improving recommendation accuracy and interpretability.

Benefits of technology

It significantly improves the accuracy and reliability of TCM herbal recommendations, reduces the hallucination rate, provides a clear structured evidence path, and has good engineering deployability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121687367A_ABST
    Figure CN121687367A_ABST
Patent Text Reader

Abstract

The invention discloses a traditional Chinese herbal medicine recommendation method and system based on structured evidence sub-graph retrieval enhancement generation, and relates to the technical field of artificial intelligence and medical information processing. In order to solve the problems that an existing method is poor in recommendation effect in a data sparse scene, a generative model has illusion risks and the like, a multi-hop structured evidence sub-graph is used as a basic unit for retrieval and reasoning. The method comprises the following steps: firstly, constructing a traditional Chinese medicine knowledge graph covering various entities such as symptoms, herbal medicines, effects and syndromes and a multi-hop relationship, exporting a structured evidence sub-graph, and establishing a sub-graph vector retrieval engine; and during operation, aiming at the input symptoms, introducing a modern Hopfield network to carry out associative state updating, generating a query vector capable of reflecting a potential pathological mode, and accurately retrieving and reordering the structured evidence sub-graphs from the sub-graph vector retrieval engine. And then, extracting the structured evidence sub-graph features by using a graph neural network encoder, realizing cross-modal alignment of graph structure representation and text semantic representation through a projection network and a comparative learning mechanism, and deeply fusing knowledge in a unified semantic space. In addition, the method is also combined with a selective retrieval strategy based on uncertainty and an illusion rate control mechanism based on knowledge graph constraint. Experiments show that the method can significantly improve the accuracy and robustness of herbal medicine recommendation, provides visual structured evidence, and has good clinical interpretability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of artificial intelligence and medical information processing, and particularly to a traditional Chinese medicine herb recommendation method and system based on structured evidence subgraph retrieval enhanced generation, which combines traditional Chinese medicine knowledge graph and structured evidence subgraph retrieval enhanced generation technology to achieve traditional Chinese medicine herb recommendation, and is used for the traditional Chinese medicine herb multi-label recommendation task of single symptom or multi-symptom input. Background Art

[0002] The prescription of traditional Chinese medicine herbs is the core link of traditional Chinese medicine diagnosis and treatment activities. Doctors need to formulate personalized herb compatibility plans based on the symptom combinations (syndromes) of patients. With the advancement of electronic medical record systems and the digitization of traditional Chinese medicine classics, it has become a research hotspot to build traditional Chinese medicine herb recommendation models using large-scale prescription data and traditional Chinese medicine knowledge resources.

[0003] In the prior art, early methods mostly adopted traditional machine learning methods such as collaborative filtering, matrix factorization, and association rule mining to model the co-occurrence relationship between symptoms and herbs. However, in real scenarios, there are serious data sparsity and long-tail problems in prescription data. A large number of rare symptoms and low-frequency herb combinations make it difficult for the above methods to learn stable statistical laws, and the recommendation effect is limited. In recent years, graph neural networks have been introduced into the field of traditional Chinese medicine herb recommendation due to their advantages in processing relational data, such as performing graph convolution or attention calculation on the symptom-herb bipartite graph, so as to utilize graph structure information to a certain extent. However, such methods often only utilize a single type of edge and a small number of entity types, and fail to fully integrate multi-source heterogeneous knowledge such as traditional Chinese medicine efficacy, syndromes, and meridians, and have limited ability to describe complex compatibility principles such as "monarch, minister, assistant, and guide".

[0004] At the same time, retrieval enhanced generation technology enhances the ability of large language models in knowledge-intensive tasks by performing vector retrieval on large-scale text libraries, and has achieved remarkable progress in fields such as general question answering. However, traditional retrieval enhanced generation uses unstructured text paragraphs as the basic retrieval unit, ignores the explicit topological structure between knowledge entities, is easy to introduce noise paragraphs unrelated to the core pathology, and lacks structured and traceable recommendation basis. In the professional medical field, existing large language models also have an obvious "hallucination" problem, that is, generating herbs or compatibility plans that do not exist in the knowledge base, lacking a reliable constraint mechanism, and having potential clinical safety risks.

[0005] Therefore, a new technical solution is needed: using multi-hop structured evidence subgraphs in the traditional Chinese medicine knowledge graph as the basic unit of retrieval and reasoning, discovering pathological patterns deeply related to symptoms through an associative structured evidence subgraph retrieval mechanism, and adopting a cross-modal alignment method to fuse graph structure knowledge and symptom text semantics, effectively reducing hallucinations while significantly improving recommendation accuracy and outputting interpretable structured evidence to meet the requirements of reliability and interpretability in traditional Chinese medicine clinical practice. Summary of the Invention

[0006] The main objective of this invention is to overcome the shortcomings of existing TCM herbal medicine recommendation methods, such as data sparsity, insufficient utilization of structured knowledge, high risk of model illusion, and poor interpretability of recommendation results. This invention proposes a TCM herbal medicine recommendation method and system based on enhanced generation of structured evidence subgraph retrieval. By introducing multi-hop structured evidence subgraphs as a subgraph vector retrieval engine, using a modern Hopfield network for associative subgraph retrieval, encoding structured evidence subgraphs using graph neural networks, and employing a contrastive learning-driven cross-modal projection alignment mechanism, this invention achieves deep utilization of the TCM knowledge graph, improving the accuracy, reliability, and interpretability of TCM herbal medicine recommendations, and possesses good engineering deployability. It is particularly suitable for multi-label herbal medicine recommendation scenarios with single or multiple symptom inputs.

[0007] To achieve the above objectives, the technical solution provided by this invention is summarized as follows, and corresponds one-to-one with each step in the claims: In terms of constructing a knowledge graph of Traditional Chinese Medicine (TCM) and deriving structured evidence subgraphs, this invention extracts entities such as symptoms, herbs, syndromes, efficacy, and prescriptions, along with their multi-hop relationships, from TCM databases and literature resources to construct the TCM knowledge graph. For each entity node, a multi-hop neighborhood is extracted within a preset number of hops (preferably 1 to 2 hops) to form a neighborhood containing a central node and a node set. Sum of edges Structured evidence subgraph The data is stored in JSON or an equivalent structured format. This step ensures that the local topological structure in the knowledge graph is explicitly modeled as a multi-hop structured evidence subgraph, providing a foundation for subsequent subgraph-level retrieval and encoding.

[0008] Furthermore, regarding the structured evidence subgraph serialization and subgraph vector retrieval engine construction, this invention serializes each structured evidence subgraph into descriptive text according to a fixed template of "center node; source node-relationship-target node...". A pre-trained sentence vector encoding model is used to vectorize the descriptive text and perform L2 normalization. Based on the resulting structured evidence subgraph embedding, the subgraph vector retrieval engine (preferably an inner product similarity indexFlatIP) is constructed as the vectorized storage unit for the structured subgraph retrieval. Compared to directly encoding the entire graph or unstructured text, this scheme uses the structured evidence subgraph as the retrieval granularity, balancing the integrity of structural information with the controllability of the index size.

[0009] Furthermore, in terms of symptom synonym matching and entity mapping, this invention adopts a strategy combining "rules + semantics": First, a TCM symptom synonym dictionary containing no less than 12,000 symptom synonym entries is constructed, and precise matching is performed on the input symptom text; if no match is found, a BERT-like Chinese model pre-trained in the medical field is used to encode the symptom text and each of the entity synonym sets respectively, and entity semantic representation is constructed by aggregating the synonym embeddings, and the maximum similarity and a preset threshold are used to determine the entity semantic representation. Determine whether to establish a mapping to achieve a robust mapping from the symptom text to the standard entities in the knowledge graph. This step effectively mitigates entity alignment failures caused by colloquial descriptions, synonyms, and typos.

[0010] Furthermore, regarding the structured evidence subgraph retrieval in the associative memory network module, this invention utilizes a domain-pre-trained language model to encode the symptom text to obtain the symptom embedding, which is then used as the input state vector of the associative memory network module. The associative memory network module employs a modern Hopfield network, using all pre-constructed multi-hop structured evidence subgraph embedding matrices as a storage mode. In the structured evidence subgraph embedding space, one or more associative updates are performed according to the Hopfield network update rules to obtain a stable query vector. Only based on this query vector, Top-level queries are retrieved in the subgraph vector retrieval engine. K Candidate structured evidence subgraphs are generated. These subgraphs are then reordered based on features such as graph distance to the target entity, node popularity, relation type, and semantic similarity, with the Top-ranked subgraphs selected. N Structured evidence subgraphs. This step extends traditional similarity retrieval to energy-minimization-based associative retrieval, which is more conducive to recovering subgraphs related to true pathological patterns under noisy symptom descriptions.

[0011] Furthermore, regarding the structured evidence subgraph merging and graph neural network encoding, the present invention, for each symptom sample, assigns its corresponding Top- N The nodes and edges of the structured evidence subgraph are uniformly renumbered and merged into a single graph data object. Each node is assigned a node name embedding encoded by the sentence vector model or the SentenceTransformer model as a node feature. A graph neural network (preferably a two-layer GraphSAGE) is used to perform multi-layer message passing and readout operations on the graph data to obtain the graph-level structured evidence subgraph embedding vector of the sample. By uniformly encoding multiple structured evidence subgraphs, multiple evidence paths can be comprehensively utilized in a unified graph representation.

[0012] Furthermore, in terms of cross-modal projection alignment and knowledge fusion, this invention embeds the graph-level structured evidence subgraph into an input projection network (multilayer perceptron), maps it to a semantic space of the same dimension as the symptom embedding, obtains the projected knowledge vector, and trains the symptom embedding and the corresponding projected knowledge vector using a graph self-supervised contrastive learning loss based on InfoNCE. The projected knowledge vectors of other samples within the same mini-batch are used as negative samples to achieve cross-modal alignment between graph structure representation and text semantic representation. Simultaneously, for the Top- N The projected knowledge vectors of the structured evidence subgraphs are aggregated using an attention mechanism to obtain a unified knowledge representation. Then, the symptom embeddings are fused with this unified knowledge representation using cross-attention or other fusion networks to obtain a fused representation. This step explicitly constrains the alignment relationship between symptoms and their corresponding structured evidence subgraphs in a shared semantic space, providing a unified representational basis for subsequent multi-label prediction.

[0013] Furthermore, in terms of multi-label prediction and result output for herbal medicines, this invention concatenates or nonlinearly transforms the fused representation with the symptom embedding and inputs it into a multi-label classifier (output dimension is the total number of candidate herbs). The predicted probability of each herb is obtained through a Sigmoid function, and then calculated based on a preset threshold and / or Top-... K The strategy generates recommendations for traditional Chinese medicine herbs and outputs a structured evidence subgraph and its attention weights involved in the decision-making process, visualizing the recommendation basis. Combined with a filtering mechanism based on a knowledge graph entity set, it can effectively eliminate illegal herbs not in the knowledge graph and control illusory output.

[0014] Furthermore, regarding joint training and optimization, this invention uses real prescription herbal medicine labels as supervision signals and employs a multi-label loss function (preferably binary cross-entropy loss) to optimize the multi-label classifier. Simultaneously, it introduces cross-modal alignment loss and the graph self-supervised contrastive loss to jointly train the projection network and the graph neural network. The invention also employs efficient parameter fine-tuning and low-bit quantization strategies for the domain-pre-trained language model to reduce storage and computational overhead. In addition, this invention introduces the structured evidence subgraph selective retrieval strategy, which utilizes the prevalence of symptom samples and prediction uncertainty to control the associative retrieval budget, reducing the overall computational cost of the system without significantly sacrificing recommendation performance.

[0015] Furthermore, in terms of illusion rate control and evaluation, this invention performs constraint filtering on the herb set output by the multi-label classifier based on the knowledge graph during the inference stage, retaining only herb entities belonging to the entity set; and defines and monitors the illusion rate index during the verification and testing stage, adding a penalty term related to the illusion rate to the training loss when necessary, further restricting the model's tendency to make recommendations outside the knowledge graph, and improving the consistency and interpretability of the recommendation results.

[0016] Compared with the prior art, the beneficial effects of the present invention are as follows: Differences and effects in retrieval units and knowledge utilization methods: Traditional retrieval enhancement generation methods typically use unstructured text paragraphs as retrieval units, ignoring explicit topological structures between entities and easily introducing noise information unrelated to the core pathology. This invention utilizes the multi-hop structured evidence subgraph in the aforementioned TCM knowledge graph. As the basic unit for retrieval and reasoning, this invention explicitly preserves multiple entity categories and their multi-hop relationships, such as "symptoms-herbs-syndromes-efficacy-prescriptions," making the retrieval results more closely aligned with the pathological patterns of Traditional Chinese Medicine (TCM). Experimental results show that, on the same dataset, compared with retrieval enhancement generation based solely on text paragraphs, this invention significantly improves accuracy (P@5), F1@10, recall (R@10), and hallucination rate (Halluc@5), while also providing clear, structured evidence paths.

[0017] Differences and effects in retrieval mechanisms: Existing knowledge graph-based recommendation methods mostly employ static similarity retrieval or rely solely on graph convolutional propagation. This invention introduces the associative memory network module of the modern Hopfield network, embedding all the structured evidence subgraphs as a storage mode. The symptoms are embedded in the structured evidence subgraph embedding space for energy-minimizing associative updates, generating a stable query vector, which is then used to retrieve the Top-... K Candidate structured evidence subgraphs. Compared to simple nearest neighbor retrieval, associative retrieval can still recover structured evidence subgraphs highly correlated with potential pathological patterns even when symptom descriptions are incomplete or noisy, improving retrieval recall quality and recommendation robustness.

[0018] Differences and effects in cross-modal alignment and knowledge fusion: Traditional methods often use simple concatenation or weighted summation to fuse graph structure representations with text representations, lacking explicit alignment constraints and easily causing semantic space inconsistencies. This invention maps the graph-level structured evidence subgraph embeddings to a semantic space of the same dimension as the symptom embeddings through the projection network. It employs a contrastive learning loss in the form of InfoNCE, using the structured evidence subgraph representations of other samples within a batch as negative samples to explicitly align the symptom-structured evidence subgraph representations across modalities. Furthermore, it achieves deep fusion through the attention mechanism and cross-attention, thereby fully leveraging the complementarity of graph structure knowledge and text semantic knowledge within the unified representation space.

[0019] The differences and effects of selective retrieval and efficiency control: Existing retrieval enhancement generation or GraphRAG schemes often perform the same retrieval operation on all samples, resulting in redundant retrieval on high-frequency and simple samples. This invention proposes a selective retrieval strategy for the structured evidence subgraph based on the prevalence of the symptom samples and prediction uncertainty, reducing the retrieval frequency or decreasing the Top-level search for high-frequency symptom samples with stable historical performance and low prediction uncertainty. K For long-tail samples with a small number of samples and / or high prediction uncertainty, appropriately increase retrieval resources to effectively reduce average retrieval overhead and system latency while ensuring overall performance.

[0020] Differences and effects on illusion rate control and interpretability: Large language models are prone to "illusion" problems when directly generating herbal lists, i.e., generating herbs that are not within the knowledge graph or clinically commonly used range. This invention effectively suppresses illegal herbal output by using the filtering mechanism of the knowledge graph entity set and incorporating illusion rate indicators and penalty terms during the training and validation phases; at the same time, the structured evidence subgraph and attention weights corresponding to each recommendation output enable clinicians to comprehensively review the recommendation basis based on paths such as "symptom-herb-syndrome-efficacy-prescription", significantly improving the interpretability and clinical usability of the system.

[0021] Differences and effects in terms of engineering deployability: Unlike solutions that rely on large-scale general-purpose language models, this invention uses the domain-specific pre-trained language model combined with LoRA parameter efficient fine-tuning and low-bit quantization strategies to train only the graph neural network, the projection network, and the multi-label classifier, significantly reducing the requirements for GPU memory and computing power. This allows training and deployment to be completed in a multi-GPU consumer-grade environment (such as 1 to 8 RTX 4090 cards), providing better engineering deployment capabilities.

[0022] In summary, the present invention, through its overall technical solution of structured evidence subgraph retrieval, Hopfield associative memory network, graph neural network encoding, projection cross-modal alignment, subgraph vector retrieval engine retrieval, and hallucination rate control, has achieved substantial beneficial effects compared with existing technologies in the multi-label recommendation task of traditional Chinese medicine herbs with single or multiple symptom inputs, and has made significant technological progress. Attached Figure Description

[0023] To more clearly illustrate the technical solution of the present invention, the present invention will be further described below with reference to the accompanying drawings, wherein: Figure 1 This is a flowchart illustrating the method for recommending traditional Chinese medicine herbs based on structured evidence subgraph retrieval enhancement in an embodiment of the present invention. Figure 2 This is a schematic diagram of the overall structure of the TCM herbal medicine recommendation system based on structured evidence subgraph retrieval enhancement in an embodiment of the present invention; Figure 3 This is a performance comparison table of the Hop-RAG model and the baseline model on the TCM_PD dataset in this embodiment of the invention; Figure 4 This is a performance comparison table of the Hop-RAG model and the baseline model on the TCM_SMGCN dataset in this embodiment of the invention; Figure 5 This is a schematic diagram illustrating the interpretability of the recommendation results and structured evidence subgraphs for specific symptom input in this embodiment of the invention.

[0024] Hop-RAG is the model name of the traditional Chinese medicine herbal medicine recommendation method based on structured evidence subgraph retrieval enhancement in this invention. Detailed Implementation

[0025] The following is in conjunction with the appendix Figures 1 to 5 The following detailed description of specific embodiments of the present invention is provided. It should be understood that the following embodiments are for illustrative purposes only and are not intended to limit the scope of protection of the present invention. Without departing from the spirit and substance of the present invention, those skilled in the art can make various equivalent modifications and substitutions to the following embodiments, and all such equivalent modifications and substitutions should fall within the scope of protection of the present invention.

[0026] It should be noted that although functional modules are divided in the method and system diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than the module division in the method and system diagram or the order in the flowchart.

[0027] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein is for the purpose of describing embodiments of the invention only and is not intended to limit the invention.

[0028] Embodiment 1 of the present invention: A method for recommending single-symptom or multi-symptom multi-label herbal medicines for publicly available prescription datasets. This embodiment provides a specific way to implement the method of the present invention on a publicly available TCM prescription dataset, corresponding to the technical solutions described in claims 1 to 8. Figure 1 , Figure 2 As shown.

[0029] In this embodiment, the knowledge graph construction corresponds to the structured evidence subgraph derivation. Figure 1 Step S001 in the process, Figure 2 Module B1 in the middle.

[0030] On the server side, samples containing one or more symptom texts and multiple herbal prescription labels were selected from publicly available TCM prescription datasets. The training set, validation set, and test set were split in an 8:1:1 ratio, with a total of approximately 30,000 samples. Entities and their relational triples, including symptoms, herbs, syndromes, efficacy, and prescriptions, were extracted from databases such as TCMBank and TCM-MKG to construct a TCM knowledge graph. G B1001 contains approximately 30,000 entities and approximately 200,000 relation triples. The TCM knowledge graph B1001 is stored in an adjacency list format, and each entity is assigned a unique identifier.

[0031] For each entity node in the TCM knowledge graph B1001 v Obtain the nodes and edges within its 1-2 hop neighborhood to form a structured evidence subgraph. B1002. In this embodiment, a 1-2 hop neighborhood is preferred, such that the number of nodes in each structured evidence subgraph B1002 is controlled between 30 and 80.

[0032] Each of the structured evidence subgraphs B1002 is encapsulated as a structured object containing a central node, a list of nodes, and a list of edges, and converted into a descriptive text string according to a fixed template of "central node; source node-relationship-target node...", with an average length of approximately 128 to 256 Chinese characters.

[0033] In this embodiment, symptom synonym matching corresponds to entity mapping. Figure 1 Step S002 in the process, Figure 2 Module B2 in the middle.

[0034] Symptom text for patients to be recommended sB2001 first performs text cleaning and lexical segmentation to remove noise such as punctuation and repeated spaces. A TCM symptom thesaurus containing no less than 12,000 symptom synonym entries is pre-constructed, with the key being the standard symptom entity and the value being several synonym phrases.

[0035] In this embodiment, the domain-pretrained language model B2003 is used to encode the symptom text B2001 to obtain the symptom embedding. B2004 is compressed to 384 dimensions through linear mapping, consistent with the dimension of the subgraph vector. The synonym set of each entity is encoded to obtain the entity representation; the cosine similarity between the symptom embedding and each entity representation is calculated. When the maximum similarity is not less than 0.75, the corresponding entity is considered the target entity; otherwise, the entity mapping B2002 is not performed. Upon successful mapping, the 1-2 hops of the structured evidence subgraph related to that entity are marked as candidate evidence sources. For inputs containing multiple symptom texts B2001, the symptom descriptions can be concatenated according to predetermined delimiters (e.g., commas, pauses, or spaces) to form a continuous symptom text string, which is then used as input for subsequent steps. The subsequent processing flow of this invention does not require structural adjustments for multiple symptom combinations.

[0036] In this embodiment, the structured evidence subgraph serialization corresponds to the construction of the subgraph vector retrieval engine. Figure 1 Step S005 in the process, Figure 2 Module B3 in the middle.

[0037] The pre-trained sentence vector encoding model B3002 was used to encode all the structured evidence subgraphs B1002 text, with a vector dimension of 384; the embedding of the structured evidence subgraphs was L2 normalized.

[0038] A subgraph vector retrieval engine, B3003, was constructed using the FAISS inner product similarity index IndexFlatIP. The number of index entries is the same as that of the structured evidence subgraph B1002 (approximately 30,000). Since the vectors are normalized, the inner product calculation is equivalent to cosine similarity. This index is stored in GPU memory for fast online retrieval.

[0039] In this embodiment, the associative memory network corresponds to the structured evidence subgraph retrieval. Figure 1 Step S004 in the process, Figure 2 Module B4 in the middle.

[0040] All the structured evidence subgraphs are embedded and stacked column-wise to form a storage matrix. ,in M The number of structured evidence subgraphs.

[0041] Set temperature parameters for Hopfield network B4001 The number of iterations is 1 to 2, according to the formula:

[0042] Calculate the query vector after association B4002, and using Retrieving Top- in the FAISS subgraph vector retrieval engine B3003 K Candidate structured evidence subgraph B4003. In this embodiment... K The value is 10.

[0043] Subsequently, based on the graph theory distance (shortest path length from the central node to the target entity) between the candidate structured evidence subgraph B4003 and the target entity, the node popularity (frequency of the node in the prescription dataset), the relation type weight, and the relationship with the target entity, the following factors are considered: The cosine similarity of B4002 is used to construct a weighted score for the Top- K The structured evidence subgraph B4003 is reordered, and the Top-ranked subgraphs are selected from it. N Structured evidence subgraph B4004, in this embodiment N The preferred value is 5.

[0044] In this embodiment, the merging of structured evidence subgraphs corresponds to graph neural network encoding. Figure 1 Step S005 in the process, Figure 2 Module B5 in the middle.

[0045] For each symptom sample B2004, its Top- N The nodes and edges of the structured evidence subgraph B4004 are merged and uniformly renumbered to construct a single graph data object B5001. After merging, each of the structured evidence subgraphs has approximately 80–150 nodes and approximately 160–300 edges.

[0046] The SentenceTransformer model is used to encode the names of each node, resulting in 384-dimensional node features, which are then used to form a node feature matrix. .

[0047] In this embodiment, a two-layer GraphSAGE network is used as the graph neural network encoder B5002, with a hidden layer dimension of 256, an average pooling function, and a ReLU nonlinear activation function. After obtaining the higher-order representation of the nodes through two layers of message passing, a combination of global average pooling and attention pooling is used to read out the node representations, resulting in a graph-level structured evidence subgraph embedding. B5003.

[0048] During the self-supervised pre-training phase, two random perturbation views (including randomly deleting some edges, randomly discarding some node features, and adding a small amount of noisy edges) are generated for each of the structured evidence subgraphs, and are respectively encoded by the graph neural network. Comparative loss is used:

[0049] Pre-training is performed, including temperature parameters. Set the value to 0.2. The pre-training rounds are 20.

[0050] In this embodiment, cross-modal projection alignment corresponds to knowledge fusion. Figure 1 Step S006 in the process, Figure 2 Module B6 in the middle.

[0051] Embed the graph-level structured evidence subgraph The B5003 input consists of a projection network composed of two fully connected layers. B6001, with a first-layer output dimension of 256 and a second-layer output dimension of 384, uses ReLU activation. B5003 is mapped to the same 384-dimensional semantic space B6002 as the symptom embedding B2004, resulting in a projected knowledge vector. B6002.

[0052] The graph self-supervised contrastive learning loss B6003 based on InfoNCE is used for each symptom sample. i B2004, will As positive sample pairs B2004 and B6002, the projection vectors of other samples in the same batch are used. As a negative sample B6004, the following is defined:

[0053] in , Let be the cosine similarity.

[0054] In this embodiment, the Top- N The projected knowledge vector B6002 corresponding to the structured evidence subgraph B4004 is aggregated using an attention mechanism (B6005), with attention weights based on... With each Adaptive similarity calculation yields a unified knowledge representation. B6005.

[0055] Embedded with the symptoms B2004 is the query term, referring to the unified knowledge representation. B6005 serves as the key and value, and a fused representation is obtained through the multi-head cross-attention mechanism B6006. B6007.

[0056] In this embodiment, the herbal multi-label recommendation corresponds to... Figure 1 Step S007 in the process, Figure 2 Module B7 in the middle.

[0057] Embed the symptoms B2004 and the aforementioned fusion representation After concatenation with B6007, the data is input into a multi-label classification network B7001. The output dimension is equal to the size of the entire herb set (e.g., 200 herbs). The predicted probability for each herb is obtained after passing through a sigmoid function. Following the Top-... N The strategy outputs a recommendation result of B7002 for traditional Chinese medicine herbs, and retains the Top- N The structured evidence subgraph and its attention weight B7003 are used for visualization.

[0058] In this embodiment, model training and evaluation are performed. During the training phase, multi-label binary cross-entropy loss is used as the task loss, combined with the cross-modal alignment loss. And the graph self-supervised comparison loss The total loss is:

[0059] in , .

[0060] In this embodiment, the LoRA low-rank adaptation method is used to fine-tune only some Transformer layers of the pre-trained language model in the domain. r = 8, using 8-bit quantization to reduce memory overhead. Training uses 8 RTX 4090 cards, employing distributed data parallelism and mixed precision training, with a batch size of 16 per card and a total batch size of 128.

[0061] In this embodiment, during the inference phase, the candidate herb set output by the classifier is processed based on the knowledge graph entity set. V Filtering, retaining only V Herbal entities present in the test set; hallucination rate is statistically analyzed in the test set.

[0062] Embodiment 2 of the present invention: A Traditional Chinese Medicine Herbal Recommendation System Based on Structured Subgraph Retrieval Enhancement This embodiment provides a specific system deployment method based on the model parameters obtained from the training in Embodiment 1, corresponding to the system scheme described in claim 9.

[0063] In this embodiment, the system hardware and software environment are as follows: The system is deployed on a server with the following configuration: dual CPUs, 256 GB of memory, 8 RTX 4090 GPUs, each with 24 GB of video memory, a 64-bit Linux operating system, PyTorch as the deep learning framework, and FAISS GPU version as the search library.

[0064] In this embodiment, the system module division and communication relationships correspond to... Figure 1 and Figure 2 The system includes: a knowledge graph construction module B1, a structured subgraph export and indexing module B1002, a synonym matching and entity mapping module B2, an associative memory network module B4001, a graph neural network encoding module B5, a projection alignment module B6, a knowledge fusion module B6006, and a recommendation module B7, etc., and the functions of each module are consistent with those described in claim 9. The modules communicate with each other via RPC or message queues to ensure stability under high concurrency.

[0065] In this embodiment, the online inference process is as follows: The doctor inputs a description of the patient's main symptoms on the front-end interface. The symptom text B2001 is passed to the synonym matching and entity mapping module B2 via API, and the same synonym matching and mapping strategy as in Embodiment 1 is executed.

[0066] Subsequently, the Hopfield structured subgraph retrieval module B4003 is invoked, and the structured evidence subgraph B4004 is obtained using the parameter configuration in Embodiment 1 (K=10, N=5, etc.); the graph encoding module B5 calls the pre-loaded GraphSAGE network to encode the evidence subgraph B5002; the projection alignment module B6001, the knowledge fusion module B6007, and the recommendation module B7 generate the final herbal medicine recommendation result B7002 and the structured evidence subgraph B7003 according to the corresponding steps in Embodiment 1.

[0067] In actual deployment, the system supports more than 50 concurrent requests, and the average end-to-end response time for each request is controlled within 500ms.

[0068] Embodiment 3 of the present invention: Comparison of the effects of structured evidence subgraph retrieval and hallucination rate control This embodiment, based on Embodiment 1, primarily verifies the specific effectiveness of the structured evidence subgraph retrieval strategy and the hallucination rate control mechanism based on knowledge graph constraints. Figure 3 and Figure 4 This further illustrates the technical effects of the technical features of the present invention.

[0069] In this embodiment, to verify the performance of the method of the present invention on different datasets, two representative TCM prescription datasets, TCM_PD and TCM_SMGCN, are selected and compared with various existing baseline models, including HCKGETM, SMGCN, KDHR, SMRGAT, PresRecST, BSGAM, TCM-IPRW, and TCM-KLLaMA. Evaluation metrics include accuracy P@K, F1@K, recall R@K, and hallucination rate Halluc@5 (the proportion of herbs in the recommendation list that are not in the knowledge graph entity set). The relative improvement rate is calculated as (the higher the value, the better) / (baseline model score × 100%) for metrics where "higher is better," and as (baseline model score - present invention model score) / (baseline model score × 100%) for the hallucination rate.

[0070] In this embodiment, the model name of the traditional Chinese medicine herbal medicine recommendation method based on structured evidence subgraph retrieval enhancement is Hop-RAG.

[0071] In this embodiment, Figure 3 Experimental results on the TCM_PD dataset. It should be noted that the R@10=0.630 value reported by PresRecST in the original TCM-IPRW paper is significantly inconsistent with the magnitudes of other metrics, which is highly likely due to formatting or data entry errors in the original paper. However, this invention still uses the original data in this embodiment, and it does not affect the comparison conclusions. The results from the TCM_PD dataset show that: On the P@5 metric, the Hop-RAG of this invention achieves 0.333 on the TCM_PD dataset, which is better than the best baseline TCM-IPRW's 0.314, representing a relative improvement of approximately 6.05%.

[0072] On the F1@5 metric, Hop-RAG achieved 0.282, a relative improvement of approximately 12.35% compared to the strong GNN baseline BSGAM's 0.251. This indicates that the combination of structured subgraph retrieval and cross-modal alignment has a significant advantage in Top-5 recommendation quality.

[0073] On recall metrics R@5, R@10, and R@20, Hop-RAG significantly outperformed other baselines on R@10 and R@20, especially with R@20 reaching 0.537, a significant improvement over BSGAM's 0.477, indicating that the invention also has strong coverage on longer recommendation lists.

[0074] On the Halluc@5 metric, Hop-RAG's hallucination rate was 0.667, which is an absolute decrease of 0.019 (approximately 1.9 percentage points) and a relative decrease of approximately 2.77% compared to TCM-IPRW's 0.686. This verifies the effectiveness of the knowledge graph-based retrieval enhancement generation framework in mitigating hallucinations.

[0075] For certain metrics such as P@10 (e.g., P@10 on TCM_PD), TCM-IPRW is slightly better than Hop-RAG. This indicates that at some ranking positions, different models still have differences in their retrieval and re-ranking tradeoff strategies, further demonstrating the emphasis of this invention on Top-5 accuracy and illusion control.

[0076] In this embodiment, Figure 4 Experimental results on the TCM_SMGCN dataset. The results from the TCM_SMGCN dataset show that: On the P@5 metric, Hop-RAG achieved a score of 0.280, which is approximately 2.94% and 11.55% higher than the best baselines TCM-IPRW (0.272) and PresRecST (0.251), respectively. This further demonstrates that the advantages of this invention in Top-5 recommendation quality are consistent across datasets.

[0077] In terms of fusion precision and recall metrics such as F1@10 and F1@20, Hop-RAG significantly outperforms traditional GNNs and graph recommendation baselines. For example, F1@10 is improved from 0.224 in TCM-IPRW to 0.264, and F1@20 is improved from 0.204 to 0.243, indicating that the present invention has a better balance in the overall quality of the recommendation list.

[0078] On recall metrics R@10 and R@20, Hop-RAG achieved scores of 0.324 and 0.473, respectively, which are significantly higher than TCM-IPRW (0.217 and 0.198). This indicates that the present invention effectively improves the coverage of real herbal labels through multi-hop structured evidence subgraph retrieval and associative memory network module.

[0079] On the Halluc@5 metric for hallucination rate, Hop-RAG has a hallucination rate of 0.720, slightly lower than TCM-IPRW's 0.728, a relative decrease of about 1.10%, but still demonstrates the generalization ability of the knowledge graph-based hallucination control mechanism on different datasets.

[0080] The quantitative results from the two datasets above show that the present invention outperforms mainstream baseline models in multiple evaluation metrics, especially in Top-5 accuracy, overall F1 score, and illusion rate control. This quantitatively verifies the effectiveness of the structured evidence subgraph retrieval, cross-modal semantic alignment, and retrieval and illusion rate control strategies described in the present invention.

[0081] In addition, such as Figure 5 As shown, in a scenario where typical cold-like symptoms such as headache, chills, and nasal congestion are input into G100, the recommendation module G200 of this invention can map the recommendation result G300 to specific structured evidence subgraphs G500 one-to-one. Through the multi-hop paths G600, G700, and G800 (symptom → efficacy → herbal medicine), symptoms G100 such as headache G6001 and chills G7001 are associated with TCM efficacy nodes such as relieving muscle tension and releasing exterior pathogens G6002, inducing sweating and relieving exterior pathogens G7002, and warming and unblocking meridians G8002, respectively. These nodes further point to herbal medicine nodes such as kudzu root G6003, ephedra G7003, and cinnamon twig G8003. The relative contribution of each evidence subgraph to the final decision is explicitly given through attention weights G400. This visualization process not only intuitively demonstrates the mechanism by which this invention uses structured evidence from knowledge graphs to support generative recommendation decisions, but also provides transparent and traceable evidence for clinicians to review the rationality of the system's recommendations, thereby further enhancing the credibility and interpretability of the model in real-world applications.

[0082] This embodiment further demonstrates that the structured evidence subgraph retrieval, cross-modal alignment, retrieval strategy, and illusion rate control mechanism based on knowledge graph constraints described in claims 1 to 8 of this invention have a good synergistic effect, and can simultaneously take into account performance, efficiency, and credibility in actual TCM herbal medicine recommendation scenarios.

Claims

1. A method for retrieving enhanced generated Chinese herbal medicine recommendation based on structured evidence sub-graphs, characterized in that, Comprise the following steps: S001 Traditional Chinese medicine knowledge graph construction and structured subgraph evidence derivation step: extracting symptoms, herbal medicines, syndromes, functions, prescriptions and other entities and their multi-hop relationships from traditional Chinese medicine databases and literature resources to construct a traditional Chinese medicine knowledge graph; For each entity node, extract the multi-hop neighborhood within the preset number of hops to form a structured evidence subgraph containing a center node, a node set, and an edge set, and store it in a structured format; S002 Structured evidence subgraph serialization and subgraph vector retrieval engine construction step: serialize each structured evidence subgraph into a descriptive text according to the "center node; source node-relation-target node..." template, vectorize the text using a pre-trained sentence vector encoding model and L2 normalization, and construct the subgraph vector retrieval engine based on the obtained structured evidence subgraph embedding as the vectorized storage unit for structured evidence subgraph retrieval; S003 Symptom synonym matching and entity mapping step: For the input natural language symptom text, first use the traditional Chinese medicine field symptom synonym dictionary for exact matching, and when no match is found, use the field pre-trained language model to encode the synonym set of the symptom text and each entity in the knowledge graph, respectively, calculate the similarity and determine the target entity corresponding to the symptom under the threshold constraint, to realize robust mapping of the symptom text to the standard entity of the knowledge graph; S004 The associative memory network module and structured evidence subgraph retrieval step: using the field pre-training language model to encode the symptom text to obtain symptom embedding, taking the symptom embedding as the input state vector of the associative memory network module, taking the pre-constructed multi-hop structured evidence subgraph embedding matrix as the storage mode, updating once or more times in the structured subgraph embedding space according to the associative memory network module update rule to obtain a stable query vector, and only based on the query vector, retrieving Top- K candidate structured evidence subgraphs, reordering the candidate structured evidence subgraphs according to the graph theory distance, node popularity, relationship type and semantic similarity of the target entity, and selecting Top- N structured evidence subgraphs; S005 Structured evidence subgraph merging and graph neural network encoding step: For each symptom sample, renumber and merge the nodes and edges of its corresponding Top-N structured evidence subgraphs to construct a single graph data object, assign node name embeddings based on the sentence vector encoding model to each node as node features, and use a graph neural network to perform multi-layer message passing and readout operations on the graph data. Obtain the graph-level structured evidence subgraph embedding vector of the sample; S006 Cross-modal projection alignment and knowledge fusion step: embedding the graph-level structured evidence subgraph into an input projection network, mapping it to a semantic space of the same dimension as the symptom embedding, obtaining the projected knowledge vector, training the symptom embedding and the corresponding projected knowledge vector through graph self-supervised contrastive learning loss, taking the projected knowledge vector of other samples as negative samples, realizing cross-modal alignment of graph structure representation and text semantic representation, and obtaining Top- N The projected knowledge vector of the structured evidence subgraph is aggregated by an attention mechanism to obtain a unified knowledge representation, and the symptom embedding and the unified knowledge representation are fused through cross-attention or other fusion networks to obtain a fusion representation. S007 Herbal multi-label prediction and result output step: concatenate or nonlinearly transform the fusion representation and the symptom embedding, then input them into a multi-label classification network, output the prediction scores of each candidate herbal label, generate traditional Chinese herbal medicine recommendation results according to the preset threshold and / or Top-K strategy, and output the structured evidence subgraph involved in decision-making and its attention weight; Joint training and optimization step: Use the herbal label in the real prescription as a supervision signal, use a multi-label loss function to optimize the multi-label classification network, simultaneously introduce the cross-modal alignment loss and the graph self-supervised contrast loss to jointly train the projection network and the graph neural network, and use parameter-efficient fine-tuning and / or low-bit quantization strategy for the field pre-trained language model to reduce storage and calculation overhead.

2. The method of claim 1, wherein, In the symptom synonym matching and entity mapping step: The traditional Chinese medicine field symptom synonym dictionary contains no less than 12,000 symptom synonym entries, and each entity corresponds to several synonymous phrases; The domain pre-training language model is a BERT type Chinese model pre-trained in the medical field. After encoding the symptom text and each entity synonym set respectively, the semantic representation of the entity is obtained by aggregating the synonym embedding; When the maximum similarity between the symptom text and a certain entity synonym set is not less than a preset threshold, the entity is determined as the target entity, otherwise the entity mapping is not performed, thereby balancing the precision and recall of synonym matching.

3. The method of claim 1, wherein, In the structured evidence subgraph serialization and subgraph vector retrieval engine construction step: For each structured evidence subgraph, a subgraph text string is formed according to the "center node; source node-relation-target node..." template to explicitly encode the subgraph topology; A multi-language pre-training sentence vector encoding model or an equivalent sentence vector model is used to encode the pre-training subgraph text string, and L2 normalization is performed on the obtained vector; The subgraph vector retrieval engine uses an inner product similarity index structure to retrieve the normalized structured evidence subgraph vector, so that the inner product calculation is equivalent to the cosine similarity calculation; The structured evidence subgraph retrieval is performed for the Top- K number of candidate structured evidence subgraphs K is a configurable positive integer, preferably greater than or equal to 10, the Top- N number of structured evidence subgraphs N is preferably 5.

4. The method of claim 1, wherein, In the structured evidence subgraph retrieval step of the associative memory network module: The associative memory network module uses a modern Hopfield network structure; all structured evidence subgraph embedding vectors are stacked by column to form a storage matrix; Given the symptom embedding vector, the modern Hopfield network energy minimization update rule is used to update the input state once or multiple times; The updated query vector is used as a retrieval vector to perform approximate nearest neighbor retrieval in the subgraph vector retrieval engine to obtain a candidate structured evidence subgraph set more consistent with the potential pathological pattern, thereby improving the robustness and recall quality of the structured evidence subgraph retrieval.

5. The method of claim 1, wherein, In the structured evidence subgraph merging and graph neural network encoding step: The graph neural network is a two-layer GraphSAGE network or its equivalent variant, and the first layer and the second layer respectively perform adjacency aggregation and nonlinear transformation to output node high-order representation; The SentenceTransformer model or an encoder compatible with the sentence vector encoding model is used to encode the subgraph node name to form the node feature matrix; The node representation is read out by global average pooling, attention pooling, or a combination of the two to obtain the graph-level structured evidence subgraph embedding; Before formal training, the graph neural network uses the graph-level contrastive self-supervised pre-training strategy to construct two random perturbation views for each structured evidence subgraph, maximize the similarity between different view embeddings of the same structured evidence subgraph, and minimize the similarity between view embeddings of different structured evidence subgraphs, to improve the generalization ability of the graph neural network on sparse prescription data.

6. The method of claim 1, wherein, In the cross-modal projection alignment and knowledge fusion step: The projection network is a multi-layer perceptron including at least one linear transformation and nonlinear activation, which maps the graph-level structured evidence subgraph embedding vector to a vector with the same dimension as the symptom embedding. The graph self-supervised contrastive learning alignment loss adopts an InfoNCE form, and for a given symptom sample, the positive sample pair is , the negative sample pair is , and an example definition of the loss function is: ; wherein is a cosine similarity, is a temperature hyper-parameter; the negative samples include the projection knowledge vectors of other samples in the same mini-batch that have no corresponding relationship with the current symptom sample, for constructing contrast learning within the batch. The Top- N The projection knowledge vectors of the structured evidence sub-graphs are aggregated using an attention mechanism, and the attention weights are adaptively assigned according to the similarity with each other, so as to obtain the unified knowledge vector, and cross-attention or multi-head attention mechanism is used for deep fusion.

7. The method of claim 1, wherein, Further comprising a structured evidence subgraph selective retrieval strategy step: For the symptoms or herbs that frequently appear in the training set, the historical search benefits are counted, and the prediction uncertainty based on the model output confidence and / or prediction entropy is obtained. When the uncertainty of the corresponding sample is low and the historical recommendation performance is stable, the frequency of executing the sub-graph vector search engine retrieval and / or the Top- K value is reduced to reduce unnecessary retrieval overhead; For the long tail of the symptom samples with less number of samples in the training set and / or high prediction uncertainty, the frequency of retrieval of the subgraph vector retrieval engine and / or the Top- K value is increased to strengthen the constraint of the structured evidence subgraph on the model decision. The selective retrieval strategy is realized by the symptom or sample level retrieval switch and threshold control, which reduces the number of subgraph vector retrieval engine calls and overall computational cost without significantly reducing the recommendation performance.

8. The method of claim 1, wherein, Further comprising an illusion rate control and evaluation step based on knowledge graph constraints: In the reasoning phase, the candidate herb set output by the multi-label classifier is filtered to only retain herb entities that exist in the TCM knowledge graph entity set, to eliminate illegal herbs that are not in the knowledge graph from the model output; The illusion rate is defined as the proportion of herbs that do not belong to the knowledge graph entity set in the herb set predicted by the model in the test set, which is used to quantify the reliability of the model output; In the training or validation phase, by monitoring the illusion rate and adding a corresponding penalty term in the loss function, the model's tendency to produce recommendations outside the knowledge graph is further constrained, improving the consistency and explainability of the recommendation results. 9.A Chinese herbal medicine recommendation system based on structured evidence subgraph retrieval enhanced generation, characterized by, The system comprises: A knowledge graph construction module for constructing and storing the TCM knowledge graph and exporting the structured evidence subgraph; A subgraph vector retrieval engine module for serializing the structured evidence subgraph into text and constructing the subgraph vector retrieval engine through the sentence vector model and FAISS; A symptom synonym matching knowledge injection module for mapping the symptom text to the knowledge graph standard entity and injecting relevant structured knowledge; An associative memory network and structured evidence subgraph retrieval module for associative subgraph retrieval and reordering from the structured subgraph vector index based on the symptom embedding and modern Hopfield network; A graph neural network encoding module for encoding the merged structured evidence subgraph using the graph neural network to generate the graph-level structured evidence subgraph embedding vector; A cross-modal projection alignment and knowledge fusion module for projecting the graph-level embedding into a semantic space consistent with the symptom embedding and achieving cross-modal alignment through the graph self-supervised contrastive learning; A herb recommendation module for attention aggregation and cross-attention fusion of the symptom embedding and the projected knowledge embedding, and outputting the herb recommendation result through the multi-label classification network, and providing the structured evidence subgraph and its attention weight; Wherein, each module works together to perform the method steps of any one of claims 1 to 8.

Citation Information

Cited By

  • Medical question answering method and system based on multi-stage preference alignment retrieval enhancement

    CN122198148A