Intelligent traditional Chinese medicine prescription checking method based on knowledge graph

By building a knowledge map in the field of traditional Chinese medicine and combining the entity extraction model for traditional Chinese medicine prescription review, the problems of complexity of traditional Chinese medicine prescriptions and rigid review of existing rules have been solved, and intelligent review of traditional Chinese medicine prescriptions and improved the safety of drug use.

CN120183669APending Publication Date: 2025-06-20HENAN UNIV OF SCI & TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510276848.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-10
Publication Date
2025-06-20

AI Technical Summary

Technical Problem

Traditional Chinese medicine prescriptions are diverse and complex. The existing intelligent traditional Chinese medicine prescription review method relies on traditional rule review. It is too rigid and requires a lot of effort to build a rule database in the early stage, making it difficult to effectively convert unstructured data and semi-structured data into structured knowledge graphs.

Method used

The intelligent prescription review method of traditional Chinese medicine based on knowledge graph is adopted to construct the knowledge graph in the field of traditional Chinese medicine through entity extraction models, and the prescription compatibility relationship, dosage, special populations and alias are reviewed in combination with the knowledge graph.

Benefits of technology

It improves the accuracy and objectivity of traditional Chinese medicine prescription review, enhances the safety of medication, reduces the energy requirement for building a rule database, and realizes intelligent review of traditional Chinese medicine prescriptions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120183669A_ABST
    Figure CN120183669A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of traditional Chinese medicine application, and discloses a traditional Chinese medicine intelligent prescription checking method based on a knowledge graph, comprising the following steps: step S1, preparing data including Chinese herbal medicine related data, traditional Chinese medicine disease related data and symptom related data; s2, constructing an entity relation joint extraction model based on context feature enhancement and a multi-relation graph neural network; and S3, based on the entity relationship joint extraction model, constructing a knowledge graph, and realizing intelligent traditional Chinese medicine prescription examination. According to the traditional Chinese medicine intelligent prescription checking method based on the knowledge graph, the information of the traditional Chinese medicinal materials is obtained by using the entity relationship joint extraction model based on context feature enhancement and the multi-relationship graph neural network; the knowledge graph is constructed, the prescription examination function and method are expanded, and the method has important significance in assisting doctors in accuracy and objectivity of treating diseases in traditional Chinese medicine in real life.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of traditional Chinese medicine applications, and in particular to an intelligent traditional Chinese medicine prescription review method based on a knowledge graph. Background Art

[0002] Using intelligent information means to study the monarch-minister compatibility law of traditional Chinese medicine prescriptions, improve the traditional Chinese medicine service system, and enable traditional Chinese medicine to meet the current medical needs under the background of "Internet" is the current trend of traditional Chinese medicine development. However, there are also many difficulties in the research process of the distribution law of traditional Chinese medicine prescriptions. Traditional Chinese medicine prescriptions are diverse and complex, and different doctors may have different diagnosis and treatment methods. This leads to huge changes and differences between prescriptions. However, the levels of traditional Chinese medicine pharmacists vary, so an intelligent traditional Chinese medicine prescription review method is particularly important in terms of medication safety and other aspects.

[0003] For intelligent traditional Chinese medicine prescription review, it is very important to convert unstructured data and semi-structured data into a structured knowledge graph. The existing construction of knowledge graphs mainly relies on information extraction means, and the existing entity relationship extraction algorithms in the general field are not applicable in traditional Chinese medicine texts. Common traditional Chinese medicine prescription reviews include information such as dose review, contraindication review, and special population review. Most of the existing intelligent traditional Chinese medicine prescription review methods are based on traditional rule reviews, and rule reviews are too rigid and require a large amount of energy to build a rule database in the early stage.

[0004] Therefore, to solve the above problems, the present invention proposes an intelligent traditional Chinese medicine prescription review method based on a knowledge graph. The intelligent traditional Chinese medicine prescription review method combined with the knowledge graph constructs a knowledge graph of the traditional Chinese medicine field through entity extraction means, and combines the functions of the knowledge graph for reviewing prescription compatibility relationships, dose reviews, special population reviews, and alias reviews, which is of great significance for the intelligent development of traditional Chinese medicine and medication safety. Summary of the Invention

[0005] The purpose of the present invention is to provide an intelligent traditional Chinese medicine prescription review method based on a knowledge graph, which uses an entity relationship joint extraction model based on context feature enhancement and multi-relational graph neural network to obtain Chinese herbal medicine information; constructs a knowledge graph, expands the functions and methods of prescription review, and is of great significance for assisting doctors in the accuracy and objectivity of treating diseases with traditional Chinese medicine in real life.

[0006] To achieve the above purpose, the present invention provides an intelligent traditional Chinese medicine prescription review method based on a knowledge graph, including the following steps:

[0007] Step S1, prepare data, including data related to Chinese herbal medicines, data related to traditional Chinese medicine diseases, and data related to symptoms;

[0008] Step S2: Build an entity relationship joint extraction model based on context feature enhancement and multi-relation graph neural network;

[0009] Step S3: Build a knowledge graph based on the entity relationship joint extraction model to achieve intelligent prescription review in traditional Chinese medicine.

[0010] Preferably, in step S1, the specific process of data preparation is as follows:

[0011] Step S11: Build data related to Chinese herbal medicines, where the basic information of Chinese medicinal materials includes the four natures, five flavors, nature and flavor, meridian tropism, and functions of the medicines;

[0012] Step S12: Build data related to traditional Chinese medicine diseases, including disease causes and clinical manifestations;

[0013] Step S13: Build data related to symptoms, including standard symptom words and symptom word aliases.

[0014] Preferably, in step S2, the entity relationship joint extraction model based on context feature enhancement and multi-relation graph neural network is divided into four parts:

[0015] The first part is the text feature embedding layer, which is used to serialize the text and convert it into a vector representation rich in semantic information;

[0016] The second part is the feature extraction layer, which enhances the context features of the input text sequence, grasps both global and local features while extracting, and enriches the feature representation;

[0017] The third part is the graph neural network layer, which semantically enhances entities and relationships;

[0018] The fourth part is the entity relationship classification layer, which decodes entities, calculates all relationships, and obtains the final probability.

[0019] Preferably, the Bert pre-trained model is embedded in the text feature embedding layer to process text information in the field of traditional Chinese medicine. The specific process is as follows:

[0020] Step S211: For a given text sequence c = {c1, c2,... c i ,... c m}, the initial input u i of the i-th word is as follows:

[0021] u i = Bertc i (1);

[0022] Among them, c i represents the i-th word in the sequence; m represents the sequence length of the sentence;

