An herbal medicine recommendation method based on self-supervised contrastive learning and semantic enhancement

By employing self-supervised contrastive learning and semantic enhancement, this study addresses the shortcomings of existing herbal medicine recommendation methods in handling complex relationships and high-dimensional data in the field of traditional Chinese medicine. This approach enables more accurate herbal medicine recommendations and improves the quality of medical services in TCM clinical diagnosis and treatment.

CN119760220BActive Publication Date: 2025-11-28CHONGQING UNIV OF POSTS & TELECOMM
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411724586.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-28
Publication Date
2025-11-28
Estimated Expiration
2044-11-28

AI Technical Summary

Technical Problem

Existing herbal recommendation methods suffer from several drawbacks when dealing with complex relationships and high-dimensional data in the field of Traditional Chinese Medicine (TCM). These include slow knowledge updates, reliance on expert experience, inability to fully understand the deep-seated relationship between symptoms and herbs, the need for large amounts of labeled data, and susceptibility to noise.

Method used

We employ a self-supervised contrastive learning and semantic enhancement approach. We train feature representations of symptoms and herbs using the Word2Vec algorithm, construct multiple graph structures, aggregate neighborhood node representations using a residual graph convolutional neural network to generate enhanced subgraphs, and combine self-supervised contrastive learning to calculate contrastive loss, optimize the model gradient direction, and improve model performance using multiple loss functions.

Benefits of technology

It improves the accuracy and reliability of herbal recommendations, enhances the model's understanding of symptoms and the inherent semantic information of herbs, and improves the accuracy of recommendation results, the robustness and generalization ability of the model, making it suitable for TCM clinical diagnosis and treatment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119760220B_ABST
    Figure CN119760220B_ABST
Patent Text Reader

Abstract

The application claims a herbal medicine recommendation method based on self-supervised contrast learning and semantic enhancement. First, the Word2vec word embedding algorithm is used to combine the semantic information of symptoms and herbal medicines to train the feature representation of symptoms and herbal medicines. Then, the symptom-herbal medicine bipartite graph, symptom-symptom collaborative graph and herbal medicine-herbal medicine collaborative graph structure are constructed to capture different types of relationships between symptoms and herbal medicines. The residual graph convolutional neural network is used to aggregate the features of neighboring nodes to update the representation of the current node, and the enhanced subgraph is generated by randomly discarding nodes or edges of the collaborative graph and the bipartite graph. After encoding these subgraphs, the self-supervised contrast learning method is used to calculate the contrast loss between nodes. Then, the information from different graphs is fused to calculate the treatment score of herbal medicines on the symptom set. Finally, the adaptive optimization algorithm is used to adjust the gradient of the model by combining the cross-entropy loss, Topk loss and contrast loss, which improves the accuracy and reliability of herbal medicine recommendation.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of intelligent medical treatment, and in particular to a herbal medicine recommendation method based on self-supervised contrastive learning and semantic enhancement. BACKGROUND

[0002] Traditional Chinese medicine, as a treasure of the Chinese nation, plays an important role in disease prevention and treatment. With the development of modern science and technology, applying artificial intelligence technology to the field of traditional Chinese medicine, especially herbal medicine recommendation, has become a research hotspot. Traditional herbal medicine recommendation methods mainly rely on expert experience and rule bases, but these methods have the problems of slow knowledge update and inability to handle large-scale data.

[0003] In recent years, herbal medicine recommendation methods based on machine learning and deep learning have gradually emerged. These methods usually use historical association data between symptoms and herbal medicines to build models to predict the efficacy of herbal medicines on symptoms. However, existing methods often ignore the semantic information of symptoms and herbal medicines, and cannot fully understand the deep relationship between symptoms and herbal medicines. In addition, traditional supervised learning methods require a large amount of labeled data, which is costly to obtain and is easily affected by data noise.

[0004] Self-supervised contrastive learning, as a new technology, can effectively learn the representation of data by pre-training on unlabeled data, improving the generalization ability of the model. At the same time, graph neural networks perform well in handling complex relational data and are suitable for modeling the multiple relationships between symptoms and herbal medicines. However, there is currently a lack of herbal medicine recommendation methods that combine self-supervised contrastive learning, semantic enhancement, and graph neural networks.

