A novel traditional Chinese medicine herb recommendation method and system based on co-occurrence feature enhancement
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HUNAN UNIV OF CHINESE MEDICINE
- Filing Date
- 2026-03-16
- Publication Date
- 2026-06-19
Smart Images

Figure CN122245646A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of traditional Chinese medicine diagnosis and treatment, and particularly to a novel traditional Chinese medicine herb recommendation method and system based on enhanced co-occurrence features. Background Art
[0002] Traditional Chinese medicine herb prescriptions are the crystallization of wisdom accumulated in thousands of years of clinical practice of traditional Chinese medicine, systematically reflecting the dialectical treatment ideological system of "theory-method-prescription-herb". In the process of traditional Chinese medicine diagnosis and treatment, doctors need to infer the underlying pathogenesis and syndromes based on the complex symptoms of patients, and then establish corresponding treatment methods, and construct herb prescriptions following the prescription principle of "sovereign, minister, assistant, and courier". This reasoning process reflects a progressive logic from explicit symptoms to implicit syndromes and then to specific medication decisions, with highly non-linear and multi-level complex characteristics. In recent years, with the rapid development of artificial intelligence and deep learning technologies, traditional Chinese medicine herb recommendation methods based on deep learning have gradually become an important research direction for assisting clinical decision-making, improving diagnosis and treatment efficiency, and inheriting the experience of famous old traditional Chinese medicine doctors. By learning from large-scale historical prescription data, the model can simulate the dialectical thinking of doctors to a certain extent and achieve data-driven herb combination recommendations.
[0003] Although preliminary progress has been made in existing research, there are still many limitations and it is difficult to fully meet the dual requirements of precision and interpretability in traditional Chinese medicine clinical practice. First, existing methods generally regard symptoms as independent discrete features, ignoring the global statistical co-occurrence relationship between symptoms and herbs at the population level, resulting in the model being unable to effectively capture deep potential semantic associations when facing sparse data. Second, mainstream models mostly adopt an end-to-end mapping method of "symptom-herb", directly inferring herb recommendations from symptoms, lacking hierarchical modeling of the core logic of traditional Chinese medicine diagnosis and treatment "symptom-syndrome-treatment method", and ignoring the generation process of potential syndrome distribution and treatment strategies, thus limiting the interpretability and generalization ability of the model. In addition, symptom descriptions and treatment logic are in different semantic spaces, and existing methods lack effective semantic alignment and dynamic fusion mechanisms, making it difficult to achieve adaptive attention to key symptoms, resulting in limited accuracy and personalization of recommendation results.
[0004] In summary, existing traditional Chinese medicine herb recommendation research generally has problems such as insufficient feature utilization, lack of reasoning logic, difficulty in semantic alignment, and limited recommendation accuracy. Therefore, it is necessary to propose a novel traditional Chinese medicine herb recommendation method that can comprehensively utilize symptom-herb co-occurrence features, simulate the multi-level reasoning process of traditional Chinese medicine, and achieve cross-semantic space alignment to better conform to the essential idea and clinical application requirements of traditional Chinese medicine dialectical treatment. Summary of the Invention
[0005] This invention provides a novel method and system for recommending traditional Chinese medicine herbs based on co-occurrence feature enhancement, in order to solve the problems of low accuracy and poor interpretability in existing herbal recommendation methods.
[0006] To achieve the above objectives, the present invention employs the following technical solution:
[0007] In a first aspect, the present invention provides a novel method for recommending traditional Chinese medicine herbs based on co-occurrence feature enhancement, comprising: S1. Obtain TCM diagnosis and treatment data, extract patient symptoms and prescription herbal information from the TCM diagnosis and treatment data, construct a symptom-herbal co-occurrence matrix based on the symptom-herbal co-occurrence matrix, calculate the point mutual information between symptoms and herbs based on the symptom-herbal co-occurrence matrix, map the point mutual information into an interaction feature matrix, and generate a point mutual information enhanced feature vector. S2. Input the point mutual information enhanced feature vector into a multi-layer neural network to obtain symptom aggregation features. Based on the symptom aggregation features, query a preset syndrome embedding matrix to obtain potential syndrome semantic features. Based on the potential syndrome semantic features, query a preset treatment method embedding matrix to obtain preliminary potential treatment method features. S3. Encode the symptom aggregation features into the mean and variance distribution of the latent semantic space, and obtain latent variables using reparameterized sampling. Decode the latent variables into potential treatment increments, and fuse the potential treatment increments with the preliminary potential treatment features to obtain the fused treatment features. S4. Using the fused treatment features as the query vector and the symptom aggregation features as the key vector and value vector, the attention weights are calculated through a cross-attention mechanism and weighted fusion is performed to obtain a symptom-aware treatment semantic representation. S5. Project the symptom aggregation features and the symptom-aware treatment semantic representation to a unified contrast space and normalize them. Calculate the similarity matrix between the two and calculate the contrast loss based on the similarity matrix. Construct the total loss function of the TCM herbal medicine recommendation model based on the contrast loss. Train the TCM herbal medicine recommendation model using the total loss function to obtain the trained TCM herbal medicine recommendation model. S6. The symptom aggregation features, the potential syndrome semantic features, and the symptom-aware treatment semantic representation are concatenated to obtain multimodal fusion features. The multimodal fusion features are mapped to the herbal embedding space, and the prediction confidence of each candidate herbal medicine is calculated based on the trained TCM herbal medicine recommendation model. The set of herbs with the highest confidence is output as the recommendation result according to the Top-K strategy.
[0008] Optionally, in S1, a symptom-herb co-occurrence matrix is constructed, and point mutual information between symptoms and herbs is calculated based on the symptom-herb co-occurrence matrix, including: Construct a sparse symptom matrix based on the symptom set S and the herbal medicine set H. X sym Herbal Label Matrix Y herb ; Calculate the co-occurrence matrix of symptoms and herbs. C = · Y herb ; Calculate the joint probability based on the co-occurrence matrix. p ij and marginal probability p i 、p j The calculation satisfies the following relationship: p ij = + ,p i = + ,p j = + ; In the formula, p ij Indicates symptoms i with herbs j The joint probability, Represents the total number of samples. C ij Indicates symptoms i with herbs j The number of times they co-occur. Represents a local minimum constant. p i Indicates symptoms i The marginal probability of occurrence p j Indicates herbs j The marginal probability of occurrence Represents the symptom sparse matrix. i Row elements, Represents the herbal tag matrix of the first... j Row elements, C This represents a symptom-herb co-occurrence matrix; Calculate the normalized point mutual information matrix (PMI) that satisfies the following relationship: PMI = ; In the formula, PMI raw = log( p ij ) - log( p i ) - log( p j ), PMI raw Let be the original point mutual information value of the symptom-herb matrix, and max and min be the maximum and minimum values in the PMI matrix, respectively.
[0009] Optionally, in S1, mapping the point mutual information into an interaction feature matrix to generate a point mutual information enhanced feature vector includes: Calculate the interaction feature matrix F interact = X sym · PMI ; The sparse vector of the symptoms X sym With the interaction feature matrix F interact By concatenating the features, we obtain the point mutual information enhanced feature vector. X aug = Concat( X sym , F interact ); In the formula, F interact This represents the interaction feature matrix, and Concat represents the vector concatenation operation. X aug The feature vector represents the mutual information enhancement of points.
[0010] Optionally, in S2, the point mutual information enhanced feature vector is input into a multi-layer neural network to obtain symptom aggregation features. Based on the symptom aggregation features, a preset syndrome embedding matrix is queried to obtain potential syndrome semantic features, including: The point mutual information enhanced feature vectors are mapped to symptom aggregate features through the symptom embedding layer of a multi-layer neural network. h sym : h sym = BN1(MLP sym ( X aug · W e_sym )); In the formula, h sym Indicates symptom aggregation characteristics, W e_sym The weight matrix of the symptom embedding layer is represented by the MLP. sym The multilayer perceptron representing symptom processing, where BN1 represents a composite layer containing linear transformation, batch normalization, and activation functions, X aug Represents the feature vector with enhanced point mutual information; Based on the aforementioned symptom aggregation features h sym Query syndrome embedding matrix E syn The symptom response weights are obtained. A syn = h sym · E syn T ; The symptom embedding matrix is weighted according to the symptom response weights to obtain a weighted symptom semantic vector. v syn = A syn · E syn ; The aggregated symptom features are concatenated with the weighted syndrome semantic vector and normalized to obtain the latent syndrome semantic features. h syn = BN2(Concat (h sym , v syn )); In the formula, E syn Represents the latent symptom embedding matrix. A syn This indicates the symptom response to a query about syndromes. v syn This represents the weighted semantic vector of the syndrome, and BN2 represents the second composite normalization layer. h syn This represents the semantic features of potential symptoms.
[0011] Optionally, in S2, based on the semantic features of the potential syndrome, a preset treatment method embedding matrix is queried to obtain preliminary potential treatment method features, including: Based on the semantic features of the potential symptoms h syn Query treatment embedding matrix E treat Obtain the treatment response weightA treat = h syn · E treat T ; The weighted semantic vector of the treatment method is obtained by weighting the treatment method embedding matrix according to the treatment method response weight. v treat = A treat · E treat ; The weighted symptom semantic vector v syn With the weighted governance semantic vector v treat By splicing the data and mapping it through a multilayer perceptron, preliminary potential treatment features are obtained. = MLP treat (Concat( v syn , v treat )); In the formula, Indicates preliminary potential treatment characteristics. E treat Represents the embedding matrix of potential solutions. A treat This indicates a response to a query about syndrome-based treatment. v syn This represents a weighted semantic vector of symptoms. v treat This represents the weighted semantic vector of the governance method, MLP treat A multi-layered sensory machine representing the treatment method.
[0012] Optionally, in S3, the symptom aggregation features are encoded as the mean and variance distributions of the latent semantic space, and latent variables are obtained using reparameterized sampling. The latent variables are decoded as potential treatment increments, and the potential treatment increments are fused with the preliminary potential treatment features to obtain fused treatment features, including: The mean vector and log-variance are calculated using the encoder network: = · h sym + ; 2 = · h sym + ; In the formula, The mean vector representing the distribution of the latent semantic space. 2 Represents the logarithmic variance. h sym Indicates symptom aggregation characteristics, This represents the weight matrix used for mean calculation. This represents the bias vector used in the mean calculation. The weight matrix represents the variance calculation. Represents the bias vector for variance calculation; Using reparameterization techniques to sample latent variables z: z= +e ·exp(0.5· 2 ), e ~ N (0, I ); Generate potential healing increments through the decoder. = W dec z + b dec ; The potential healing method increment is fused with the preliminary potential healing method feature to obtain the fused healing method feature. = + ; In the formula, z This represents the latent variables obtained from sampling. e For random noise that follows a standard normal distribution, W dec z 、 b dec These are the weights and biases of the decoder, respectively. For the potential healing increment generated by the decoder, The characteristics of the integrated treatment method This indicates the initial potential characteristics of a treatment method.
[0013] Optionally, in S4, using the fused treatment features as the query vector and the symptom aggregation features as the key and value vectors, attention weights are calculated through a cross-attention mechanism and then weighted and fused to obtain a symptom-aware treatment semantic representation, including: Define query vector Q = h treat key vector K = h sym value vector V = hsym ; Calculate attention weights and perform weighted fusion: Attention Q , K , V = softmax( )· V ; In the formula, Attention(·) represents the attention calculation function. d k is the scaling factor for the key vector dimension, and softmax is the normalization exponential function. h treat The characteristics of the integrated treatment method h sym Indicates symptom aggregation characteristics; By fusing the attention output with the original treatment features and applying an activation function, a semantic representation of the symptom-aware treatment is obtained: = ReLU( h treat + Attention Q , K , V )); in, This represents the semantic representation of symptom-aware treatment methods, with ReLU as the activation function.
[0014] Optionally, in S5, the symptom aggregation features and the symptom-aware treatment semantic representation are projected onto a unified contrast space and normalized, respectively. A similarity matrix between the two is calculated, and a contrast loss is calculated based on the similarity matrix. A total loss function for the TCM herbal medicine recommendation model is constructed based on the contrast loss. The TCM herbal medicine recommendation model is trained using the total loss function to obtain the trained TCM herbal medicine recommendation model, including: Aggregate symptom features h sym Semantic representation of governance methods Project them separately into the contrast space and normalize them: z sym = , z treat = ; Where Proj represents a projection head network containing linear layers and activation functions, || · || indicates L2 norm normalization. z sym This represents the normalized symptom comparison feature vector. z treatThis represents the normalized feature vector of treatment method comparison; Calculate the similarity matrix Sim = ; Based on the similarity matrix and sample paired labels, the contrast loss is calculated. L contrast = CrossEntropy( Sim , Labels ); in, Sim Represents the similarity matrix. Indicates the temperature coefficient. Labels This represents the paired label matrix between samples, and CrossEntropy is the cross-entropy loss function; Based on the contrastive loss, the KL divergence loss of the variational autoencoder during the encoding process, and the binary cross-entropy loss, a total loss function for the TCM herbal medicine recommendation model is constructed, wherein the total loss function satisfies the following relationship: L total = L BCE + l 1 L VAE + l 2 L contrast ; In the formula, L total Represents the total loss function. L BCE Represents the binary cross-entropy loss. L VAE This represents the KL divergence loss of the variational autoencoder. l 1. l 2 represents the weighting coefficient; Substitute the total loss function into the TCM herbal medicine recommendation model to complete the training of the TCM herbal medicine recommendation model, and obtain the trained TCM herbal medicine recommendation model.
[0015] Optionally, in S6, the symptom aggregation features, the potential syndrome semantic features, and the symptom-aware treatment semantic representation are concatenated to obtain multimodal fusion features. These multimodal fusion features are mapped to the herbal embedding space, and the predicted confidence of each candidate herb is calculated based on the trained TCM herbal recommendation model. The set of herbs with the highest confidence is output as the recommendation result according to the Top-K strategy, including: Concatenating multi-level semantic features h all = Concat( h sym , hsyn , ); The multimodal fusion features are mapped to the herbal embedding space, and the multimodal fusion features mapped to the herbal embedding space are input into the trained TCM herbal recommendation model to obtain the prediction score: Score herb = BN3( h all )· ; in, h all To splice together the multimodal features of symptoms, syndromes, and treatments, E herb Embedded matrix for herbs, Score herb The predicted scores for each candidate herb are represented by BN3, which is the third composite normalization layer. h sym Indicates symptom aggregation characteristics, h syn Indicates the semantic features of potential symptoms. This is a semantic representation of symptom-aware treatment methods. Based on the predicted scores, the Top-K strategy is used to output the K herbs with the highest confidence level as the recommendation results.
[0016] Secondly, embodiments of this application provide a novel traditional Chinese medicine herbal medicine recommendation system based on co-occurrence feature enhancement, characterized in that it includes a processor and a memory; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the steps of the method described in any one of the first aspects.
[0017] Beneficial effects: This invention provides a novel TCM herbal medicine recommendation method based on co-occurrence feature enhancement. It utilizes PMI to construct semantically enhanced features, integrating global co-occurrence information into the model, effectively addressing the problem of insufficient feature mining caused by data sparsity and improving recommendation accuracy. By introducing a variational autoencoder to simulate TCM reasoning logic and generate continuous latent semantics, the interpretability and robustness of the model are significantly enhanced. Furthermore, by combining cross-attention mechanisms and contrastive learning, structured alignment of the symptom and treatment semantic spaces and adaptive attention to key symptoms are achieved, solving the semantic gap problem and ensuring the accuracy and clinical applicability of the recommendation results. Attached Figure Description
[0018] Figure 1 A flowchart illustrating a novel traditional Chinese medicine herbal recommendation method based on co-occurrence feature enhancement, according to a preferred embodiment of the present invention; Figure 2This is a schematic diagram of the structure of a novel traditional Chinese medicine herbal recommendation device based on co-occurrence feature enhancement, according to a preferred embodiment of the present invention. Figure 3 This is a schematic diagram of the structure of a novel traditional Chinese medicine herbal medicine recommendation device based on co-occurrence feature enhancement, which is a preferred embodiment of the present invention. Detailed Implementation
[0019] The technical solution of the present invention will be clearly and completely described below. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0020] Unless otherwise defined, the technical or scientific terms used in this invention shall have the ordinary meaning understood by one of ordinary skill in the art to which this invention pertains. The terms "first," "second," and similar terms used in this invention do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Similarly, the terms "an" or "a" and similar terms do not indicate a quantity limitation, but rather indicate the presence of at least one. The terms "connected" or "linked" and similar terms are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. "Up," "down," "left," "right," etc., are used only to indicate relative positional relationships; when the absolute position of the described object changes, the relative positional relationship also changes accordingly.
[0021] Example 1 Please see Figure 1 This application provides a novel method for recommending traditional Chinese medicine herbs based on co-occurrence feature enhancement, comprising: S1. Construction of co-occurrence matrix and PMI semantic enhancement features: Obtain TCM diagnosis and treatment data, extract patient symptoms and prescription herbal information, construct symptom-herbal co-occurrence matrix, calculate pointwise mutual information (PMI) between symptoms and herbs to quantify the correlation strength between the two, map the PMI matrix into an interaction feature matrix, and concatenate it with the original symptom sparse vector to generate PMI enhanced feature vector. S2. Multi-layer semantic mapping network: Construct a multi-layer neural network, including a symptom embedding layer, a potential syndrome semantic layer, and a potential treatment semantic layer, which correspond to the logical hierarchy of "symptom-syndrome-treatment" in traditional Chinese medicine reasoning, respectively; Input the PMI enhanced feature vector into the multi-layer neural network, and map it to different semantic spaces through the embedding layer and the multilayer perceptron (MLP) module. S3, Variational Latent Space Generation Module, introduces a Variational Autoencoder (VAE) structure to encode the aggregated symptom features into the mean and variance distribution of the latent semantic space; latent variables are obtained by reparameterized sampling, and latent treatment features are generated by the decoder to form a latent semantic representation with continuous distribution characteristics; S4. Cross-attention fusion mechanism: The cross-attention mechanism is used to realize the dynamic interaction between symptom and treatment semantics. The potential treatment features are used as query vectors, and the symptom features are used as key vectors and value vectors to calculate attention weights and fuse them in a weighted manner to generate a symptom-aware treatment semantic representation, so as to realize the adaptive attention of treatment to key symptoms. S5. Contrast semantic alignment to construct a TCM herbal medicine recommendation model. Project the symptom aggregation features and the symptom-aware treatment semantic representations onto a unified contrast space and normalize them. Calculate the similarity matrix between the two and calculate the contrast loss based on the similarity matrix. Construct the total loss function of the TCM herbal medicine recommendation model based on the contrast loss. Train the TCM herbal medicine recommendation model using the total loss function to obtain the trained TCM herbal medicine recommendation model. S6. Herbal Recommendation Generation: Symptom aggregation features, potential syndrome semantic features, and symptom-aware treatment semantic vectors are concatenated and fused. The results are mapped to the herbal embedding space through the fully connected layer of the trained TCM herbal recommendation model. Based on the trained TCM herbal recommendation model, the prediction confidence of each candidate herb is calculated. A Top-K screening strategy is used to output the set of herbs with the highest confidence, forming the final personalized recommendation result.
[0022] In the above embodiments, by utilizing PMI to construct semantically enhanced features and integrating global co-occurrence information into the model, the problem of insufficient feature mining caused by data sparsity is effectively solved, thus improving recommendation accuracy. By introducing a variational autoencoder to simulate the reasoning logic of traditional Chinese medicine and generating continuous latent semantics, the interpretability and robustness of the model are significantly enhanced. Furthermore, by combining cross-attention mechanisms and contrastive learning, structured alignment of the semantic space of symptoms and treatments and adaptive attention to key symptoms are achieved, solving the semantic gap problem and ensuring the accuracy and clinical applicability of the recommendation results.
[0023] Optionally, in S1, the construction process of the PMI enhanced feature vector is as follows: Define the symptom set. S Herbal Collection H For those containing N Construct a sparse symptom matrix from a dataset of records. X sym Herbal Label Matrix Y herb ,in X sym Multi-fever coding for symptomsY herb Encode the multi-thermal activity of herbs; calculate the co-occurrence matrix of symptoms and herbs. C = · Y herb And calculate the joint probability. p ij and marginal probability p i , p j The formula is as follows: p ij = + ,p i = + ,p j = + ; in, C ij Indicates symptoms i with herbs j The number of times they co-occur. C i and C j These represent the row summation and column summation of the co-occurrence matrix, respectively. To prevent the minima of a constant with a denominator of zero, the normalized point mutual information matrix (PMI) is calculated using the following formula: PMI raw = log( p ij ) - log( p i ) - log( p j ); PMI = ; in, PMI raw The original point mutual information values are given, and max and min are the maximum and minimum values in the PMI matrix, respectively. The symptom interaction features are calculated using the PMI matrix and concatenated with the original symptom vector to obtain the enhanced feature vector. Xaug : Finteract = X sym · PMI ; X aug = Concat( X sym , F interact ); in, F interact This represents the symptom interaction feature matrix, and Concat represents the vector concatenation operation.
[0024] Optionally, in S2, the specific calculation process of the multi-layer semantic mapping network is as follows: The enhanced feature vector mapping yields the symptom aggregation features. h sym : h sym = BN1(MLP sym ( X aug · W e_sym )); in, W e_sym The weight matrix of the symptom embedding layer is represented by the MLP. sym The multilayer perceptron used for symptom processing is represented by BN1, which represents a composite layer containing linear transformation, batch normalization, and activation functions; the syndrome embedding matrix is queried using symptom aggregation features. E syn Symptom characteristics were obtained. h syn : A syn = h sym · E syn T ; v syn = A syn · E syn ; h syn = BN2(Concat (h sym , v syn )); in, Esyn Represents the latent symptom embedding matrix. A syn This indicates the symptom response to a query about syndromes. v syn represents the weighted semantic vector of the syndrome, and BN2 represents the second composite normalization layer; By querying the treatment method embedding matrix Etreat using syndrome features, preliminary potential treatment method features are obtained. : A treat = h syn · E treat T ; v treat = A treat · E treat ; = MLP treat (Concat( v syn , v treat )); in, E treat Represents the embedding matrix of potential solutions. A treat This indicates a response to a query about syndrome-based treatment. v treat This represents the weighted semantic vector of the governance method, MLP treat A multi-layered sensory machine representing the treatment method.
[0025] In this embodiment, the syndrome embedding matrix is a learnable matrix that maps abstract syndrome concepts in traditional Chinese medicine, such as wind-cold common cold, yin deficiency with fire excess, and phlegm-dampness obstruction, into low-dimensional, dense, and continuous numerical vectors. Each syndrome corresponds to a row and column vector in the matrix, which is the syndrome embedding vector. The numerical features of the vector represent the semantic information, pathogenesis features, and correlation with other syndromes, symptoms, and treatments of the syndrome.
[0026] Similarly, the treatment embedding matrix is a learnable matrix that maps specific treatment strategies in traditional Chinese medicine, such as relieving exterior syndromes with pungent and warm herbs, nourishing yin and reducing fire, drying dampness and resolving phlegm, and promoting blood circulation and removing blood stasis, into low-dimensional, dense, and continuous numerical vectors. Each treatment corresponds to a row and column vector in the matrix, which is the treatment embedding vector. The numerical features of the vector represent the semantic information, treatment principles, and correlation with syndromes and herbs of the treatment.
[0027] Optionally, in S3, the calculation formula for generating the variational latent space is as follows: Syndrome aggregation features are obtained through encoder network h sym Mapped to latent distribution parameters: = · h sym + ; 2 = · h sym + ; in, The mean vector representing the distribution of the latent semantic space. 2 Represents the logarithmic variance. , and , These are the corresponding weight matrices and biases; latent variables are sampled using reparameterization techniques. z And integrate to generate potential healing characteristics: z= +e ·exp(0.5· 2 ), e ~ N (0, I ); = W dec z + b dec ; = + ; in, z This represents the latent variables obtained from sampling. e For random noise that follows a standard normal distribution, W dec , b dec For the weights and biases of the decoder, For the potential healing increment generated by the decoder, The characteristics of the fused treatment method are defined; simultaneously, the regularization loss LKL of the VAE is calculated: LKL = -0.5·mean(1 + 2- 2 - exp( 2 )); Here, LKL represents the KL divergence loss, which is used to constrain the potential distribution.
[0028] Optionally, in S4, the cross-attention fusion mechanism queries symptom features using treatment features, as shown in the following formula: Define query vector Q Key vector K Sum value vector V : Q = h treat , K = h sym , , V = h sym ; in, Q Derived from the characteristics of treatment methods, K and V Derived from symptom aggregation features; multi-head attention weights are calculated and residuals are fused to obtain the final treatment feature. : Attention Q , K , V = softmax( )· V ; = ReLU( h treat + Attention Q , K , V )); in, d k is the scaling factor for the key vector dimension, softmax is the normalization exponential function, and ReLU is the activation function.
[0029] Optionally, in S5, the contrastive semantic alignment and loss function calculation are as follows: Aggregate symptom features h sym Characteristics of the ultimate cure Project onto contrast space and normalize: z sym = , z treat = ; Where Proj represents a projection head network containing linear layers and activation functions, || · || indicates L2 norm normalization. z sym and z treat Normalized feature representation; calculate contrastive loss. L contrast : Sim = ; L contrast = CrossEntropy( Sim , Labels ); in, Sim Represents the similarity matrix. Indicates the temperature coefficient. Labels This represents the paired label matrix between samples, and CrossEntropy is the cross-entropy loss function; Jointly optimize herb prediction loss and semantic alignment loss during model training: the total loss function of model training. L total It consists of recommendation task loss, VAE regularization loss, and contrastive loss: L total = L BCE + l 1 L VAE + l 2 L contrast ; in, L BCE For binary cross-entropy loss, L VAE For the KL divergence loss of the variational autoencoder, l 1, l 2 represents the weighting coefficient.
[0030] Optionally, in S6, the specific steps for generating the herbal recommendations are as follows: By fusing multi-level semantic features and mapping them through a fully connected layer, the herbal prediction score is obtained. h all = Concat( h sym , h syn , ); Score herb= BN3( h all )· ; in, h all To splice together the multimodal features of symptoms, syndromes, and treatments, E herb Embedded matrix for herbs, Score herb The predicted scores for each candidate herb are used; the Top-K strategy is employed to select the K herbs with the highest scores as the recommended set.
[0031] In the above embodiment, the model first calculates the predicted confidence scores of all candidate herbs, then sorts them from highest to lowest confidence, and selects the top K herbs with the highest scores as the final recommendation set output. During this process, the model first calculates a matching score for each candidate herb to indicate whether the herb is suitable for the current symptoms. Then, all herbs are sorted from highest to lowest score, and only the top K herbs are retained as the final herb combination recommended to the patient. Here, K is a preset value, which can be set to a desired positive integer as needed.
[0032] Example 2 like Figure 2 As shown, the present invention also provides a novel TCM herbal medicine recommendation device based on co-occurrence feature enhancement. The schematic diagram shows the structure of the novel TCM herbal medicine recommendation device based on co-occurrence feature enhancement provided by the present invention. The novel TCM herbal medicine recommendation device 100 based on co-occurrence feature enhancement of the present invention includes a co-occurrence matrix and PMI semantic enhancement feature construction module 11, a multi-layer semantic mapping network module 12, a variational latent space generation module 13, a cross-attention fusion mechanism module 14, a contrastive semantic alignment module 15, and a herbal medicine recommendation generation module.
[0033] The co-occurrence matrix and PMI semantic enhancement feature construction module 11 acquires TCM diagnosis and treatment data, extracts patient symptom and prescription herbal information, constructs a symptom-herbal co-occurrence matrix, calculates point mutual information (PMI) between symptoms and herbs to quantify the correlation strength between them, maps the PMI matrix into an interaction feature matrix, and concatenates it with the original symptom sparse vector to generate a PMI enhanced feature vector. The method used in the co-occurrence matrix and PMI semantic enhancement feature construction module 11 can be referred to S1 in Example 1, and will not be repeated here. The multi-layer semantic mapping network module 12 constructs a multi-layer neural network, including a symptom embedding layer, a potential syndrome semantic layer, and a potential treatment semantic layer, which respectively correspond to the "symptom-syndrome-treatment" logical hierarchy in traditional Chinese medicine reasoning. The PMI-enhanced feature vector is input into the multi-layer neural network and mapped to different semantic spaces through the embedding layer and the multi-layer perceptron (MLP) module. The method of the multi-layer semantic mapping network module 12 can be referred to S2 in Embodiment 1, and will not be elaborated here. The variational latent space generation module 13 introduces a variational autoencoder (VAE) structure to encode the symptom aggregation features into a mean and variance distribution of the latent semantic space; latent variables are obtained using reparameterized sampling, and latent treatment features are generated through a decoder to form a latent semantic representation with continuous distribution characteristics. The method of the semantic mapping module 13 can be referred to S3 in Example 1, and will not be described in detail here.
[0034] The cross-attention fusion mechanism module 14 employs a cross-attention mechanism to achieve dynamic interaction between symptom and treatment semantics. It uses potential treatment features as query vectors and symptom features as key and value vectors to calculate attention weights and perform weighted fusion, generating a symptom-aware treatment semantic representation. This enables adaptive attention of treatments to key symptoms. The cross-attention fusion mechanism module 14 can be referenced from S4 in Example 1 and will not be elaborated upon here.
[0035] The contrast semantic alignment module 15 maps symptom features and treatment semantic features to a unified contrast space through a projection layer, calculates the cosine similarity matrix between samples, and uses a temperature-regulated cross-entropy loss function to maximize the similarity of positive sample pairs and minimize the similarity of negative sample pairs, thereby achieving structured alignment and consistency optimization of the symptom-treatment semantic space. The contrast semantic alignment module 15 can be referred to as S5 in Example 1, and will not be described in detail here.
[0036] The herbal recommendation generation module 16 concatenates and fuses symptom aggregation features, potential syndrome semantic features, and symptom-aware treatment semantic vectors. This data is then mapped to the herbal embedding space through a fully connected layer. The prediction confidence of each candidate herb is calculated, and a Top-K selection strategy is used to output the set of herbs with the highest confidence, forming the final personalized recommendation result. The herbal recommendation generation module 16 can be referenced from S6 in Example 1, and will not be elaborated upon here.
[0037] Example 3 This invention also provides a novel traditional Chinese medicine herbal recommendation device based on co-occurrence feature enhancement. Please refer to the following references. Figure 3This is a schematic diagram of the structure of the novel TCM herbal medicine recommendation device based on co-occurrence feature enhancement provided by the present invention. The novel TCM herbal medicine recommendation device 200 based on co-occurrence feature enhancement of the present invention includes a memory 21, a processor 22, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it performs the steps of the novel TCM herbal medicine recommendation method based on co-occurrence feature enhancement described above.
[0038] It is understood that the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, electronic device, or network device, etc.) to execute all or part of the steps of the method described in this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0039] Example 4 The prediction accuracy of the novel TCM herbal medicine recommendation method based on co-occurrence feature enhancement was evaluated using cross-validation, as follows: To verify the effectiveness of the proposed Traditional Chinese Medicine Herbal Recommendation Model (CFHR-TCM), this study conducted extensive experiments on two publicly available datasets (TCM1 and TCM2). The datasets were strictly divided into training, validation, and test sets in a 7:1:2 ratio. Specific statistics are as follows: the TCM1 dataset contains 33,765 samples, with 23,635 in the training set, 3,377 in the validation set, and 6,753 in the test set; the TCM2 dataset contains 26,360 samples, with 18,452 in the training set, 2,636 in the validation set, and 5,272 in the test set. Precision (K), recall (K), and F1 score (K) were used as evaluation metrics, measured at recommendation list cutoff values of K=5, 10, and 20, respectively. To eliminate errors caused by randomness and ensure the statistical significance of the results, all experiments were repeated 200 times independently, and the average values of each indicator were reported.
[0040] Table 1 presents the quantitative evaluation results of the model on the two datasets. The data shows that CFHR-TCM performs excellently across all key metrics. Specifically, on the TCM1 dataset, the model achieves a Precision@5 of 0.2398, a Recall@5 of 0.1646, and an F1-Score@5 of 0.1962; on the TCM2 dataset, performance is further improved, with Precision@5, Recall@5, and F1-Score@5 reaching 0.2893, 0.2068, and 0.2440, respectively. Compared to all baseline methods, CFHR-TCM demonstrates a significant performance advantage, validating the effectiveness of the co-occurrence feature enhancement and multi-layer semantic mapping mechanisms.
[0041] To further evaluate the prediction accuracy and practicality of the novel TCM herbal medicine recommendation method based on co-occurrence feature enhancement, this study employed a case study validation method. The specific process is as follows: First, the model is trained using known symptom-herb associations in the dataset. Second, the model predicts and generates a list of candidate herbs by inputting a set of symptoms from test cases. Finally, the predictions are compared with actual prescriptions. In the case demonstration, herbs marked in red indicate that the model's recommendations are consistent with the ground truth, meaning they are correct.
[0042] As can be seen from Table 2, for an actual prescription consisting of ten herbs, the first ten suggested herbs in CFHR-TCM matched eight of the references, resulting in an accuracy of 80%.
[0043] Table 1: Cross-validation results of CFHR-TCM with other methods on two datasets
[0044] Table 2: Experimental Results of CFHR-TCM Case Study under Dataset TCM2
[0045] The preferred embodiments of the present invention have been described in detail above. It should be understood that those skilled in the art can make numerous modifications and variations based on the concept of the present invention without creative effort. Therefore, all technical solutions that can be obtained by those skilled in the art based on the concept of the present invention through logical analysis, reasoning, or limited experimentation on the basis of existing technology should be within the scope of protection defined by the claims.
Claims
1. A novel traditional Chinese medicine herb recommendation method based on co-occurrence feature enhancement, characterized in that, include: S1. Obtain TCM diagnosis and treatment data, extract patient symptoms and prescription herbal information from the TCM diagnosis and treatment data, construct a symptom-herbal co-occurrence matrix based on the symptom-herbal co-occurrence matrix, calculate the point mutual information between symptoms and herbs based on the symptom-herbal co-occurrence matrix, map the point mutual information into an interaction feature matrix, and generate a point mutual information enhanced feature vector. S2. Input the point mutual information enhanced feature vector into a multi-layer neural network to obtain symptom aggregation features. Based on the symptom aggregation features, query a preset syndrome embedding matrix to obtain potential syndrome semantic features. Based on the potential syndrome semantic features, query a preset treatment method embedding matrix to obtain preliminary potential treatment method features. S3. Encode the symptom aggregation features into the mean and variance distribution of the latent semantic space, and obtain latent variables using reparameterized sampling. Decode the latent variables into potential treatment increments, and fuse the potential treatment increments with the preliminary potential treatment features to obtain the fused treatment features. S4. Using the fused treatment features as the query vector and the symptom aggregation features as the key vector and value vector, the attention weights are calculated through a cross-attention mechanism and weighted fusion is performed to obtain a symptom-aware treatment semantic representation. S5. Project the symptom aggregation features and the symptom-aware treatment semantic representation to a unified contrast space and normalize them. Calculate the similarity matrix between the two and calculate the contrast loss based on the similarity matrix. Construct the total loss function of the TCM herbal medicine recommendation model based on the contrast loss. Train the TCM herbal medicine recommendation model using the total loss function to obtain the trained TCM herbal medicine recommendation model. S6. The symptom aggregation features, the potential syndrome semantic features, and the symptom-aware treatment semantic representation are concatenated to obtain multimodal fusion features. The multimodal fusion features are mapped to the herbal embedding space, and the prediction confidence of each candidate herbal medicine is calculated based on the trained TCM herbal medicine recommendation model. The set of herbs with the highest confidence is output as the recommendation result according to the Top-K strategy.
2. The novel Chinese herbal medicine recommendation method based on co-occurrence feature enhancement according to claim 1, characterized in that, In S1, a symptom-herb co-occurrence matrix is constructed, and point mutual information between symptoms and herbs is calculated based on the symptom-herb co-occurrence matrix, including: Construct a sparse symptom matrix based on the symptom set S and the herbal medicine set H. X sym Herbal Label Matrix Y herb ; Calculate the co-occurrence matrix of symptoms and herbs. C = · Y herb ; Calculate the joint probability based on the co-occurrence matrix. p ij and marginal probability p i 、p j The calculation satisfies the following relationship: p ij = + ,p i = + ,p j = + ; In the formula, p ij Indicates symptoms i with herbs j The joint probability, Represents the total number of samples. C ij Indicates symptoms i with herbs j The number of times they co-occur. Represents a local minimum constant. p i Indicates symptoms i The marginal probability of occurrence p j Indicates herbs j The marginal probability of occurrence Represents the symptom sparse matrix. i Row elements, Represents the herbal tag matrix of the first... j Row elements, C This represents a symptom-herb co-occurrence matrix; Calculate the normalized point mutual information matrix (PMI) that satisfies the following relationship: PMI = ; In the formula, PMI raw = log( p ij ) - log( p i ) - log( p j ), PMI raw Let be the original point mutual information value of the symptom-herb matrix, and max and min be the maximum and minimum values in the PMI matrix, respectively.
3. The novel TCM herbal medicine recommendation method based on co-occurrence feature enhancement according to claim 2, characterized in that, In S1, the point mutual information is mapped into an interaction feature matrix to generate a point mutual information enhanced feature vector, including: Calculate the interaction feature matrix F interact = X sym · PMI ; The sparse vector of the symptoms X sym With the interaction feature matrix F interact By concatenating the features, we obtain the point mutual information enhanced feature vector. X aug = Concat( X sym , F interact ); In the formula, F interact This represents the interaction feature matrix, and Concat represents the vector concatenation operation. X aug The feature vector represents the mutual information enhancement of points.
4. The novel Chinese herbal medicine recommendation method based on co-occurrence feature enhancement according to claim 1, characterized in that, In S2, the point mutual information enhanced feature vector is input into a multi-layer neural network for mapping to obtain symptom aggregation features. Based on the symptom aggregation features, a preset syndrome embedding matrix is queried to obtain potential syndrome semantic features, including: The point mutual information enhanced feature vectors are mapped to symptom aggregate features through the symptom embedding layer of a multi-layer neural network. h sym : h sym = BN1(MLP sym ( X aug · W e_sym )); In the formula, h sym Indicates symptom aggregation characteristics, W e_sym The weight matrix of the symptom embedding layer is represented by the MLP. sym The multilayer perceptron representing symptom processing, where BN1 represents a composite layer containing linear transformation, batch normalization, and activation functions, X aug Represents the feature vector with enhanced point mutual information; Based on the aforementioned symptom aggregation features h sym Query syndrome embedding matrix E syn The symptom response weights are obtained. A syn = h sym · E syn T ; The symptom embedding matrix is weighted according to the symptom response weights to obtain a weighted symptom semantic vector. v syn = A syn · E syn ; The aggregated symptom features are concatenated with the weighted syndrome semantic vector and normalized to obtain the latent syndrome semantic features. h syn = BN2(Concat (h sym , v syn )); In the formula, E syn Represents the latent symptom embedding matrix. A syn This indicates the symptom response to a query about syndromes. v syn This represents the weighted semantic vector of the syndrome, and BN2 represents the second composite normalization layer. h syn This represents the semantic features of potential symptoms.
5. The novel Chinese herbal medicine recommendation method based on co-occurrence feature enhancement according to claim 1, characterized in that, In S2, based on the semantic features of the potential syndrome, a preset treatment method embedding matrix is queried to obtain preliminary potential treatment method features, including: Based on the semantic features of the potential symptoms h syn Query treatment embedding matrix E treat Obtain the treatment response weight A treat = h syn · E treat T ; The weighted semantic vector of the treatment method is obtained by weighting the treatment method embedding matrix according to the treatment method response weight. v treat = A treat · E treat ; The weighted symptom semantic vector v syn With the weighted governance semantic vector v treat By splicing the data and mapping it through a multilayer perceptron, preliminary potential treatment features are obtained. = MLP treat (Concat( v syn , v treat )); In the formula, Indicates preliminary potential treatment characteristics. E treat Represents the embedding matrix of potential solutions. A treat This indicates a response to a query about syndrome-based treatment. v syn This represents a weighted semantic vector of symptoms. v treat This represents the weighted semantic vector of the governance method, MLP treat A multi-layered sensory machine representing the treatment method.
6. The novel Chinese herbal medicine recommendation method based on co-occurrence feature enhancement according to claim 1, characterized in that, In S3, the symptom aggregation features are encoded as the mean and variance distributions of the latent semantic space, and latent variables are obtained using reparameterized sampling. These latent variables are then decoded into potential treatment increments, and the potential treatment increments are fused with the preliminary potential treatment features to obtain fused treatment features, including: The mean vector and log-variance are calculated using the encoder network: = · h sym + ; 2 = · h sym + ; In the formula, The mean vector representing the distribution of the latent semantic space. 2 Represents the logarithmic variance. h sym Indicates symptom aggregation characteristics, This represents the weight matrix used for mean calculation. This represents the bias vector used in the mean calculation. The weight matrix represents the variance calculation. Represents the bias vector for variance calculation; Using reparameterization techniques to sample latent variables z: z= +ε ·exp(0.5· 2 ), ε ~ N (0, I ); Generate potential healing increments through the decoder. = W dec z + b dec ; The potential healing method increment is fused with the preliminary potential healing method feature to obtain the fused healing method feature. = + ; In the formula, z This represents the latent variables obtained from sampling. ε For random noise that follows a standard normal distribution, W dec z 、 b dec These are the weights and biases of the decoder, respectively. For the potential healing increment generated by the decoder, The characteristics of the integrated treatment method This indicates the initial potential characteristics of a treatment method.
7. The novel Chinese herbal medicine recommendation method based on co-occurrence feature enhancement according to claim 1, characterized in that, In S4, using the fused treatment features as the query vector and the symptom aggregation features as the key and value vectors, attention weights are calculated through a cross-attention mechanism and then weighted and fused to obtain a symptom-aware treatment semantic representation, including: Define query vector Q = h treat key vector K = h sym value vector V = h sym ; Calculate attention weights and perform weighted fusion: Attention( Q , K , V ) = softmax( )· V ; In the formula, Attention(·) represents the attention calculation function. d k is the scaling factor for the key vector dimension, and softmax is the normalization exponential function. h treat The characteristics of the integrated treatment method h sym Indicates symptom aggregation characteristics; By fusing the attention output with the original treatment features and applying an activation function, a semantic representation of the symptom-aware treatment is obtained: = ReLU( h treat + Warning ( Q , K , V )); in, This represents the semantic representation of symptom-aware treatment methods, with ReLU as the activation function.
8. The novel traditional Chinese medicine herbal recommendation method based on co-occurrence feature enhancement according to claim 1, characterized in that, In S5, the symptom aggregation features and the symptom-aware treatment semantic representation are projected onto a unified contrast space and normalized. A similarity matrix between the two is calculated, and a contrast loss is calculated based on the similarity matrix. A total loss function for the TCM herbal medicine recommendation model is constructed based on the contrast loss. The TCM herbal medicine recommendation model is trained using the total loss function to obtain the trained TCM herbal medicine recommendation model, including: Aggregate symptom features h sym Semantic representation of governance methods Project them separately into the contrast space and normalize them: z sym = , z treat = ; Where Proj represents a projection head network containing linear layers and activation functions, || · || indicates L2 norm normalization. z sym This represents the normalized symptom comparison feature vector. z treat This represents the normalized feature vector of treatment method comparison; Calculate the similarity matrix Sim = ; Based on the similarity matrix and sample paired labels, the contrast loss is calculated. L contrast = CrossEntropy( Sim , Labels ); in, Sim Represents the similarity matrix. Indicates the temperature coefficient. Labels This represents the paired label matrix between samples, and CrossEntropy is the cross-entropy loss function; Based on the contrastive loss, the KL divergence loss of the variational autoencoder during the encoding process, and the binary cross-entropy loss, a total loss function for the TCM herbal medicine recommendation model is constructed, wherein the total loss function satisfies the following relationship: L total = L BCE + λ 1 L VAE + λ 2 L contrast ; In the formula, L total Represents the total loss function. L BCE This represents the binary cross-entropy loss. L VAE This represents the KL divergence loss of the variational autoencoder. λ 1. λ 2 represents the weighting coefficient; Substitute the total loss function into the TCM herbal medicine recommendation model to complete the training of the TCM herbal medicine recommendation model, and obtain the trained TCM herbal medicine recommendation model.
9. The novel Chinese herbal medicine recommendation method based on co-occurrence feature enhancement according to claim 1, characterized in that, In S6, the symptom aggregation features, the potential syndrome semantic features, and the symptom-aware treatment semantic representation are concatenated to obtain multimodal fusion features. These multimodal fusion features are mapped to the herbal embedding space, and the predicted confidence of each candidate herb is calculated based on the trained TCM herbal recommendation model. The set of herbs with the highest confidence is output as the recommendation result according to the Top-K strategy, including: Concatenating multi-level semantic features h all = Concat( h sym , h syn , ); The multimodal fusion features are mapped to the herbal embedding space, and the multimodal fusion features mapped to the herbal embedding space are input into the trained TCM herbal recommendation model to obtain the prediction score: Score herb = BN3( h all )· ; in, h all To splice together the multimodal features of symptoms, syndromes, and treatments, E herb Embedded matrix for herbs, Score herb The predicted scores for each candidate herb are represented by BN3, which is the third composite normalization layer. h sym Indicates symptom aggregation characteristics, h syn Indicates the semantic features of potential symptoms. This is a semantic representation of symptom-aware treatment methods. Based on the predicted scores, the Top-K strategy is used to output the K herbs with the highest confidence level as the recommendation results.
10. A novel traditional Chinese medicine herbal medicine recommendation system based on co-occurrence feature enhancement, characterized in that, Including processor and memory; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the steps of the method according to any one of claims 1-9.