Herbal medicine recommendation method based on self-supervised comparative learning and semantic enhancement
By using self-supervised contrast learning and semantic enhancement techniques in the herbal recommendation method to construct multi-graph structures and enhancement sub-graphs, the shortcomings of existing methods in dealing with complex relationships and high-dimensional data are solved, and more accurate and reliable herbal recommendation effects are achieved.
Patent Information
- Application Number
- CN202411724586.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2044-11-28
AI Technical Summary
The existing herbal recommended methods are insufficient when dealing with complex relationships and high-dimensional data, and cannot fully utilize the semantic information of symptoms and herbal medicines, and rely on a large amount of labeled data, which is costly to obtain and is susceptible to data noise.
Using the herbal recommendation method based on self-supervised contrast learning and semantic enhancement, we train the symptom and herbal feature representation through the Word2vec word embedding algorithm, and construct multiple graph structures, using residual graph convolution neural network to aggregate the representation of neighborhood nodes, generate an enhancement sub-graph, and calculate the comparison loss through self-supervised contrast learning, combining cross entropy loss and Topk loss optimization model.
It improves the accuracy and reliability of herbal recommendations, makes full use of the semantic information of symptoms and herbal medicines, enhances the model's characterization ability of graph structure data and the accuracy of recommendation results, reduces the dependence on labeled data, and improves the robustness and generalization ability of the model.
Smart Images