[0005] Therefore, it is of great research significance and application value to propose a herbal medicine recommendation method based on self-supervised contrastive learning and semantic enhancement. This method aims to fully utilize the semantic information of symptoms and herbal medicines, construct multiple graph structures, and combine self-supervised contrastive learning to improve the accuracy and reliability of herbal medicine recommendation.

[0006] After searching, the application publication number CN118113938A discloses a recommendation method based on contrastive learning and multi-behavior semantic enhancement. It adopts a multi-task form and combines contrastive learning and multi-behavior recommendation tasks to improve the recommendation performance of the multi-behavior recommendation method. The recommendation method sets a new multi-behavior graph convolution algorithm, which uses the user's target behavior embedding to guide the generation of each auxiliary behavior embedding. In addition, a unique aggregation mechanism is used to fuse semantic information from different behaviors, enabling it to identify specific types of behavior preference signals. In the contrastive learning task, the same user under different behaviors is used as positive pairs to construct a user structure contrastive learning task, which strengthens the user's potential dependence relationship under different behaviors and improves the representation ability of user embeddings. This effectively improves the overall performance of the recommendation model and the ability to depict user semantic information.

[0007] In this patent, the embedding of users and items is still done through random initialization, and only based on the embedding vector of the target behavior to build a unique embedding for each auxiliary behavior, thereby enhancing the embedding representation. However, the present invention makes full use of the external information of symptoms and herbs, so that the model can acquire more detailed prior knowledge, especially when dealing with the semantic complexity specific to the field of traditional Chinese medicine. By injecting the specific semantic information of symptoms and herbs into the model, the instability and semantic ambiguity caused by random initialization are avoided.

[0008] In addition, this patent compares the target behavior and the auxiliary behavior, which may cause the learned embedding to be excessively influenced by the auxiliary behavior, thereby weakening the feature learning under the target behavior. However, the present invention avoids this negative effect by using enhanced sub-graphs for contrastive learning, ensuring accurate capture of the target behavior features.

[0009] Finally, the present invention introduces a TopK loss function, which allows the model to better distinguish high-probability positive and negative examples, and adjusts the size and direction of the gradient through an adaptive optimization algorithm, effectively avoiding the tedious step of manually adjusting the loss weights of each task in traditional methods, thereby improving the training efficiency and accuracy of the model. SUMMARY

[0010] The present invention aims to solve the shortcomings of existing herbal medicine recommendation methods in dealing with complex relationships and high-dimensional data. A herbal medicine recommendation method based on self-supervised contrastive learning and semantic enhancement is proposed. The technical solution of the present invention is as follows:

[0011] A herbal medicine recommendation method based on self-supervised contrastive learning and semantic enhancement, comprising the following steps:

[0012] Step 1: Use the Word2vec word embedding algorithm to train the feature representation of symptoms and herbs in combination with the semantic information of symptoms and herbs;

[0013] Step 2: According to the different relationship types between symptoms and herbs, construct multiple graph structures, including: symptom-herb bipartite graph, symptom-symptom collaborative graph, herb-herb collaborative graph;

[0014] Step 3: Use residual graph convolutional neural network to aggregate the representation of neighboring nodes to update the representation of the current node;

[0015] Step 4: Perform node dropping or edge dropping on the collaborative graph and bipartite graph to generate enhanced sub-graphs;

[0016] Step 5: After encoding the enhanced sub-graphs, use the self-supervised contrastive learning method to calculate the contrastive loss between the nodes of the sub-graphs;

[0017] Step 6: Fuse information from different graphs and calculate the score of the set of symptoms that can be cured by the herb;

[0018] Step 7: Combine the cross-entropy loss, Topk loss, and contrastive loss to optimize the model by adjusting the size and direction of the gradient through an adaptive optimization algorithm.

[0019] Further, step 1: Use the Word2vec word embedding algorithm to train the feature representation of symptoms and herbs combined with the semantic information of symptoms and herbs; specifically:

[0020] Given the text description of symptoms and herbs, learn the embedding representation of each word through the Skip-Gram model of Word2Vec. The goal of the Skip-Gram model is to predict the center word through the context words, defined as:

[0021]

[0022] where w t is the center word, w t+j is the context word, c is the size of the context window, T is the total number of words in the text, and θ is the parameter of the model. The model learns the word vector by maximizing the conditional probability P(w t+j |w t ) given the context word. By optimizing the objective function, we get the embedding vector of each word, represented as a d-dimensional vector. For each text description of symptoms and herbs, convert it into a word vector representation and represent the feature of each symptom and herb as a fixed-length vector e s and e h as input features.