[0023] Step S212. For a given relationship sequence \(d = \{d_1, d, \ldots d k , \ldots d n \}\), the initial input \(v' k \) of the \(k\)-th relationship is as follows:

[0024] v' k = Bertd k (2);

[0025] where \(d k \) represents the \(k\)-th relationship in the sequence; \(n\) represents the number of relationship types.

[0026] Preferably, the feature extraction layer consists of an attention gated recurrent unit module, a multi-head attention module, a residual network module, and a feed-forward neural network module; the feature extraction layer strengthens the context features of the input text sequence and enriches the feature representation. The specific process is as follows:

[0027] Step S221. The attention gated recurrent unit network consists of a double-layer GRU unit;

[0028] First, using the vector obtained from the text embedding layer as the input and the hidden layer encoding feature vectors at all times, the text feature matrix \(H\) of the feature extraction layer is obtained as follows:

[0029]

[0030] where \(h\) represents the hidden layer vector of the GRU unit; represents the hidden layer vector at time

[0031] Secondly, based on the text feature matrix \(H\) multiplied by the updatable weight matrix \(W g1 \), the attention weight matrix \(W ga \) is obtained. Then, the attention matrix \(W ga \) and the updatable weight matrix \(W g2 \) are multiplied to obtain the final attention matrix \(W att \) as follows:

[0032] W ga = H * W g1 (4);

[0033] W att = W ga * W g2 (5);

[0034] Then, \(W att \) is normalized using softmax to convert the attention matrix \(W att \) into the attention weight matrix \(W gw \) as follows:

[0035] W gw = softmaxW att (6);

[0036] Finally, perform matrix multiplication on H and W gw to obtain the matrix H' that highlights important text information, as follows:

[0037] H' = H * W gw (7);

[0038] Step S222, in the multi-head attention module, perform matrix multiplication on the matrix H' obtained from the attention gating recurrent unit module and the Query matrix W q , the Key matrix W k , and the Value matrix W v to obtain three feature matrices Q, K, and V, as follows:

[0039] Q = H' * W q (8);

[0040] K = H' * W k (9);

[0041] V = H' * W v (10);

[0042] Use softmax for normalization, and the normalized text sequence attention matrix is Z nr , Z nr_j is the calculation result of the j-th attention head, and Q j , K j , and V j are the Query, Key, and Value matrices corresponding to the j-th attention head respectively; the finally obtained Z nr , Z nr_j , are as follows:

[0043] Z nr = softmax(QK T V)(11);

[0044]

[0045] Use multi-head attention to concatenate the calculation results of multiple attention heads and multiply them with the initial weight matrix M0 for feature extraction to obtain the final extracted feature M a , as follows:

[0046] Z = [Z1, Z2,... Z j ,... Z I (13);

[0047] Zj = Z nr_j (14);

[0048] M a = ZM0(15);

[0049] Where I is the number of heads, and Z j is the attention weight matrix of the j-th head; Z is the attention weight matrix;

[0050] Step S223: The entity relationship joint extraction model uses a residual network module and normalizes the output of the multi-head attention module. The finally obtained matrix M after normalization is as follows:

[0051] M = H' + M a (16);

[0052] Step S224: Input the finally obtained matrix M into the feed-forward neural network module FFNN to obtain a text feature matrix M after one cycle. After N cycles, use Avgpool to perform average pooling on M out , and after N cycles, use Avgpool to perform average pooling on M out to obtain U', and propagate it to the graph neural network layer, as follows:

[0053] M out = M + FFNNM(17);

[0054] U' = AvgpoolM out (18);

[0055] Where M out represents the text feature matrix after one cycle; U' is the feature vector obtained after average pooling, which represents the global semantic information of the input sequence.

[0056] Preferably, the graph neural network layer enhances the semantics of entities and relationships. The specific process is as follows:

[0057] Step S231: Classify entity nodes into the same type of nodes, regard relationship nodes as another type of nodes, and regard one type of nodes as the main nodes. Calculate the influence coefficient of all adjacent nodes of the other type on the main nodes in turn, that is, all adjacent nodes of are connected and calculated to obtain the attention weight A i between node u' k and v' ik , as follows:

[0058] A ik = concat(W e u' i , W r v'k )(19);

[0059] Among them, W e and W r are the initial weight matrices of entity nodes and relationship nodes; u' i is an entity node; v' k is a relationship node;

[0060] Step S232, perform normalization processing on the attention weights between nodes u' i and v' k , and use the softmax function to reduce the influence of individual outliers on the entity-relationship joint extraction model to obtain A' ik , as follows:

[0061] A' ik = softmaxA ik (20);

[0062] Step S233, based on the neighboring node information, update the current node information u' i to obtain the updated node information m i , as follows:

[0063] m i = u' i + ∑ k∈N A' ik W gv v' k (21);

[0064] Among them, W gv is a trainable parameter;

[0065] Step S234, use the sigmoid activation function to calculate the weight g i to ensure the balance before and after node information update, as follows:

[0066] g i = sigmoidW g concat(u', m) i , m i (22);

[0067] Among them, W g is a trainable matrix parameter; g i is a weight parameter;

[0068]

[0069] Among them, represents the node representation after n layers of information transmission; n is the number of layers of the graph neural network; g i * mi represents the contribution of the updated node information to the final representation, and its importance is determined by g i ; (1 - g i ) * u′ i represents the contribution of the node information before the update to the final representation, and its importance is determined by 1 - g i ; when g i is close to 1, the updated information dominates; when g i is close to 0, the information before the update dominates;

[0070] Therefore, the simplified form of the entire update process is as follows:

[0071] G = GNN(u′ i , {v′ k} k∈N )(24);

[0072] where G is the global feature at the graph level; {v′ k} k∈N represents all the neighboring nodes of node u i ; GNN represents the process of updating the main node with neighboring nodes;

[0073] Step S235: Let the vector be h, the entity feature vector be u, and the relationship feature vector be v, and fuse the entity feature vector and the relationship feature vector into the GNN network in sequence. The entity-relationship joint extraction model uses a residual network connection to obtain the updated relationship vector representation and entity word vector representation. Then, the output result of the entity-relationship joint extraction model is as follows:

[0074]

[0075] where, represents the feature vectors of all nodes of type v in the neighbor set N i of node u′ n ; represents the feature vectors of all nodes of type u in the neighbor set N k of node v′ m ; represents the update of the entity node by the i-th relationship node v′ i under the condition that the entity node u is a neighboring node; represents the update of the relationship node by the k-th entity node u′ k under the condition that the relationship node v is a neighboring node.

[0076] Preferably, based on the enhancement of the semantic information of entities and relationships by the graph neural network layer and the obtained vector representations of entities and relationships, an entity tagger is then used to predict the initial and end positions of the entities and record them with numerical digits. The specific process is as follows:

[0077] The entity-relationship joint extraction model predicts the head entity position, uses "1" to represent the start and end positions of the entity, then calculates and predicts the position where the second entity appears when the head entity is determined according to the conditional probability, and records the start and end positions with the number "2". Finally, all entities are predicted and the start and end positions are marked as follows:

[0078]

[0079] Among them, and respectively represent the probability of the i-th word being the start position and end position of the entity; and respectively represent the learnable weight matrices for the start and end positions of the entity, which are used to map the hidden state to the score space of the boundary; and represent the bias terms, which are used to adjust the prediction baseline of the model for the boundary positions;

[0080] The objective function of the prediction result is as follows:

[0081]

[0082] Among them, Pe|x represents the prediction probability of the sentence sequence x for the entity e; e start and e end respectively represent the start position and end position of the entity e in the sentence; represents the probability that the i-th word is predicted as the entity boundary at position t; represents the true label of the i-th word at position t. When the sentence sequence x is true, the function I is 1; conversely, when the sentence sequence x is false, the function I is 0;

[0083] After obtaining the predicted entities, all possible categories of entity pairs are extracted, and the maximum likelihood value is calculated, that is, given two entities e1, e2 and possible relationships in the text sequence c to form a triple T(e1, r, e2), the maximum likelihood P is calculated as follows:

[0084] P = ∏ e1,r,e2∈T pe1,r,e2x(30).

[0085] Preferably, in step S3, based on the entity-relationship joint extraction model, a knowledge graph is constructed according to the obtained entities and relationships, and the dosage, taboos, standardization of medicinal material names, and medicinal pairs of the Chinese medicinal materials in the prescription are reviewed according to the information in the constructed knowledge graph;

[0086] For the prescribed prescription, the information of Chinese medicinal materials and dosage information therein are obtained, and knowledge fact information is obtained from the target knowledge graph through Cyber query statements, and the prescription review result is obtained according to the knowledge fact information.

[0087] Therefore, the present invention adopts the above-mentioned Chinese medicine intelligent prescription review method based on a knowledge graph, and uses an entity-relationship joint extraction model based on context feature enhancement and multi-relational graph neural network to obtain Chinese medicinal material information; constructs a knowledge graph, expands the functions and methods of prescription review, and is of great significance for assisting doctors to improve the accuracy and objectivity of treating diseases with traditional Chinese medicine in real life.

[0088] The technical solution of the present invention will be further described in detail below with reference to the drawings and embodiments. Description of the Drawings

[0089] Figure 1 is the prescription review flowchart of a Chinese medicine intelligent prescription review method based on a knowledge graph according to the present invention;

[0090] Figure 2 is the structural diagram of the entity-relationship joint extraction model of the present invention;

[0091] Figure 3 is the attention gated recurrent unit of the present invention;

[0092] Figure 4 is the entity tagger model diagram of the present invention;

[0093] Figure 5 is the knowledge graph example of the present invention;

[0094] Figure 6 is the dosage knowledge graph of the present invention;

[0095] Figure 7 is the system prescription review use case diagram in the embodiment of the present invention. Detailed Embodiments

[0096] The technical solution of the present invention will be further described below with reference to the drawings and embodiments.

[0097] As Figure 1 shown, a Chinese medicine intelligent prescription review method based on a knowledge graph includes the following steps:

[0098] Step S1, prepare data, including data related to Chinese herbal medicines, mutual data related to traditional Chinese medicine diseases, and data related to symptoms;

[0099] Step S2: Construct an entity-relationship joint extraction model based on context feature enhancement and multi-relationship graph neural network;

[0100] Step S3: Based on the entity-relationship joint extraction model, construct a knowledge graph to realize intelligent traditional Chinese medicine prescription review.

[0101] Embodiment

[0102] Step S1: Prepare data.

[0103] Step S11: Use the medicinal material information in the Chinese Pharmacopoeia (2020 Edition) as basic information to construct data related to Chinese herbal medicines, where the basic information of Chinese medicinal materials includes the four natures, five flavors, nature and flavor, meridian tropism, and functions of the medicine.

[0104] Step S12: Use the classification of traditional Chinese medicine diseases and syndromes released by the State Administration of Traditional Chinese Medicine to construct data related to traditional Chinese medicine diseases, including disease causes and clinical manifestations.

[0105] Step S13: Use standardized symptoms as basic description words for traditional Chinese medicine symptoms to construct symptom-related data, including standard symptom words and symptom aliases.

[0106] Step S2: Construct an entity-relationship joint extraction model based on context feature enhancement and multi-relationship graph neural network.

[0107] For the entity-relationship joint extraction model based on context feature enhancement and multi-relationship graph neural network, as Figure 2 shown, construct a knowledge graph, use the basic knowledge graph to conduct basic reviews on drug dosage, taboos, populations, compatibility, and drug names. Under the same training data, the entity-relationship joint extraction model can achieve better performance and effects.

[0108] The entity-relationship joint extraction model is mainly divided into four parts. The first part is the text feature embedding layer, which is used to serialize the text from the Chinese Pharmacopoeia and convert it into a vector representation rich in semantic information; the second part is the feature extraction layer, which enhances the context features of the input text sequence, can grasp both global features and local features while extracting global features, and enriches the feature representation; the third part is the graph neural network layer, which semantically enhances entities and relationships; the fourth part is the entity-relationship classification layer, which mainly decodes entities, calculates all possible relationships, and obtains the final probability. Based on the entity-relationship joint extraction model, constructing a knowledge graph can better reflect the intelligence of traditional Chinese medicine prescription review.

[0109] Step S21: The text feature embedding layer serializes the text from the Chinese Pharmacopoeia and converts it into a vector representation rich in semantic information.

[0110] To obtain a vector representation rich in semantic information, a Bert pre-trained model is embedded in the text feature embedding layer to process text information in the field of traditional Chinese medicine. Among them, the pre-trained model is a set of model parameters that uses a large amount of unlabeled text data for self-supervised training to learn language knowledge. In the present invention, the text information includes two parts, one part is the text sequence from the Chinese Pharmacopoeia, and the other part is the relationship type defined by the present invention.

[0111] Step S211. For a given text sequence c = {c1, c2, … c i , … c m}, the initial input u i of the i-th word is as follows:

[0112] u i = Bertc i (1);

[0113] where c i represents the i-th word in the sequence; m represents the sequence length of the sentence.

[0114] Step S212. For a given relationship sequence d = {d1, d, … d k , … d n}, the initial input v′ k of the k-th relationship is as follows:

[0115] v′ k = Bertd k (2);

[0116] where d k represents the k-th relationship in the sequence; n represents the number of relationship types.

[0117] Step S22. The feature extraction layer strengthens the context features of the input text sequence, grasps local features while extracting global features, and enriches the feature representation.

[0118] To better extract the text sequence features of medicines, considering that the integrated Attention-GRU can better capture the local features of the medicinal materials information in the prescription, the Attention-GRU is stacked with a multi-head attention mechanism, a residual connection, and a feed-forward neural network module to form a feature extraction layer, as Figure 2 shown.

[0119] The feature extraction layer is composed of an attention gated recurrent unit (Attention-GRU) module, a multi-head attention (Multi-HeadAttention) module, a residual network (ResNet) module, and a feed-forward neural network (FeedForward) module.

[0120] Step S221, as Figure 3 shown, the attention gated recurrent unit network is composed of a double-layer GRU unit.

[0121] First, taking the vector obtained from the text embedding layer as the input, and using the hidden layer encoding feature vectors at all times, the text feature matrix H of the feature extraction layer is obtained, as follows:

[0122]

[0123] where h represents the hidden layer vector of the GRU unit; represents the hidden layer vector at time.

[0124] Secondly, based on the text feature matrix H multiplied by the updatable weight matrix W g1 , the attention weight matrix W ga is obtained, and then the attention matrix W ga is multiplied by the updatable weight matrix W g2 matrix to obtain the final attention matrix W att , as follows:

[0125] W ga = H * W g1 (4);

[0126] W att = W ga * W g2 (5);

[0127] Then, W att is normalized using softmax, and the attention matrix W att is converted into the attention weight matrix W gw , as follows:

[0128] W gw = softmaxW att (6);

[0129] Finally, H is multiplied by W gw to obtain the matrix H' that highlights important text information, as follows:

[0130] H' = H * W gw (7).

[0131] Step S222, in the multi-head attention module, the matrix H' obtained by Attention-GRU and the Query matrix W q , Key matrix W k , and Value matrix W v are multiplied to obtain three feature matrices Q, K, and V, as follows:

[0132] Q = H' * W q (8);

[0133] K = H′ * W k (9);

[0134] V = H′ * W v (10);

[0135] To make the gradient more stable and avoid the problem of reduced training efficiency caused by too small a gradient, softmax is used for normalization, and the normalized text sequence attention matrix is Z nr , Z nr_j is the calculation result of the j-th attention head, Q j , K j and V j are the Query, Key, and Value matrices corresponding to the j-th attention head respectively. The finally obtained Z nr , Z nr_j , are as follows:

[0136] Z nr = softmax(QK T )V(11);

[0137]

[0138] The multi-head attention is used to splice the calculation results of multiple attention heads and multiply them by the initial weight matrix M0 for feature extraction to obtain the final extracted feature M a , as follows:

[0139] Z = [Z1, Z2,... Z j ,... Z I (13);

[0140] Z j = Z nr_j (14);

[0141] M a = ZM0(15);

[0142] where I is the number of multi-heads, Z j is the attention weight matrix of the j-th head; Z is the attention weight matrix.

[0143] Step S223, the entity relationship joint extraction model uses a residual network module and normalizes the output of the multi-head attention module. The finally obtained matrix M is as follows:

[0144] M = H′ + M a (16);

[0145] Step S224: Input the finally obtained matrix M into the feedforward neural network module FFNN to obtain a text feature matrix M after one cycle. out , after N cycles, use Avgpool on M out to perform average pooling to obtain U', and propagate it to the graph neural network layer, as shown below:

[0146] M out = M + FFNNM(17);

[0147] U' = AvgpoolM out (18);

[0148] Among them, M out represents the text feature matrix after one cycle; U′ is the feature vector obtained after average pooling, which characterizes the global semantic information of the input sequence.

[0149] Step S23: The graph neural network layer takes U′ obtained from the context-enhanced feature extraction layer and V′ = v′1, v′2, … v′ pre-trained by Bert n as the node inputs of the graph, and extracts the semantic information of entity nodes and relationship nodes respectively. Among them, the graph neural network is a GNN model, which obtains the dependency relationship in the graph by means of information transmission between nodes in the network. GNN updates the node state through the neighbors at any depth of the node, and this state can represent the state information.

[0150] Step S231: Classify entity nodes into the same type of nodes, regard relationship nodes as another type of nodes, regard one type of nodes as the main nodes, and calculate the influence coefficients of all adjacent nodes of the other type on the main nodes in turn, that is, all adjacent nodes of perform connection calculations to obtain the attention weight A i between node u′ k and v′ ik , as shown below:

[0151] A ik = concat(W e u′ i , W r v′ k )(19);

[0152] Among them, W e and W r are the initial weight matrices of entity nodes and relationship nodes; u′ i is the entity node; v′ k is the relationship node.

[0153] Step S232: Normalize the attention weights between nodes u' i and v' k using the softmax function to reduce the impact of individual outliers on the entity relation joint extraction model, obtaining A' ik as follows:

[0154] A' ik = softmax(A ik )(20);

[0155] Step S233: Multiply each weight by the corresponding neighboring node and accumulate to obtain all attention scores. Use a residual network to avoid gradient vanishing during training. Based on the neighboring node information, update the current node information u' i to obtain the updated node information m i as follows:

[0156] m i = u' i + ∑ k∈N A' ik W gv v' k (21);

[0157] where W gv is a trainable parameter.

[0158] Step S234: Calculate the weight g i using the sigmoid activation function to ensure the balance before and after node information update as follows:

[0159] g i = sigmoid(W g concat(u', m i , m i )(22);

[0160] where W g is a trainable matrix parameter; g i is a weight parameter.

[0161]

[0162] where represents the node representation after n layers of information passing; n is the number of layers of the graph neural network; g i * m i represents the contribution of the updated node information to the final representation, and its importance is determined by g i ; (1 - g i ) * u' i represents the contribution of the node information before update to the final representation, and its importance is determined by 1 - g iDecision; when g i is close to 1, the updated information dominates; when g i is close to 0, the information before the update dominates.

[0163] Therefore, the simplified form of the entire update process is as follows:

[0164] G = GNN(u′ i , {v′ k}) (24); k∈N

[0165] where G is the global feature at the graph level; {v′ k} k∈N represents all neighboring nodes of node u i ; GNN represents the process of updating the main node with neighboring nodes.

[0166] Step S235: Use the method of iterative fusion to semantically fuse the main node with all neighboring nodes. Assume the vector is h, the entity feature vector is u, the relationship feature vector is v, and fuse the entity feature vector and the relationship feature vector into the GNN network in sequence. The entity-relationship joint extraction model uses a residual network connection to obtain the updated relationship vector representation and entity word vector representation. Then, the output result of the entity-relationship joint extraction model is as follows:

[0167]

[0168] where represents the feature vectors of all nodes of type v in the neighbor set N i of node u′ n ; represents the feature vectors of all nodes of type u in the neighbor set N k of node v′ m ; represents the update of the entity node by the i-th relationship node v′ i under the condition that the entity node u is a neighboring node; represents the update of the relationship node by the k-th entity node u′ k under the condition that the relationship node v is a neighboring node.

[0169] Step S24: The entities and relationships passing through the graph neural network layer have enhanced semantic information and obtain vector representations of the entities and relationships. Next, use an entity tagger to predict the initial position and end position of the entity and record them with digital bits.

[0170] For example Figure 4 ​As shown in the figure, the entity-relationship joint extraction model predicts the head entity position, uses "1" to represent the start and end positions of the entity, then calculates and predicts the position where the second entity appears when the head entity is determined according to the conditional probability, and uses the number "2" to record the start and end positions. Finally, all entities are predicted and the start and end positions are marked, as follows:

[0171]

[0172] Among them, and respectively represent the start position probability and end position probability that the i-th word is an entity; and respectively represent the learnable weight matrices for the start and end positions of the entity, which are used to map the hidden state to the score space of the boundary; and represent the bias term, which is used to adjust the prediction baseline of the model for the boundary position.

[0173] The objective function of the prediction result is as follows:

[0174]

[0175] Among them, Pe|x represents the prediction probability of the sentence sequence x for the entity e; e start and e end respectively represent the start position and end position of the entity e in the sentence; represents the probability that the i-th word is predicted as the entity boundary at position t; represents the true label of the i-th word at position t; when the sentence sequence x is true, the function I is 1; conversely, when the sentence sequence x is false, the function I is 0.

[0176] After obtaining the predicted entities, extract all possible categories of the entities, calculate the maximum likelihood value, that is, for two entities e1, e2 and possible relationships in the given text sequence c, form a triple T(e1, r, e2), and calculate the maximum likelihood P, as follows:

[0177] P = ∏ e1,r,e2∈T pe1,r,e2x(30);

[0178] Step S3, based on the entity-relationship joint extraction model, construct a knowledge graph to realize intelligent prescription review of traditional Chinese medicine.

[0179] As Figure 5 shown, according to the obtained entities and relationships, construct a knowledge graph, create nodes and relationships related to traditional Chinese medicine materials. Review the dosage, taboos, norms of the names of traditional Chinese medicine materials, and medicine pairs of the traditional Chinese medicine materials in the prescription according to the information in the constructed knowledge graph.

[0180] For the prescriptions issued by doctors, obtain the medicinal material information and dosage information therein, obtain knowledge fact information from the target knowledge graph through Cyber query statements, and perform verification based on the knowledge fact information to obtain the prescription review result.

[0181] Taking the dosage knowledge graph as an example, if a certain medicinal material exceeds the specified dosage, it means that it does not conform to the fact information. The dosage knowledge graph is as Figure 6 shown.

[0182] Embodiment

[0183] This embodiment is specifically implemented according to a traditional Chinese medicine intelligent prescription review method based on a knowledge graph proposed by the present invention, and mainly includes the following steps:

[0184] (1) Make a data set, divide the data set according to the ratio of 7:2:1, and use them as the training set, validation set, and test set respectively. The training set is used to train the entity-relationship joint extraction model, the validation set is used to adjust parameters, and the test set is used to test the model performance.

[0185] (2) Construct an entity-relationship joint extraction model based on context feature enhancement and multi-relational graph neural network.

[0186] (3) Use the data set to conduct a large number of experiments on the entity-relationship joint extraction model, test the weights obtained after each training, record and compare them, and save the weights with the best effect.

[0187] (4) The entity-relationship joint extraction model loads the saved weights, and inputs the Chinese medicinal material information to be predicted into the entity-relationship joint extraction model to obtain the predicted result.

[0188] (5) Construct a knowledge graph according to the obtained predicted result.

[0189] (6) Review the prescriptions issued by traditional Chinese medicine doctors according to the obtained knowledge graph, as Figure 7 shown.

[0190] Prescription review use case: 9g of cloves, 3g of turmeric, 8g of Erycibe obtusata, 10g of Polygonum multiflorum, 8g of cinnabar.

[0191] Prescription review result:

[0192] Clove, dosage unqualified, out of range, normal dosage should be: 1 - 3g.

[0193] Cinnabar, dosage unqualified, out of range, normal dosage should be: 0.1 - 0.5g.

[0194] The name of Erycibe obtusata is not standardized and should be: Piper wallichii.

[0195] The name of fleece-flower root is not standardized and should be: Polygonum multiflorum Thunb.

[0196] The review of compatibility relationship is unqualified: cloves and turmeric are incompatible.

[0197] Therefore, the present invention adopts the above-mentioned traditional Chinese medicine intelligent prescription review method based on knowledge graph, uses the entity relationship joint extraction model based on context feature enhancement and multi-relation graph neural network to obtain the information of Chinese medicinal materials; constructs a knowledge graph, expands the functions and methods of prescription review, and is of great significance for assisting doctors to improve the accuracy and objectivity of treating diseases with traditional Chinese medicine in real life.

[0198] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that: they can still modify or equivalently replace the technical solutions of the present invention, and these modifications or equivalent replacements cannot make the modified technical solutions deviate from the spirit and scope of the technical solutions of the present invention.

Claims

1. A method for intelligent TCM prescription review based on knowledge graph, characterized in that: The following steps are involved: Step S1, preparing data, including data related to Chinese herbal medicine, data related to Chinese medicine diseases and data related to symptoms; Step S2, constructing an entity relationship joint extraction model based on context feature enhancement and multi-relation graph neural network; Step S3: Based on the entity-relationship joint extraction model, a knowledge graph is constructed to realize intelligent TCM prescription review.

2. According to claim 1, a method for intelligent TCM prescription review based on knowledge graph, characterized in that: In step S1, the specific process of data preparation is as follows: Step S11, constructing Chinese herbal medicine related data, wherein the basic information of Chinese herbal medicine includes the four properties, five flavors, nature and taste, meridians and functions of the medicine; Step S12, constructing TCM disease-related data, including disease causes and clinical manifestations; Step S13: construct symptom-related data, including standard symptom words and symptom word aliases.

3. According to the knowledge graph-based intelligent prescription review method of traditional Chinese medicine in claim 1, it is characterized in that: In step S2, the entity relationship joint extraction model based on context feature enhancement and multi-relation graph neural network is divided into four parts: The first part is the text feature embedding layer, which is used to serialize the text and convert it into a vector representation rich in semantic information; The second part is the feature extraction layer, which strengthens the contextual features of the input text sequence. While extracting global features, it can also grasp local features and enrich feature representation. The third part is the graph neural network layer, which performs semantic enhancement on entities and relationships; The fourth part is the entity relationship classification layer, which decodes the entities and calculates all the relationships to obtain the final probability.

4. According to claim 3, a method for intelligent TCM prescription review based on knowledge graph, characterized in that: The Bert pre-trained model is embedded in the text feature embedding layer to process text information in the field of traditional Chinese medicine. The specific process is as follows: Step S211: For a given text sequence c={c1, c2, ...c i ,…c m }, the initial input u of the i-th word i , as shown below: u i =Bert(c i ) (1); Among them, c i represents the i-th word in the sequence; m represents the sequence length of the sentence; Step S212: for a given relationship sequence d={d1,d,…d k ,…d n }, the initial input v′ of the kth relation k , as shown below: v′ k =Bert(d k ) (2); Among them, d k represents the kth relation in the sequence; n represents the number of relation types.

5. According to claim 3, a method for intelligent TCM prescription review based on knowledge graph, characterized in that: The feature extraction layer consists of an attention gated recurrent unit module, a multi-head attention module, a residual network module, and a feedforward neural network module. The feature extraction layer strengthens the contextual features of the input text sequence and enriches the feature representation. The specific process is as follows: Step S221, the attention gated recurrent unit network is composed of a double-layer GRU unit; First, take the vector obtained by the text embedding layer as input, use the hidden layer encoding feature vectors at all times, and obtain the text feature matrix H of the feature extraction layer, as shown below: Where h represents the hidden layer vector of the GRU unit; express The hidden layer vector at time instant; Secondly, based on the text feature matrix H multiplied by the updateable weight matrix W g1 , get the attention weight matrix W ga , and then the attention matrix W ga With the updateable weight matrix W g2 Matrix multiplication is performed to obtain the final attention matrix W att , as shown below: W ga =H*W g1 (4); IN att =In ga *IN g2 (5); Then, W att Use softmax to normalize the attention matrix W att Converted to attention weight matrix W gw , as shown below: W gw =softmax(W att ) (6); Finally, H and W gw Perform matrix multiplication to obtain the matrix H′ that highlights important text information, as shown below: H′=H*W gw (7); Step S222: In the multi-head attention module, the matrix H′ obtained by the attention gated recurrent unit module and the query matrix W q , Key matrix W k , Value matrix W v Perform matrix multiplication to obtain three feature matrices Q, K, and V, as shown below: Q=H'*W q (8); K=H'*W k (9); V=H′*W v (10); Use softmax for normalization, and the normalized text sequence attention matrix is ​​Z nr , Z nr_j is the result of the j-th attention head calculation, Q j , K j and V j They are the Query, Key, and Value matrices corresponding to the jth attention head; the final Z nr , Z nr_j , as shown below: Z nr =softmax(QK T )V (11); Use multi-head attention to concatenate the calculation results of multiple attention heads and multiply them with the initial weight matrix M0 for feature extraction to obtain the final extracted feature M a , as shown below: Z=[Z1,Z2,…Z j ,…WITH I ] (13); WITH j =Z nr_j (14); M a =ZM0 (15); Among them, I is the number of long positions, Z j is the attention weight matrix of the jth head; Z is the attention weight matrix; Step S223, the entity relationship joint extraction model uses the residual network module and normalizes the output of the multi-head attention module. The final matrix M obtained by normalization is as follows: M=H′+M a (16); Step S224: Input the final matrix M into the feedforward neural network module FFNN to obtain the text feature matrix M after one cycle. out , after N cycles, use Avgpool to out Perform average pooling to get U′ and propagate it to the graph neural network layer as shown below: M out =M+FFNN(M) (17); U'=Avgpool(M out ) (18); Among them, M out Represents the text feature matrix after a cycle; U' is the feature vector obtained after average pooling, which represents the global semantic information of the input sequence.

6. According to claim 3, a method for intelligent TCM prescription review based on knowledge graph, characterized in that: The graph neural network layer performs semantic enhancement on entities and relationships. The specific process is as follows: Step S231: classify entity nodes as nodes of the same type, regard relationship nodes as nodes of another type, regard nodes of one type as master nodes, and sequentially calculate the influence coefficients of all adjacent nodes of another type on the master node. All adjacent nodes of Do the connection calculation and get the node u' i and v' k The attention weight A between ik , as shown below: A ik =concat(W e u' i ,W r v' k ) (19); Among them, W e and W r is the initial weight matrix of entity nodes and relationship nodes; u' i is an entity node; v' k is a relationship node; Step S232: for node u' i and v' k The attention weights between are normalized, and the softmax function is used to reduce the impact of individual outliers on the entity relationship joint extraction model to obtain A' ik , as shown below: A' ik =softmax(A ik ) (20); Step S233: Based on the neighboring node information, the current node information u' i Update and obtain the updated node information m i , as shown below: m i =u' i +∑ k∈N A' ik W gv v' k (21); Among them, W gv is a trainable parameter; Step S234: Calculate the weight g using the sigmoid activation function i , used to ensure the balance before and after the node information is updated, as shown below: g i =sigmoid(W g concat(u' i ,m i )) (22); Among them, W g is a trainable matrix parameter; g i is the weight parameter; in, represents the node representation after n layers of information transmission; n is the number of graph neural network layers; g i *m i represents the contribution of the updated node information to the final representation, and its importance is given by g i Decision; (1-g i )*u' i Indicates the contribution of the node information before the update to the final representation, and its importance is 1-g i decide; when i When it is close to 1, the updated information dominates; when g i When it is close to 0, the information before the update is dominant; Therefore, the entire update process is simplified as follows: G=GNN(u' i ,{v' k } k∈N ) (24); Among them, G is the global feature at the graph level; {v' k } k∈N Represents node u i All neighboring nodes; GNN represents the process of updating the master node from the neighboring nodes; Step S235, let the vector be h, the entity feature vector be u, and the relationship feature vector be v, and fuse the entity feature vector and the relationship feature vector into the GNN network in sequence, and the entity relationship joint extraction model uses the residual network connection to obtain the updated relationship vector representation and entity word vector representation, then the output result of the entity relationship joint extraction model is as follows: in, Represents node u' i The neighbor set N n The feature vector of all nodes of type v in ; Represents node v' k The neighbor set N m The feature vector of all nodes of type u in ; Indicates that under the condition that the entity node u is a neighboring node, the i-th relationship node v' i Updates to entity nodes; Indicates that under the condition that the relationship node v is a neighboring node, the kth entity node u′ k Updates to relationship nodes.

7. According to claim 3, a method for intelligent TCM prescription review based on knowledge graph, characterized in that: Based on the semantic information enhancement of entities and relationships by the graph neural network layer and the vector representation of entities and relationships obtained, the entity tagger is then used to predict the initial and end positions of the entities and record them with digital digits. The specific process is as follows: The entity relationship joint extraction model predicts the position of the head entity, using "1" to represent the start and end positions of the entity, and then calculates and predicts the position of the second entity when the head entity is determined based on the conditional probability, and uses the number "2" to record the start and end positions. Finally, all entities are predicted and marked with the start and end positions, as shown below: in, and They represent the start position probability and end position probability of the i-th word being an entity respectively; and denote the learnable weight matrices for the start and end positions of the entity, respectively, used to map the hidden state to the score space of the boundary; and Represents the bias term, which is used to adjust the model's prediction baseline for the boundary position; The objective function of the prediction result is as follows: Among them, P(e|x) represents the predicted probability of sentence sequence x for entity e; e start and e end Respectively represent the starting position and ending position of entity e in the sentence; represents the probability that the i-th word at position t is predicted as an entity boundary; Represents the true label of the i-th word at position t. When the sentence sequence x is true, the function I is 1; otherwise, when the sentence sequence x is false, the function I is 0; After obtaining the predicted entity, extract all possible categories of the entity and calculate the maximum likelihood value, that is, in a given text sequence c, two entities e1, e2 and possible relations form a triple T (e1, r, e2), and calculate the maximum likelihood P, as shown below: P=∏ (e1,r,e2)∈T p((e1,r,e2)|x) (30)。 8. According to claim 1, a method for intelligent TCM prescription review based on knowledge graph, characterized in that: In step S3, based on the entity-relationship joint extraction model, a knowledge graph is constructed according to the obtained entities and relationships, and the dosage, contraindications, medicinal material name specifications, and drug pairs of the prescribed Chinese medicinal materials are reviewed according to the constructed knowledge graph information; For the prescribed prescription, the medicinal material information and dosage information are obtained, the knowledge fact information is obtained from the target knowledge graph through the Cyber ​​query statement, and the knowledge fact information is verified to obtain the prescription review result.

Citation Information

Cited By

  • Prescription commenting system based on generative artificial intelligence and processing method thereof

    CN121662420A