Figure CN119760220A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of smart medical care, and in particular to a herbal medicine recommendation method based on self-supervised contrastive learning and semantic enhancement. Background Art
[0002] As a treasure of the Chinese nation, traditional Chinese medicine plays an important role in disease prevention and treatment. With the development of modern science and technology, the application of artificial intelligence technology in 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 problems such as slow knowledge update and inability to process 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 herbs to build models to predict the efficacy of herbs on symptoms. However, existing methods often ignore the semantic information of symptoms and herbs and cannot fully understand the deep relationship between symptoms and herbs. 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] As an emerging technology, self-supervised contrastive learning can effectively learn data representation and improve the generalization ability of the model by pre-training on unlabeled data. At the same time, graph neural networks perform well in processing complex relational data and are suitable for modeling multiple relationships between symptoms and herbs. However, there is currently a lack of herbal recommendation methods that combine self-supervised contrastive learning, semantic enhancement, and graph neural networks.
[0005] Therefore, a herbal medicine recommendation method based on self-supervised contrastive learning and semantic enhancement is proposed, which has important research significance and application value. This method aims to make full use of the semantic information of symptoms and herbs, 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, a recommendation method based on contrastive learning and multi-behavior semantic enhancement, adopts a multi-task form, combining contrastive learning and multi-behavior recommendation tasks to improve the recommendation performance of the multi-behavior recommendation method. This recommendation method sets up 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, we also use a unique aggregation mechanism to fuse semantic information from different behaviors, so that it can identify specific types of behavioral preference signals. In the contrastive learning task, by taking the same user across different behaviors as a positive pair, a user structure contrastive learning task is constructed to strengthen the potential dependencies of users under different behaviors and improve the representation ability of user embeddings. It effectively improves the overall performance of the recommendation model and the ability to characterize user semantic information.
[0007] In this patent, the embedding of users and items is still performed by random initialization, and a unique embedding is constructed for each auxiliary behavior based only on the embedding vector of the target behavior, thereby enhancing the embedding representation. However, the present invention makes full use of the external information of symptoms and herbs, allowing the model to obtain more detailed prior knowledge, especially when dealing with semantic complexity problems unique 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, the patent compares the target behavior and the auxiliary behavior, which may cause the learned embedding to be overly affected by the auxiliary behavior, thereby weakening the feature learning under the target behavior. The present invention avoids this negative impact by using enhanced subgraphs for comparative learning, ensuring accurate capture of the target behavior features.
[0009] Finally, the present invention introduces the TopK loss function, which enables 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 steps of manually adjusting the loss weights of each task in the traditional method, thereby improving the training efficiency and accuracy of the model. Summary of the invention
[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 by combining the semantic information of symptoms and herbs;
[0013] Step 2: According to the different relationship types between symptoms and herbs, multiple graph structures are constructed, including: symptom-herb bipartite graph, symptom-symptom synergy graph, herb-herb synergy graph;
[0014] Step 3: Use the residual graph convolutional neural network to aggregate the representations of neighboring nodes to update the representation of the current node;
[0015] Step 4: Drop nodes or edges of the collaborative graph and the bipartite graph to generate enhanced subgraphs;
[0016] Step 5: After encoding the enhanced subgraph, the contrast loss between subgraph nodes is calculated using the self-supervised contrastive learning method;
[0017] Step 6: Fuse the information from different graphs and calculate the score of the herbal medicine that can cure the symptom set;
[0018] Step 7: Combine cross entropy loss, Topk loss, and contrast loss to optimize the model by adjusting the size and direction of the gradient through an adaptive optimization algorithm.
[0019] Furthermore, the step 1: using the Word2vec word embedding algorithm, combining the semantic information of symptoms and herbs to train the feature representation of symptoms and herbs; specifically:
[0020] Given the text descriptions of symptoms and herbs, the embedding representation of each word is learned through the Skip-Gram model of Word2Vec. The goal of the Skip-Gram model is to predict the center word from the context words, which is defined as:
[0021]
[0022] Among them, w t is the central 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, θ is the parameter of the model, and the model maximizes the conditional probability P(w t+j |w t ) to learn word vectors, and by optimizing the objective function, the embedding vector of each word is obtained, which is 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 by the weighted average method. s and e h , as input features.
[0023] Furthermore, the step 2: construct multiple graph structures according to different relationship types between symptoms and herbs, including: symptom-herb bipartite graph, symptom-symptom collaboration graph, herb-herb collaboration graph; specifically:
[0024] According to the relationship types between symptoms and herbs, symptom-herb bipartite graphs are constructed Symptom-Symptom Synergy Diagram Herb-Herb Synergy Diagram Relationship types include therapeutic relationship, complications, and compatibility principles, among which Represents a collection of symptom nodes, represents a collection of herbal nodes, All symptoms and herbal entities are included, and the edge sets are defined based on the set filtering thresholds:
[0025]
[0026] Where s is the symptom, h is the herbal medicine, p is the prescription, T s , T h is the filtering threshold.
[0027] Furthermore, the step 3: using the residual graph convolutional neural network to aggregate the representation of the neighboring nodes to update the representation of the current node is specifically as follows:
[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, The initial embedding before graph aggregation is performed for node i, W i is a linear transformation matrix. To update the representation of node i at the (l+1)th layer, embedding propagation is performed on each graph obtained in step 2. The formula is as follows, and the neighborhood representation of each node in each graph is obtained;
[0031]
[0032] In the formula is the neighborhood set of node i, is the neighborhood representation of node i in the lth layer, and then a residual structure is constructed to enhance the features of each node in the graph, as shown below;
[0033]
[0034] In further discussion based on bipartite graph When considering the embedding strategy of There are two types of nodes in the graph, namely symptoms and herbs, so two independent GCNs are used to propagate the embedding of symptom nodes and herbal nodes respectively; although these two GCNs share the bipartite graph topology, but using different training parameters;
[0035] In each graph, the node representation is continuously updated by aggregating through the above formula; finally, in the graph The last layer of symptom embedding obtained in s , herbal embedding is denoted as b h ,Similarly, FIG. The last layer of symptom embedding obtained in s ,picture The final layer of herbal embedding obtained is denoted as c h .
[0036] Furthermore, the step 4: performing node discarding or edge discarding on the collaborative graph and the bipartite graph to generate an enhanced subgraph is specifically as follows:
[0037] By performing node dropping or edge dropping, and Generate two enhanced subgraphs respectively; For example, two enhancer graphs can be defined as:
[0038]
[0039] or
[0040]
[0041] In the formula, are two random masking vectors that control the retained node set and edge set, respectively, and their Dropout rate is d.
[0042] Furthermore, the step 5: after encoding the enhanced subgraph, using the self-supervised contrastive learning method, calculates the contrast loss between the subgraph nodes; specifically:
[0043] After encoding the two enhanced subgraphs by the method in step 3, the node representation of the enhanced subgraphs is obtained. For the symptom end, the symptom i is embedded in the last layer of the two enhanced graphs as When comparing subgraphs at the node scale, the same nodes are considered as positive pairs, i.e. Any different nodes are considered as negative pairs, that is, The contrast loss InfoNCE is used to maximize the consistency of the positive pairs on the symptom side and minimize the consistency of the negative pairs on the symptom side, which is calculated as follows:
[0044]
[0045] Where τ is the temperature hyperparameter in Softmax, φ(·) is the inner product of two vectors, and the loss calculation method of the herbal medicine end is similar, denoted as Respectively Perform the same operation and get Thus, the final objective function of self-supervised learning is
[0046] Furthermore, the step 6: integrating the information from different graphs and calculating the score of the symptom set that the herbal medicine can cure is specifically:
[0047] After obtaining the multi-graph embedding, the multi-angle information of symptoms and herbs from different graphs is combined using CAT() or SUM() operations to finally obtain the complete embedding information of symptoms and herbs;
[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 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 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] Among them, P is a Multi-hot encoding matrix of the symptom set in the prescription, E s is the embedding matrix of all symptoms stacked, mean(·) is the average pooling layer; next, the fraction of all herbs that can cure the symptom set is calculated as follows:
[0052]
[0053] Where E h is the embedding matrix of all herbs stacked together, and σ(·) is the Sigmoid activation function.
[0054] Furthermore, the step 7: combining cross entropy loss, Topk loss, and contrast loss, and adjusting the size and direction of the gradient through an adaptive optimization algorithm to optimize the model, specifically:
[0055] In order to enable the model to better learn to distinguish high-probability positive 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 ith sample, is the probability output of the model for the i-th sample, is the jth probability among the top k highest probability predictions for the ith sample, y ij is the corresponding target value; the basic binary cross entropy loss L bce All predictions are taken into account, and the Topk loss focuses on the model's prediction accuracy for the most likely category; combined with the contrastive learning loss in step 5, 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 function; Topk loss and contrastive learning loss are regarded as auxiliary task losses, denoted by L aux,1 and L aux,2 , the binary cross entropy loss is regarded as the target task loss, denoted by L tar ;but
[0060]
[0061] where θ represents the underlying shared parameter set, k represents the kth training iteration in an epoch, and G x Represents the gradient of task x relative to θ; in order to guide the optimization process towards the target task, if the auxiliary gradient conflicts with the target gradient, that is, 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 formula of the projection strategy is as follows:
[0062]
[0063] At the same time, a relaxation factor r is introduced to reduce G aux,i and G tar The magnitude gap between
[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 comprises a memory, a processor and a computer program stored in 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 as claimed in 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 when the computer program is executed by a processor, the method for recommending herbal medicines based on self-supervised contrastive learning and semantic enhancement as described in any one of the items is implemented.
[0068] The advantages and beneficial effects of the present invention are as follows:
[0069] The present invention comprehensively captures the complex relationship between symptoms and herbs, symptoms and symptoms, and herbs and herbs by constructing a symptom-herb bipartite graph, a symptom-symptom synergy graph, and an herb-herb synergy graph; the Word2vec word embedding algorithm is used to perform high-dimensional feature representation of symptoms and herbs, thereby enhancing the model's understanding of the intrinsic semantic information of symptoms and herbs; the residual graph convolutional neural network is used to aggregate the representation of neighborhood nodes, thereby improving the model's ability to characterize graph structure data and the accuracy of recommendation results; by discarding nodes or edges in synergy graphs and bipartite graphs, an enhanced subgraph is generated, and the contrast loss is calculated using a self-supervised contrast learning method, thereby improving the robustness and generalization ability of the model; combining cross entropy loss, Topk loss, and contrast loss, multiple loss functions optimize model performance, and the size and direction of the gradient are adjusted by an adaptive optimization algorithm, thereby improving the efficiency and stability of model training. The method can provide more accurate herbal medicine recommendations, contribute to the clinical diagnosis and treatment process of traditional Chinese medicine, improve the quality of medical services, and has significant practical application value. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] Figure 1 The present invention provides a flowchart of a preferred embodiment of a method for recommending herbal medicines based on self-supervised contrastive learning and semantic enhancement. DETAILED DESCRIPTION
[0071] The following will describe the technical solutions in the embodiments of the present invention in detail in conjunction with the accompanying drawings in the embodiments of the present invention. The described embodiments are only part of the embodiments of the present invention.
[0072] The technical solution of the present invention to solve the above technical problems is:
[0073] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and thus the drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0074] See also Figure 1 , this embodiment provides a herbal medicine recommendation method based on self-supervised contrastive learning and semantic enhancement, comprising the following steps:
[0075] Step 1: Given the text descriptions 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 from the context words, defined as:
[0076]
[0077] Among them, wt is the central 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 maximizes the conditional probability P(w t+j |w t ) to learn word vectors. By optimizing the objective function, the embedding vector of each word is obtained, which is 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 characteristics of each symptom and herb are represented as a fixed-length vector e by weighted averaging or other methods. s and e h , as input features.
[0078] Step 2: Construct symptom-herb bipartite graphs according to the relationship types between symptoms and herbs (therapeutic relationship, complications, compatibility principles). Symptom-Symptom Synergy Diagram Herb-Herb Synergy Diagram in Represents a collection of symptom nodes, Represents a collection of herbal nodes, All symptoms and herbal entities are included, and the edge sets are defined based on the set filtering thresholds:
[0079]
[0080]
[0081] Where s is the symptom, h is the herbal medicine, p is the prescription, 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, The initial embedding before graph aggregation is performed for node i, W i is 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. The formula is as follows, and the neighborhood representation of each node in each graph is obtained.
[0085]
[0086] In the formula is the neighborhood set of node i, is the neighborhood representation of node i at the lth layer. Then, a residual structure is constructed to enhance the features of each node in the graph, as shown below.
[0087]
[0088] In further discussion based on bipartite graph When considering the embedding strategy of There are two types of nodes (symptoms and herbs) in the graph. Therefore, two independent GCNs are used to propagate the embedding of symptom nodes and herbal nodes respectively. Although these two GCNs share the same bipartite graph but with different training parameters.
[0089] In each graph, the above formula is used to continuously aggregate and update the node representation. Finally, in the graph The last layer of symptom embedding obtained in s , herbal embedding is denoted as b h ,Similarly, FIG. The last layer of symptom embedding obtained in s ,picture The final layer of herbal embedding obtained is denoted as c h .
[0090] Step 4: By performing node drop or edge drop, and Generate two enhancement subgraphs respectively. For example, two enhancer graphs can be defined as:
[0091]
[0092] or
[0093]
[0094] In the formula, are two random masking vectors that control the retained node set and edge set, respectively, and their Dropout rate is d.
[0095] Step 5: After encoding the two enhanced subgraphs using the method in step 3, the node representation of the enhanced subgraph is obtained. For the symptom end, the embedding of symptom i in the last layer of the two enhanced graphs is recorded as When comparing subgraphs at the node scale, the same nodes are considered as positive pairs, i.e. Any different nodes are considered as negative pairs, that is, The contrast loss InfoNCE is used to maximize the consistency of the positive pairs on the symptom side and minimize the consistency of the negative pairs on the symptom side, which is calculated as follows:
[0096]
[0097] Where τ is the temperature hyperparameter in Softmax, and φ(·) is the inner product of two vectors. The loss calculation method of the herbal medicine end is similar, denoted as Respectively Perform the same operation and get Thus, the final objective function of self-supervised learning is
[0098] Step 6: After obtaining the multi-graph embedding, the multi-angle information of symptoms and herbs from different graphs is combined using CAT() or SUM() operations to 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 They represent the final symptom embedding and herbal 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] Among them, 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, we calculate the fraction of all herbs that can cure the symptom set, as follows:
[0103]
[0104] Where E h is the embedding matrix of all herbs stacked together, and σ(·) is the Sigmoid activation function.
[0105] Step 7: In order to enable the model to 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 ith sample, is the probability output of the model for the i-th sample, is the jth probability among the top k highest probability predictions for the ith sample, y ij is the corresponding target value. The basic binary cross entropy loss L bce All predictions are taken into account, and the Topk loss focuses on the model's prediction accuracy for the most likely category. Combined with the contrastive learning loss in 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 contrastive learning loss are regarded as auxiliary task losses and are denoted as L aux,1 and L aux,2 The binary cross entropy loss is regarded as the target task loss, denoted by L tar .but
[0111]
[0112] where θ represents the underlying shared parameter set, k represents the kth training iteration in an epoch, and 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, that is, 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 formula of the projection strategy is as follows:
[0113]
[0114] At the same time, a relaxation factor r is introduced to reduce G aux,i and G tar The magnitude gap between them.
[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 described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions.
[0118] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. 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 technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0119] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0120] The above embodiments should be understood to be only used to illustrate the present invention and not to limit the protection scope of the present invention. After reading the contents of the present invention, technicians can make various changes or modifications to the present invention, and these equivalent changes and modifications also fall within the scope defined by the claims of the present invention.
Claims
1. A herbal medicine recommendation method based on self-supervised contrastive learning and semantic enhancement, characterized in that: The following steps are involved: Step 1: Use the Word2vec word embedding algorithm to combine the semantic information of symptoms and herbs to train the feature representation of symptoms and herbs; Step 2: According to the different relationship types between symptoms and herbs, multiple graph structures are constructed, including: symptom-herb bipartite graph, symptom-symptom synergy graph, herb-herb synergy 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: Drop nodes or edges of the collaborative graph and the bipartite graph to generate enhanced subgraphs; Step 5: After encoding the enhanced subgraph, the contrast loss between subgraph nodes is calculated using the self-supervised contrastive learning method; Step 6: Fuse the information from different graphs and calculate the score of the herbal medicine that can cure the symptom set; Step 7: Combine cross entropy loss, Topk loss, and contrast loss to optimize the model by adjusting the size and direction of the gradient through an adaptive optimization algorithm.
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, combining the semantic information of symptoms and herbs to train the feature representation of symptoms and herbs; specifically: Given the text descriptions of symptoms and herbs, the embedding representation of each word is learned through the Skip-Gram model of Word2Vec. The goal of the Skip-Gram model is to predict the center word from the context words, which is defined as: Among them, w t is the central 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, θ is the parameter of the model, and the model maximizes the conditional probability P(w t+j |w t ) to learn word vectors, and by optimizing the objective function, the embedding vector of each word is obtained, which is 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 by the weighted average 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 according to different relationship types between symptoms and herbs, including: symptom-herb bipartite graph, symptom-symptom collaboration graph, herb-herb collaboration graph; specifically: According to the relationship types between symptoms and herbs, symptom-herb bipartite graphs are constructed Symptom-Symptom Synergy Diagram Herb-Herb Synergy Diagram Relationship types include therapeutic relationship, complications, and compatibility principles, among which Represents a collection of symptom nodes, Represents a collection of herbal nodes, All symptoms and herbal entities are included, and the edge sets are defined based on the set filtering thresholds: Where s is the symptom, h is the herbal medicine, p is the prescription, T s , T h 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: The step 3: using the residual graph convolutional neural network to aggregate the representations of the neighboring nodes to update the representation of the current node, specifically: The Word2Vec embedding of each entity node obtained in step 1 is updated through a linear layer. Where e i is the Word2Vec embedding of node i, The initial embedding before graph aggregation is performed for node i, W i is a linear transformation matrix. To update the representation of node i at the (l+1)th layer, embedding propagation is performed on each graph obtained in step 2. The formula is as follows, and the neighborhood representation of each node in each graph is obtained; In the formula is the neighborhood set of node i, is the neighborhood representation of node i in the lth layer, and then a residual structure is constructed to enhance the features of each node in the graph, as shown below; In further discussion based on bipartite graph When considering the embedding strategy of There are two types of nodes in the graph, namely symptoms and herbs, so two independent GCNs are used to propagate the embedding of symptom nodes and herbal nodes respectively; although these two GCNs share the bipartite graph topology, but using different training parameters; In each graph, the node representation is continuously updated by aggregating through the above formula; finally, in the graph The last layer of symptom embedding obtained in s , herbal embedding is denoted as b h ,Similarly, FIG. The last layer of symptom embedding obtained in s ,picture The final layer of herbal embedding obtained 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: The step 4: discarding nodes or edges of the collaborative graph and the bipartite graph to generate an enhanced subgraph, specifically: By performing node dropping or edge dropping, and Generate two enhanced subgraphs respectively; For example, two enhancement subgraphs can be defined as: or In the formula, are two random masking vectors that control the retained node set and edge set, 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: The step 5: after encoding the enhanced subgraph, using the self-supervised contrastive learning method, calculate the contrast loss between the subgraph nodes; specifically: After encoding the two enhanced subgraphs by the method in step 3, the node representation of the enhanced subgraphs is obtained. For the symptom end, the symptom i is embedded in the last layer of the two enhanced graphs as When comparing subgraphs at the node scale, the same nodes are considered as positive pairs, i.e. Any different nodes are considered as negative pairs, that is, The contrast loss InfoNCE is used to maximize the consistency of the positive pairs on the symptom side and minimize the consistency of the negative pairs on the symptom side, which is calculated as follows: Where τ is the temperature hyperparameter in Softmax, φ(·) is the inner product of two vectors, and the loss calculation method of the herbal medicine end is similar, denoted as Respectively Perform the same operation and get 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 6: Fusing information from different graphs to calculate the score of the symptom set that the herbal medicine can cure, specifically: After obtaining the multi-graph embedding, the multi-angle information of symptoms and herbs from different graphs is combined using CAT() or SUM() operations to 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 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 embedding of all symptoms according to the following formula to obtain the comprehensive embedding of the symptom set; esyn=ReLU(W(mean(P·Es))+b) Among them, P is a Multi-hot encoding matrix of the symptom set in the prescription, E s is the embedding matrix of all symptoms stacked, mean(·) is the average pooling layer; next, the fraction of all herbs that can cure the symptom set is calculated as follows: Where E h is the embedding matrix of all herbs stacked together, and σ(·) is the Sigmoid activation function.
8. The herbal medicine recommendation method based on self-supervised contrastive learning and semantic enhancement according to claim 1, characterized in that: Step 7: Combine cross entropy loss, Topk loss, and contrast loss to optimize the model by adjusting the size and direction of the gradient through an adaptive optimization algorithm, specifically: In order to enable the model to better learn to distinguish high-probability positive and negative examples, the following loss function is constructed to optimize the model; Where N is the number of samples in the batch, y i is the target value of the ith sample, is the probability output of the model for the i-th sample, is the jth probability among the top k highest probability predictions for the ith sample, y ij is the corresponding target value; the basic binary cross entropy loss L bce All predictions are taken into account, and the Topk loss focuses on the model's prediction accuracy for the most likely category; combined with the contrastive learning loss in step 5, the final loss function is as follows: L=L bce +λ1L Topk +λ2L ssl Where λ1 and λ2 are hyperparameters that control the strength of the corresponding loss function; Topk loss and contrastive learning loss are regarded as auxiliary task losses, denoted by L aux,1 and L aux,2 , the binary cross entropy loss is regarded as the target task loss, denoted by L tar ;but where θ represents the underlying shared parameter set, k represents the kth training iteration in an epoch, and G x Represents the gradient of task x relative to θ; in order to guide the optimization process towards the target task, if the auxiliary gradient conflicts with the target gradient, that is, 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 formula of 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 magnitude gap between By changing the mixed operation of the auxiliary task gradient direction and size, the learning process is easier to optimize towards the target task.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the herbal medicine recommendation method based on self-supervised contrastive learning and semantic enhancement as described in any one of claims 1 to 8 is implemented.
10. 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, the method for recommending herbal medicines based on self-supervised contrastive learning and semantic enhancement as claimed in any one of claims 1 to 8 is implemented.
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
Drug relocation method and system based on correction mechanism and comparative learning
CN117976139A
Open domain dialog reply method and system based on thematic enhancement
US20240062006A1
Cited By
Traditional Chinese medicine symptom association prediction method based on similarity and graph neural network
CN120183704A