[0023] Further, step 2: Construct multiple graph structures according to different relationship types between symptoms and herbs. Including: symptom-herb bipartite graph, symptom-symptom collaborative graph, herb-herb collaborative graph; specifically:

[0024] According to the relationship types between symptoms and herbs, construct the symptom-herb bipartite graph Symptom-symptom collaborative graph Herb-herb collaborative graph The relationship types include treatment relationship, complication, and compatibility principle, where represents the set of symptom nodes, represents the set of herb nodes, covers all symptoms and herb entities, and the edge set is defined based on the set filtering threshold:

[0025]

[0026] where s is a symptom, h is a herb, p is a prescription, T s , T h is a filtering threshold.

[0027] Further, the step 3: updating the representation of the current node by aggregating the representations of the neighborhood nodes using the residual graph convolutional neural network, specifically:

[0028] The Word2Vec embedding of each entity node obtained in step 1 is updated through a linear layer.

[0029]

[0030] where e i is the Word2Vec embedding of node i, is the initial embedding of node i before performing graph aggregation, W i is a linear transformation matrix, in order to update the representation of node i in the (l+1) layer, the embedding propagation is performed on each graph respectively, the formula is as follows, the neighborhood representation of each node in each graph is obtained;

[0031]

[0032] where is the neighborhood set of node i, is the neighborhood representation of node i in the l layer, then a residual structure is constructed to enhance the features of each node in the graph, as follows;

[0033]

[0034] In further exploring the embedding strategy based on the bipartite graph , considering that there are two types of nodes in the bipartite graph , namely symptoms and herbs, two independent GCNs are used to perform embedding propagation on symptom nodes and herb nodes respectively; although these two GCNs share the topology of the bipartite graph , they use different training parameters;

[0035] The node representation is continuously aggregated and updated in each graph by the above formula; finally, the last layer symptom embedding obtained in the graph is denoted as b s , and the herb embedding is denoted as b h , similarly, the last layer symptom embedding obtained in the graph is denoted as c s , and the last layer herb embedding obtained in the graph is denoted as c h .

[0036] Further, the step 4: performing node dropping or edge dropping on the coordination graph and the bipartite graph to generate an enhanced subgraph, specifically:

[0037] By performing node dropping or edge dropping, two enhanced subgraphs are generated respectively as and Take for example, the two enhanced subgraphs can be defined as:

[0038]

[0039] or

[0040]

[0041] wherein are two random mask vectors for controlling the reserved node set and edge set respectively, and the Dropout rate is d.

[0042] Further, the step 5: after encoding the enhanced subgraph, a self-supervised contrastive learning method is used to calculate the contrastive loss between the nodes of the subgraph; specifically:

[0043] After encoding the two enhanced subgraphs through the method of step 3, the node representation of the enhanced subgraph is obtained, and for the symptom side, the last layer embedding of symptom i in the two enhanced graphs is respectively denoted as The subgraph is compared at the node scale, and the same node is regarded as a positive pair, i.e. Any different node is regarded as a negative pair, i.e. The contrastive loss InfoNCE is used to maximize the consistency of the positive pair of the symptom side and minimize the consistency of the negative pair of the symptom side, which is calculated as follows:

[0044]

[0045] Where τ is the temperature hyperparameter in Softmax, and φ(·) is the inner product of two vectors. The loss calculation method of the herbal medicine side is similar, denoted as The same operation is performed on to obtain Thus, the final objective function of the self-supervised learning is

[0046] Further, the step 6: information from different graphs is fused to calculate the score of the set of symptoms that can be cured by the herbal medicine, specifically:

[0047] After obtaining the multi-graph embedding, the multi-angle information of symptoms and herbal medicines from different graphs is combined by using the CAT() or SUM() operation to finally obtain the complete embedding information of symptoms and herbal medicines;

[0048] eS = COMBINE(b s , c s ), e H = COMBINE(b h , c h )

[0049] where e S and e H represent the final symptom embedding and herb embedding respectively, COMBINE(·) denotes either CAT() or SUM() operation; then the Multi-hot encoding of the symptom set in the prescription is interacted with the embedding of all symptoms according to the following formula to obtain the comprehensive embedding of the symptom set:

[0050] esyn = ReLU(W(mean(P · Es)) + b)

[0051] where P is a Multi-hot encoding matrix of the symptom set in the prescription, E s is the embedding matrix of all symptoms stacked, and mean(·) is the average pooling layer; next, the scores of all herbs that can cure the symptom set are calculated, and the formula is as follows:

[0052]

[0053] where E h is the embedding matrix of all herbs stacked, and σ(·) is the Sigmoid activation function.

[0054] Further, the step 7: combine the cross-entropy loss, the Topk loss, and the contrastive loss to optimize the model by adjusting the size and direction of the gradient through the adaptive optimization algorithm, specifically:

[0055] In order to make the model better learn to distinguish high-probability positive examples and negative examples, the following loss function is constructed to optimize the model:

[0056]

[0057] where N is the number of samples in the batch, y i is the target value of the i-th sample, is the probability output of the i-th sample by the model, is the j-th probability in the top k highest probability predictions of the i-th sample, y ij is the corresponding target value; the basic binary cross-entropy loss L bce considers all predictions, while the Topk loss focuses on the prediction accuracy of the most likely class by the model; combined with the contrastive learning loss in step 5, therefore, the final loss function is as follows:

[0058] L = L bce+ λ1L Topk + λ2L ssl

[0059] where λ1 and λ2 are hyperparameters that control the strength of the corresponding loss functions; the Topk loss and the contrastive learning loss are regarded as auxiliary task losses, denoted as L aux,1 and L aux,2 , respectively; the binary cross-entropy loss is regarded as the target task loss, denoted as L tar ; then

[0060]

[0061] where θ represents the set of shared parameters at the bottom layer, k represents the k-th training iteration in an epoch, G x represents the gradient of task x with respect to θ; in order to guide the optimization process towards the target task, if the auxiliary gradient conflicts with the target gradient, i.e., their cosine similarity is negative, first modify the gradient direction by projecting the auxiliary gradient onto the normal plane of the target gradient, and the formula of the projection strategy is as follows:

[0062]

[0063] At the same time, a relaxation factor r is introduced to reduce the amplitude gap between G aux,i and G tar ;

[0064]

[0065] By changing the mixed operation of the auxiliary task gradient direction and size, the learning process is easier to optimize towards the target task.

[0066] An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements the herbal medicine recommendation method based on self-supervised contrastive learning and semantic enhancement according to any one of claims 1 to 8 when executing the program.

[0067] A non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program is executable by a processor to implement the herbal medicine recommendation method based on self-supervised contrastive learning and semantic enhancement according to any one of claims.

[0068] The advantages and beneficial effects of the present application are as follows:

[0069] The application comprehensively captures the complex relationships between symptoms and herbs, and between symptoms and symptoms, and between herbs and herbs, by constructing a symptom-herb bipartite graph, a symptom-symptom synergy graph, and a herb-herb synergy graph; uses a Word2vec word embedding algorithm to represent the high-dimensional features of symptoms and herbs, enhancing the model's understanding of the intrinsic semantic information of symptoms and herbs; uses a residual graph convolutional neural network to aggregate the representations of neighboring nodes, improving the model's representation ability for graph structure data and the accuracy of the recommendation results; generates enhanced subgraphs by discarding nodes or edges of the synergy graph and the bipartite graph, calculates the contrast loss using a self-supervised contrast learning method, and improves the robustness and generalization ability of the model; combines cross-entropy loss, Topk loss, and contrast loss to optimize the performance of the model, and adjusts the size and direction of the gradient through an adaptive optimization algorithm, improving the efficiency and stability of the model training. The method can provide more accurate herb recommendations, help the process of traditional Chinese medicine clinical diagnosis and treatment, improve the quality of medical services, and has significant practical application value. BRIEF DESCRIPTION OF DRAWINGS

[0070] Figure 1 The application provides a flowchart of a herb recommendation method based on self-supervised contrast learning and semantic enhancement. DETAILED DESCRIPTION

[0071] The technical solutions in the embodiments of the application will be described below in detail with reference to the drawings of the embodiments of the application. The described embodiments are only some of the embodiments of the application.

[0072] The technical solutions of the application to solve the above technical problems are:

[0073] It should be noted that the diagrams provided in the following embodiments only schematically illustrate the basic concept of the application, and the diagrams only show the components related to the application, not the number, shape and size of the components when actually implemented. The actual implementation of each component may be arbitrarily changed in terms of shape, number and proportion, and the layout pattern of the components may be more complex.

[0074] Please refer to Figure 1 The herb recommendation method based on self-supervised contrast learning and semantic enhancement provided by the embodiment includes the following steps:

[0075] Step 1: Given the text description of symptoms and herbs, learn the embedding representation of each word through the Skip-Gram model of Word2Vec. The goal of the Skip-Gram model is to predict the center word through the context word, defined as:

[0076]

[0077] where wt is the center word, w t+j is the context word, c is the size of the context window, T is the total number of words in the text, and Θ is the parameters of the model. The model learns word vectors by maximizing the conditional probability P(w t+j |w t ) of a context word given a center word. By optimizing this objective function, we obtain an embedding vector for each word, denoted as a d-dimensional vector. For each symptom and herb textual description, we convert it into a word vector representation and represent the feature of each symptom and herb as a fixed-length vector e s and e h as input features.

[0078] Step 2: Construct symptom-herb bipartite graphs according to the relationship types between symptoms and herbs (treatment relationship, complication, compatibility principle) Symptom-symptom synergy graph Herb-herb synergy graph where denotes the set of symptom nodes, denotes the set of herb nodes, covers all symptom and herb entities, and the edge set is defined based on the set filtering threshold:

[0079]

[0080]

[0081] where s is the symptom, h is the herb, p is the prescription, and T s , T h is the filtering threshold.

[0082] Step 3: Update the Word2Vec embedding of each entity node obtained in step 1 through a linear layer.

[0083]

[0084] where e i is the Word2Vec embedding of node i, is the initial embedding of node i before performing graph aggregation, and W i is a linear transformation matrix. To update the representation of node i at the (l+1) layer, we perform embedding propagation on each graph obtained in step 2, as shown in the formula below, to obtain the neighborhood representation of each node in each graph.

[0085]

[0086] where N is the neighborhood set of node i, is the neighborhood of node i in the l-th layer. Then, a residual structure is constructed to enhance the feature of each node in the graph, as follows.

[0087]

[0088] In further exploring the embedding strategy based on bipartite graph , it is considered that there are two types of nodes (symptoms and herbs) in the bipartite graph . Therefore, two independent GCNs are used to embed and propagate the symptoms nodes and the herbs nodes respectively. Although the two GCNs share the topology of the bipartite graph , they use different training parameters.

[0089] In each graph, the node representation is constantly aggregated and updated by the above formula. Finally, the last layer of symptom embedding in the graph is denoted as b s , and the last layer of herb embedding is denoted as b h . Similarly, the last layer of symptom embedding in the graph is denoted as c s , and the last layer of herb embedding in the graph is denoted as c h .

[0090] Step 4: Generate two enhanced subgraphs from and by performing node dropout or edge dropout. Take for example, the two enhanced subgraphs can be defined as:

[0091]

[0092] or

[0093]

[0094] In the formula, are two random mask vectors that control the reserved node set and edge set respectively, and the Dropout rate is d.

[0095] Step 5: After encoding the two enhanced subgraphs by the method in step 3, the node representation of the enhanced subgraph is obtained. For the symptom side, the last layer of embedding of symptom i in the two enhanced graphs is denoted as Compare the subgraphs at the node scale, and regard the same node as a positive pair, i.e. regard any different nodes as a negative pair, i.e. Use the contrastive loss InfoNCE to maximize the consistency of the positive pairs of the symptom side and minimize the consistency of the negative pairs of the symptom side, which is calculated as follows:

[0096]

[0097] where τ is the temperature hyper-parameter in Softmax, and φ(·) is the inner product of two vectors. The loss calculation method of the herbal side is similar, denoted as The same operation is performed on to obtain Thus, the final objective function of self-supervised learning is

[0098] Step 6: After obtaining the multi-graph embedding, use the CAT() or SUM() operation to combine the multi-angle information of symptoms and herbs from different graphs, and finally obtain the complete embedding information of symptoms and herbs.

[0099] e S = COMBINE(b s , c s ), e H = COMBINE(b h , c h )

[0100] where e S and e H represent the final symptom embedding and herb embedding, respectively, and COMBINE(·) represents the CAT() or SUM() operation. Then, the Multi-hot encoding of the symptom set in the prescription is interacted with the embedding of all symptoms according to the following formula to obtain the comprehensive embedding of the symptom set.

[0101] esyn = ReLU(W(mean(P·Es))+b)

[0102] where P is a Multi-hot encoding matrix of the symptom set in the prescription, E s is the stacked embedding matrix of all symptoms, and mean(·) is the average pooling layer. Next, the scores of all herbs that can cure the symptom set are calculated, as follows:

[0103]

[0104] where E h is the stacked embedding matrix of all herbs, and σ(·) is the Sigmoid activation function.

[0105] Step 7: In order to make the model better learn to distinguish high-probability positive and negative examples, the following loss function is constructed to optimize the model.

[0106]

[0107] where N is the number of samples in the batch, y i is the target value of the i-th sample, is the probability output of the model for the i-th sample, is the j-th probability in the top-k highest probability predictions of the i-th sample, y ij is the corresponding target value. The basic binary cross-entropy loss L bce The Topk loss focuses on the prediction accuracy of the model on the most likely class, considering all predictions. Combined with the contrastive learning loss of step 5, the final loss function is as follows:

[0108] L=L bce +λ1L Topk +λ2L ssl

[0109] where λ1 and λ2 are hyperparameters that control the strength of the corresponding loss function.

[0110] The Topk loss and the contrastive learning loss are regarded as auxiliary task losses, denoted as L aux,1 and L aux,2 The binary cross-entropy loss is regarded as the target task loss, denoted as L tar . Then

[0111]

[0112] where θ represents the underlying shared parameter set, k represents the k-th training iteration in an epoch, G x represents the gradient of task x with respect to θ. In order to guide the optimization process towards the target task, if the auxiliary gradient conflicts with the target gradient, i.e. their cosine similarity is negative, first modify the gradient direction by projecting the auxiliary gradient onto the normal plane of the target gradient. The formula of the projection strategy is as follows:

[0113]

[0114] At the same time, a relaxation factor r is introduced to reduce the amplitude gap between G aux,i and G tar .

[0115]

[0116] By changing the mixed operation of the auxiliary task gradient direction and size, the learning process is easier to optimize towards the target task.

[0117] The systems, devices, modules or units illustrated in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions.

[0118] Computer-readable media includes permanent and non-permanent, movable and non-movable media that can implement information storage by any method or technology. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible to a computing device. According to the definition herein, computer-readable media does not include transitory media such as modulated data signals and carriers.

[0119] It should also be noted that the terms "comprising", "containing", or any other variant thereof are intended to cover non-exclusive inclusions, so that a process, method, article or apparatus that includes a list of elements not only includes those elements, but also includes other elements not explicitly listed, or inherent to such a process, method, article or apparatus. Without more limitations, the element defined by the statement "comprising a" does not exclude the presence of additional identical elements in the process, method, article or apparatus that includes the element.

[0120] The above embodiments should be understood as merely illustrative of the present application and not restrictive of the scope of protection of the present application. After reading the content of the description of the present application, those skilled in the art can make various modifications or changes to the present application, and these equivalent changes and modifications also fall within the scope defined by the claims of the present application.

Claims

1. A herbal medicine recommendation method based on self-supervised contrastive learning and semantic enhancement, characterized in that, Includes the following steps: Step 1: Use the Word2vec word embedding algorithm to train feature representations of symptoms and herbs by combining semantic information of symptoms and herbs; Step 2: Based on the different types of relationships between symptoms and herbs, construct multiple graph structures, including: symptom-herb bipartite graph, symptom-symptom synergistic graph, and herb-herb synergistic graph; Step 3: Use the residual graph convolutional neural network to aggregate the representations of neighboring nodes to update the representation of the current node; Step 4: Discard nodes or edges from the collaborative graph and bipartite graph to generate an enhanced subgraph; Step 5: After encoding the augmented subgraph, calculate the contrast loss between subgraph nodes using a self-supervised contrastive learning method; Step 6: Merge the information from different graphs and calculate the score of the symptom set that the herbal medicine can cure; Step 7: Combine cross-entropy loss, Topk loss, and contrastive loss, and optimize the model by adjusting the magnitude and direction of the gradient using an adaptive optimization algorithm; Step 3: Update the representation of the current node by aggregating the representations of neighboring nodes using a residual graph convolutional neural network, specifically as follows: The Word2Vec embedding of each entity node obtained in step 1 is updated through a linear layer; Embedding propagation is performed on each graph obtained in step 2 to obtain the neighborhood representation of each node in each graph; then, a residual structure is constructed to enhance the features of each node in the bipartite graph. There are two types of nodes in the graph: symptoms and herbs. Two independent GCNs are used to perform embedding propagation on symptom nodes and herb nodes respectively. The node representation is continuously aggregated and updated in each graph using the above formula. Finally, in the graph... The final symptom embedding obtained from the process is denoted as b. s Herbal embedding is denoted as b h ,picture The final symptom embedding obtained from the process is denoted as c. s ,picture The last layer of herbs obtained from the process is denoted as c. h ; Step 6: The information from different graphs is fused to calculate the score by which the herbal medicine can cure the symptom set, specifically: After obtaining the multi-graph embedding, the CAT() or SUM() operation is used to combine the multi-angle information of symptoms and herbs from different graphs, and finally obtain the complete embedding information of symptoms and herbs. e S =COMBINE(b s ,c s ),e H =COMBINE(b h ,c h ) Where e S and e H These represent the final symptom embedding and herbal embedding, respectively. COMBINE(·) represents the CAT() or SUM() operation. Then, the multi-hot encoding of the symptom set in the prescription is interacted with the embeddings of all symptoms according to the following formula to obtain the comprehensive embedding of the symptom set. have been syn =ReLU(W(mean(P·E s ))+b) Where P is a multi-hot encoding matrix of the symptom set in the prescription, and E s This is the embedding matrix of all stacked symptoms, and mean(·) is the average pooling layer; next, the scores of all herbs that can cure the symptom set are calculated, using the following formula: Where E h Let be the embedding matrix of all the herbs stacked, and σ(·) be the Sigmoid activation function.

2. The herbal medicine recommendation method based on self-supervised contrastive learning and semantic enhancement according to claim 1, characterized in that, Step 1: Using the Word2vec word embedding algorithm, combined with the semantic information of symptoms and herbs, to train feature representations of symptoms and herbs; specifically: Given a textual description of symptoms and herbs, the embedding representation of each word is learned using a Skip-Gram model from Word2Vec. The goal of the Skip-Gram model is to predict the center word from the context words, defined as: Among them, w t It is the central word, w t+j Here, c is the context word, T is the total number of words in the text, and θ is the model parameter. The model maximizes the conditional probability P(w) of the context word given the center word. t+j |w t To learn word vectors, the embedding vector for each word is obtained by optimizing the objective function, represented as a d-dimensional vector. For the text description of each symptom and herb, it is converted into a word vector representation, and the features of each symptom and herb are represented as a fixed-length vector e using a weighted averaging method. s and e h , as input features.

3. The herbal medicine recommendation method based on self-supervised contrastive learning and semantic enhancement according to claim 1, characterized in that, Step 2: Construct multiple graph structures based on the different relationship types between symptoms and herbs; including: symptom-herb bipartite graph, symptom-symptom synergistic graph, and herb-herb synergistic graph; specifically: Construct symptom-herb bipartite diagrams based on the types of relationships between symptoms and herbs. Symptom-symptom synergistic diagram Herbs - Herb Synergy Diagram Relationship types include therapeutic relationships, complication relationships, and compatibility principles, among which... Represents the set of symptom nodes. Represents the set of herb nodes. It covers all symptoms and herbal entities, and the edge set is defined based on a set filtering threshold: Where s represents symptoms, h represents herbs, p represents prescriptions, and T represents... s T h This is the filtering threshold.

4. The herbal medicine recommendation method based on self-supervised contrastive learning and semantic enhancement according to claim 1, characterized in that, Step 3: Update the representation of the current node by aggregating the representations of neighboring nodes using a residual graph convolutional neural network, specifically as follows: The Word2Vec embedding of each entity node obtained in step 1 is updated through a linear layer; In the formula e i Word2Vec embedding for node i, For node i, perform initial embedding before graph aggregation, W i For the linear transformation matrix, in order to update the representation of node i at the (l+1)th layer, embedding propagation is performed on each graph obtained in step 2, as shown in the following formula, to obtain the neighborhood representation of each node in each graph; In the formula Let i be the set of the neighborhood of node i. Let i be the neighborhood representation of node i at the l-th layer. Then, construct a residual structure to enhance the features of each node in the graph, as shown below. Two-part diagram There are two types of nodes: symptoms and herbs. Two separate GCNs are used to propagate the embeddings of symptom nodes and herb nodes respectively; although these two GCNs share a bipartite graph. The same topology, but with different training parameters; In each graph, the node representation is continuously aggregated and updated using the above formula; ultimately, in the graph... The final symptom embedding obtained from the process is denoted as b. s Herbal embedding is denoted as b h ,picture The final symptom embedding obtained from the process is denoted as c. s ,picture The last layer of herbs obtained from the process is denoted as c. h .

5. The herbal medicine recommendation method based on self-supervised contrastive learning and semantic enhancement according to claim 1, characterized in that, Step 4: Discarding nodes or edges in the collaborative graph and bipartite graph to generate an enhanced subgraph, specifically: By performing node dropping or edge dropping, and Two enhanced subgraphs are generated respectively; with For example, two enhancement subgraphs are defined as follows: or In the formula, These are two random masking vectors that control the set of nodes and the set of edges to be retained, respectively, and their dropout rate is d.

6. The herbal medicine recommendation method based on self-supervised contrastive learning and semantic enhancement according to claim 1, characterized in that, Step 5: After encoding the enhanced subgraph, a self-supervised contrastive learning method is used to calculate the contrastive loss between subgraph nodes; specifically: After encoding the two augmented subgraphs using the method in step 3, the node representations of the augmented subgraphs are obtained. For the symptom end, symptom i is embedded in the last layer of the two augmented graphs and denoted as follows: Compare subgraphs at the node scale, treating the same node as the opposite node, i.e. Any two distinct nodes are considered a negative pair, i.e. The contrastive loss InfoNCE is used to maximize the consistency of positive pairs on the symptom side and minimize the consistency of negative pairs on the symptom side. The calculation is as follows: Where τ is the temperature hyperparameter in Softmax, φ(·) is the inner product of two vectors, and the loss calculation method at the herbal end is similar, denoted as... To each Perform the same operation to obtain Thus, the final objective function of self-supervised learning is:

7. The herbal medicine recommendation method based on self-supervised contrastive learning and semantic enhancement according to claim 1, characterized in that, Step 7: Combining cross-entropy loss, Topk loss, and contrastive loss, the model is optimized by adjusting the magnitude and direction of the gradient using an adaptive optimization algorithm. Specifically: To enable the model to better learn to distinguish between high-probability positive and negative examples, the following loss function was constructed to optimize the model; Where N is the number of samples in the batch, y i It is the target value of the i-th sample. It is the model's probability output for the i-th sample. It is the j-th probability among the k highest probability predictions of the i-th sample, y ij This corresponds to the target value; the basic binary cross-entropy loss L bce All predictions are considered, and the Topk loss focuses on the model's prediction accuracy for the most likely class; combined with the contrastive learning loss from step 5, the final loss function is as follows: L=L bce +λ1L Topk +λ2L ssl In the formula, λ1 and λ2 are hyperparameters controlling the strength of the corresponding loss functions; the Topk loss and contrastive learning loss are regarded as auxiliary task losses, denoted as L1 and L2 respectively. aux,1 and L aux,2 The binary cross-entropy loss is considered as the target task loss, denoted as L. tar ;but Where θ represents the underlying shared parameter set, k represents the k-th training iteration in an epoch, and G... x Let θ represent the gradient of task x with respect to θ. To guide the optimization process toward the target task, if the auxiliary gradient conflicts with the target gradient (i.e., their cosine similarity is negative), the gradient direction is first modified by projecting the auxiliary gradient onto the normal plane of the target gradient. The projection strategy is as follows: At the same time, a relaxation factor r is introduced to reduce G. aux,i and G tar The difference in magnitude between them; By using a hybrid operation that alters the direction and magnitude of the gradient in the auxiliary task, the learning process becomes easier to optimize towards the target task.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the herbal recommendation method based on self-supervised contrastive learning and semantic enhancement as described in any one of claims 1 to 7.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the herbal recommendation method based on self-supervised contrastive learning and semantic enhancement as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Recommendation method based on comparative learning and multi-behavior semantic enhancement

    CN118113938A

  • Causal relationship identification method and device based on graph convolutional network and comparative learning

    CN115309862A

  • CircRNA and disease association prediction method

    CN116682493A