Medical inquiry method and device based on knowledge graph and generative dialogue
By constructing and updating the knowledge graph, extracting historical dialogue summary, and encoding with user problems, the problems of information forgetting and insufficient medical knowledge in the medical dialogue system are solved, the consistency and medical accuracy of dialogue are achieved, and accurate medical advice is provided.
Patent Information
- Application Number
- CN202411556482.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2025-02-28
AI Technical Summary
The existing medical dialogue system has problems such as information forgetting, insufficient medical knowledge, redundancy in dialogue and insufficient knowledge graph fusion in multiple rounds of dialogue, which affects the consistency and medical accuracy of dialogue.
Generate high-quality medical conversation replies by constructing and updating knowledge graphs, extracting historical conversation summary, matching knowledge graph triples, and encoding them with user questions and historical conversations.
It effectively solves the problems of information forgetting and dialogue redundancy, enhances the consistency and medical accuracy of dialogue, ensures that the generated responses are closely related to the previous article, and provides accurate and relevant medical advice.
Smart Images

Figure CN119537534A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence and medical information processing, and in particular to a medical consultation method and device based on knowledge graph and generative dialogue, aiming to improve the accuracy and contextual coherence of multi-round medical dialogues, and solve the long-term memory forgetting and information redundancy problems encountered by generative models in complex medical scenarios. Background Art
[0002] With the development of big data and artificial intelligence technology, the application of conversation-generated consultation systems in the medical field has gradually become popular. This type of system helps patients obtain medical advice by having multiple rounds of natural language conversations with patients, alleviating the pressure of consultation caused by tight medical resources. However, there are still some problems with existing generative dialogue systems. In multi-round medical conversations, due to the lack of specialized medical background knowledge and effective context management, they are mainly manifested in the following aspects:
[0003] 1. Information forgetting: In multi-round dialogue scenarios, the generative model needs to understand the context based on historical dialogues. However, many models fail to effectively capture key information in the dialogue context, resulting in the generated responses being out of touch with the previous dialogue context, affecting the dialogue coherence and medical accuracy. The model is difficult to maintain long-term context memory in multi-round dialogues, resulting in the lack of coherence in the generated responses.
[0004] 2. Insufficient medical knowledge: Although traditional dialogue generation models can generate natural language dialogues, the generated responses are often too general and lack the accuracy and consistency of medical knowledge. They cannot effectively solve the specific medical problems raised by patients. In addition, the models may generate inaccurate or irrelevant responses and cannot effectively handle complex medical dialogue scenarios.
[0005] 3. Dialogue redundancy: Useless information increases in long conversations, affecting the model’s ability to process and generate high-quality responses.
[0006] 4. Insufficient integration of medical entity recognition and knowledge graph: Some knowledge graph-based medical dialogue systems attempt to introduce medical knowledge graphs. However, during the integration of the knowledge graph, the entity recognition accuracy is insufficient, and the graph knowledge fails to be highly matched with patient questions, which limits the system's knowledge utilization capabilities. Summary of the invention
[0007] The present invention aims to overcome the above shortcomings of the prior art and provides a medical consultation method and device based on knowledge graph and generative dialogue. The present invention utilizes knowledge graph and dialogue fusion to extract high-quality historical content through summary extraction, solving the problems of information forgetting, insufficient medical knowledge, dialogue redundancy, and insufficient graph fusion in traditional medical dialogue models.
[0008] The objective of the present invention is achieved through the following technical solutions:
[0009] The first aspect of the present invention relates to a medical consultation method based on a knowledge graph and a generative dialogue, comprising the following steps:
[0010] 1. Preprocess the data, preprocess the medical data to form the knowledge graph dataset and medical dialogue dataset.
[0011] 2. Build a knowledge graph, build and update the knowledge graph containing medical entities and their relationships.
[0012] 3. Extract historical dialogue summaries and extract summary information from the historical records of multiple rounds of dialogues to enhance the contextual understanding of dialogue generation.
[0013] 4. Match knowledge graph triples, match entities in the conversation with entities in the knowledge graph, and generate knowledge triple data.
[0014] 5. Encoding data: encode the matched knowledge triple data, encode the current user question and historical dialogue summary, and form an input vector for generating dialogue responses.
[0015] 6. Generate answers and generate responses to medical conversations based on the encoded input data.
[0016] The second aspect of the present invention relates to a medical consultation device based on a knowledge graph and a generative dialogue, comprising a memory and one or more processors, wherein the memory stores executable code, and when the one or more processors execute the executable code, they are used to implement a medical consultation method based on a knowledge graph and a generative dialogue of the present invention.
[0017] The third aspect of the present invention relates to a computer-readable storage medium having a program stored thereon, which, when executed by a processor, implements a medical consultation method based on a knowledge graph and a generative dialogue of the present invention.
[0018] The present invention proposes a medical consultation method based on knowledge graph and generative dialogue. The method first enhances the open medical dialogue data set, and the processed data set includes the medical entity corresponding to each sentence. For the current i-th round of user query, the corresponding 1 to i-1 rounds are extracted as the corresponding historical dialogues to train the summary extraction model. Then, the medical entities in the current user query are matched with the entities in the knowledge graph by similarity to obtain related medical knowledge triples. The matched knowledge triples, historical summaries and the user's current query are fused for final answer generation.
[0019] Compared with the prior art, the present invention has the following advantages:
[0020] By introducing a historical conversation summary extraction module, the problem of information forgetting in multi-round conversations is solved. The present invention can effectively capture and retain key information in the conversation context, ensuring that the generated response is closely related to the previous text, thereby improving the coherence and medical accuracy of the conversation. This module helps the model maintain context memory in long-term multi-round conversations and ensures the coherence of responses.
[0021] By integrating filtered structured medical knowledge graph triples and combining them with the generative model, the accuracy and consistency of medical information in the conversation are enhanced. The generated responses can provide accurate and relevant medical advice for the patient's specific problems, avoiding the problem of overly general or inaccurate responses in traditional models. The system can make full use of graph knowledge to provide more professional and targeted responses, significantly improving the system's processing capabilities in complex medical scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 is a flow chart of the method of the present invention;
[0023] Figure 2 Schematic diagram of the device of the present invention. DETAILED DESCRIPTION
[0024] The present invention is further described in detail below with reference to the accompanying drawings and embodiments.
[0025] Example 1
[0026] Reference Figure 1 , this embodiment relates to a medical consultation method based on knowledge graph and generative dialogue, comprising the following steps:
[0027] (1) Preprocess the data and preprocess the medical data to form a knowledge graph dataset and a medical dialogue dataset.
[0028] (1.1) The medical dialogue dataset is processed sentence by sentence, sentences containing invalid characters and missing values are removed, and the format is adjusted to the dataset D in which patients and doctors alternate.
[0029] D={d1,d2,...,d n} (1)
[0030] d i = {u i ,t i} (2)
[0031] (1.2) The medical dialogue dataset is then processed to generate the training set H required for the summary extraction model.
[0032] H={h1,h2,...,h n} (3)
[0033] h i ={u1;t1;u2;t2;...;u i ;t i} (4)
[0034] (1.3) The BERT-CRF model architecture is used to train medical conversation data to extract medical entities in sentences. BERT is used to extract the context information of the sentence, and the word vector is represented as a context-related word vector sequence, which is then globally optimized through the CRF layer. The specific operation of BERT+CRF is as follows: Given an input sequence and where u i ,t i In named entity recognition, X is collectively referred to as (x1, x2, ..., x n ) is the word vector H = {h1,h2,...,h n}, and then use the CRF layer to model the sequence label and calculate Y = (y1, y2, ..., y n ) probability:
[0035] h i =BERT(x1,x2,...,x n ) (5)
[0036]
[0037] Among them, score(X,Y) is the score of the BERT-CRF model for the sequence X and the annotation Y, and the model is trained by maximizing the probability.
[0038] (1.4) Through the medical entity recognition model, the medical entities are concatenated with the original sentences, so that the data set contains the original sentences and the medical entities corresponding to each sentence. The multi-round conversation data between the patient and the doctor is represented by D = {d1, d2, ..., d n}, where d i represents the i-th round of dialogue, including the patient's questions and the doctor's responses, where d i = {u i |t i ; e1,e2,...,e n}, including specific sentences and the medical entities contained in the sentences.
[0039] (2) Build a knowledge graph, build and update the knowledge graph containing medical entities and their relationships.
[0040] (2.1) Process the knowledge graph triple data and ensure that the triple format is (h, r, t), where h represents the head entity, r represents the relationship, and t represents the tail entity.
[0041] (2.2) Convert the knowledge triple (h, r, t) into a node and relationship format suitable for Neo4j storage. Each entity h and t is mapped to a node in Neo4j, and each relationship r is mapped to a relationship edge between nodes.
[0042] (3) Extract historical dialogue summaries: Extract summary information from the historical records of multiple rounds of dialogue to enhance the contextual understanding of dialogue generation.
[0043] (3.1) The input representation module accepts the input text sequence h i ={u1;t1;u2;t2;...;u i ;t i} Its corresponding true summary sequence Y = {y1,y2,...,y m}, where u i and t together as X={x1,x2,...,x n}, generate word vector representation E={e1,e2,...,e n}, the formula is:
[0044]
[0045] (3.2) The word vector of the input text is encoded through a multi-layer self-attention mechanism to generate a context representation H = {h1,h2,...,h n}, the calculation formula of the self-attention mechanism is:
[0046]
[0047] Among them, Q is the query vector, K is the key vector, V is the value vector, d k is the dimension of the vector.
[0048] (3.3) The context representation H generated by the encoder is generated by the summary generator module to generate an output summary. During the generation process, the decoder gradually generates each word of the summary through autoregression. The probability distribution formula of the generated words is:
[0049]
[0050] in, is the tth generated summary word, represents the summary word sequence generated before time step t, W o is the weight matrix of the output layer, h tIt is the context representation of the current moment.
[0051] (3.4) Summary generated by comparing models and the true summary Y = {y1,y2,...,y m}, use the cross entropy loss function to calculate the loss, the loss function formula is:
[0052]
[0053] Among them, y t is the tth word in the true summary, and the model optimizes the accuracy of the generated summary by minimizing this loss function.
[0054] (4) Match knowledge graph triples, match entities in the conversation with entities in the knowledge graph, and generate knowledge triple data.
[0055] (4.1) The BioWordVec word embedding model is used to convert entities in the conversation and entities in the knowledge graph into vector representations. Each entity e i and e KG Mapped to vector E through BioWordVec i and E KG . Matching is performed by calculating the cosine similarity between entity vectors. The similarity calculation formula is:
[0056]
[0057] Among them, E i and E KG They represent the vector representations of the conversation entity and the knowledge graph entity respectively. The higher the similarity, the higher the degree of match.
[0058] (4.2) For each successfully matched entity pair (e i ,e KG ), extract relevant triples (h, r, t) from the knowledge graph, where h and t represent the head entity and tail entity respectively, and r represents the relationship between them. The generated triples (h, r, t) will be used as the candidate triples for the input of the subsequent answer generation module, and will be filtered twice in the subsequent model training to ensure that the generated dialogue can be associated with medical knowledge.
[0059] (5) Encoding data: Encode the matched knowledge triple data, encode the current user question and the historical dialogue summary, and form an input vector for generating dialogue responses.
[0060] (5.1) Encode the current user question and historical dialogue summary: Concatenate the patient's current input and historical summary into where h i={u1;t1;u2;t2;...;u i ;t i}, pre-trained BERT is used for encoding to generate context vectors of the patient’s current input and historical summary for model training.
[0061] (5.2) Entity Encoding: To bridge the representation gap between external knowledge and conversation text, we employ a multi-layer perceptron (MLP) for this purpose. A knowledge triple is represented by concatenating the head, tail, and relation embeddings together. The head, tail, and relation entities are represented using pre-trained BioWordVec embeddings that are trained on large unlabeled biomedical text data.
[0062] e=MLP(concat[h; r; t]) (13)
[0063] (6) Generate answers, generating responses to medical conversations based on the encoded input data.
[0064] (6.1) Embedding context H through medical multi-head attention mechanism k and triple embeddings in knowledge graphs k By calculating the dot product attention, we identify the triplet most relevant to the current dialogue context and generate the attention weight β j,l The calculation formula of the attention mechanism is:
[0065]
[0066] Among them, H k is the contextual embedding k is the triple embedding, z k is a scaling factor used to control the numerical range of the dot product result. This step uses a multi-head attention mechanism to process multiple triplets in parallel and generate a weighted representation.
[0067] (6.2) A feedforward neural network (FFN) is applied to the weighted representation generated by the multi-head attention mechanism to further process and generate the fused representation. The feedforward neural network consists of two linear transformation layers connected by a ReLU activation function. The formula is as follows:
[0068] F k =FFN(MultiHeadMedAttention(H k ,e k ,e k )) (15)
[0069] (6.3) Attention weight β generated by the multi-head attention mechanism j,l, calculate the probability of copying an entity from the knowledge graph. By weighting the entities in all triples, the probability of each entity being copied from the knowledge graph is calculated as follows:
[0070]
[0071] Among them, β j,l is the attention weight corresponding to each entity, which is used to indicate the possibility of it being copied into the generated answer.
[0072] (6.4) Based on the previously generated context vector H k And the fused triple information F k , the decoder generates the current word t at each time step j k,j The specific formula is:
[0073]
[0074] The probability distribution of generated words is calculated by the softmax function:
[0075]
[0076] (6.5) The entity copying mechanism ensures that accurate medical entities are copied from the knowledge graph when generating answers. The probability of entity copying P c (y k,j ) is calculated by the following formula:
[0077] P c (y k,j )=σ(W c [h t ;T]) (19)
[0078] Among them, W c is the weight matrix controlling the copy mechanism, h t is the current context representation, and T is the triple embedding representation.
[0079] (6.6) Generation and copying gate mechanism control: The gate mechanism g1 is used to control whether the currently generated word is generated from the vocabulary or copied from the historical dialogue entity. The calculation formula of the gate mechanism is:
[0080] g1=σ(W1[H k ]+b1) (20)
[0081] According to the value of g1, the probability of generating words and copying entities is fused. The specific formula is:
[0082] P copy (y k,j )=g1P gen (yk,j )+(1-g1)P c (y k,j ) (twenty one)
[0083] (6.7) Calculation of the final generated probability distribution: The generated words and entities copied from the knowledge graph are fused through the second-layer gating mechanism g2 to finally generate the answer. The calculation formula is:
[0084] g2=σ(W2[F k ]+b2) (22)
[0085] The probability distribution of the final generated word is:
[0086] P(y k,j )=g2P tr (y k,j )+(1-g2)P copy (y k,j ) (twenty three)
[0087] Among them, P tr (y k,j ) is the probability of copying an entity from a triple, P copy (y k,j ) is the fusion probability of the generated word and the copied entity.
[0088] This example verifies the effectiveness of this method based on an open source medical conversation dataset. The dataset contains multiple rounds of conversations between multiple doctors and patients. The data is single, redundant, and uneven in rounds. Summary extraction, triple filtering, and fusion are used to effectively improve the fluency and richness of answers in medical conversations. After using the training model of this method, efficient and rich medical responses can be obtained. This model can be used in the development of medical AIGC-related applications to enhance user experience.
[0089] The evaluation index calculation modules include language fluency, semantic relevance, medical accuracy and BLEU indicators. Among them, perplexity (PPL) is used as the measurement standard. A lower PPL value indicates a more fluent response. The calculation formula is: Semantic relevance: Cosine similarity is used to calculate the similarity between the generated response and the patient's question. The higher the similarity, the more relevant the generated response is to the patient's question. The formula is: Medical accuracy: The score is based on the matching degree between the generated medical entities and the entities in the historical summary. The higher the matching rate, the better the medical accuracy. The BLEU (Bilingual Evaluation Understudy) indicator is an automated evaluation indicator used to evaluate the output quality of machine-generated language models. It evaluates the quality of text generation by measuring the n-gram matching degree between the text generated by the model and the reference text.
[0090] Example 2
[0091] The present embodiment relates to a medical consultation device based on a knowledge graph and a generative dialogue, comprising a memory and one or more processors, wherein the memory stores executable code, and when the one or more processors execute the executable code, they are used to implement a medical consultation method based on a knowledge graph and a generative dialogue of embodiment 1.
[0092] Example 3
[0093] This embodiment relates to a computer-readable storage medium having a program stored thereon. When the program is executed by a processor, a medical consultation method based on a knowledge graph and a generative dialogue of Embodiment 1 is implemented.
[0094] Each embodiment of the present invention is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0095] The above description is only an embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent substitution, improvement, etc. made within the spirit and principle of the present invention should be included in the scope of the claims of the present invention.
Claims
1. A medical consultation method based on knowledge graph and generative dialogue, characterized in that: The following steps are involved: (1) Preprocess the data and preprocess the medical data to form a knowledge graph dataset and a medical dialogue dataset; (2) Construct a knowledge graph, build and update a knowledge graph containing medical entities and their relationships; (3) Extract historical dialogue summaries, extract summary information from the historical records of multiple rounds of dialogue to enhance the contextual understanding of dialogue generation; (4) Matching knowledge graph triples, matching entities in the conversation with entities in the knowledge graph, and generating knowledge triple data; (5) Encoding data: Encode the matched knowledge triple data, encode the current user question and the historical dialogue summary, and form an input vector for generating dialogue responses; (6) Generate answers, generating responses to medical conversations based on the encoded input data.
2. According to claim 1, a medical consultation method based on knowledge graph and generative dialogue is characterized in that: Step (1) specifically includes: (1.1) The medical dialogue dataset is processed sentence by sentence, sentences containing invalid characters and missing values are removed, and the format is adjusted to the dataset D of alternating patients and doctors; D={d1,d2,...,d n } (1) d i ={u i ,t i } (2) (1.2) Then the medical dialogue dataset is processed to generate the training set H required for the summary extraction model; H={h1,h2,...,h n } (3) h i ={u1;t1;u2;t2;...;u i ;t i } (4) (1.3) The BERT-CRF model architecture is used to train medical conversation data to extract medical entities in sentences. BERT is used to extract the context information of the sentence, and the word vector is represented as a context-related word vector sequence, which is then globally optimized through the CRF layer. The specific operation of BERT+CRF is as follows: Given an input sequence and where u i ,t i In named entity recognition, X is collectively referred to as (x1, x2, ..., x n ) is the word vector H = {h1,h2,...,h n }, and then use the CRF layer to model the sequence label and calculate Y = (y1, y2, ..., y n ) probability: h i =BERT(x1,x2,...,x n ) (5) Among them, score(X,Y) is the score of the BERT-CRF model for the sequence X and the label Y, and the model is trained by maximizing the probability; (1.4) Through the medical entity recognition model, the medical entities are concatenated with the original sentences, so that the data set contains the original sentences and the medical entities corresponding to each sentence. The multi-round conversation data between the patient and the doctor is represented by D = {d1, d2, ..., d n }, where d i represents the i-th round of dialogue, including the patient's questions and the doctor's responses, where d i = {u i |t i ; e1,e2,...,e n }, including specific sentences and the medical entities contained in the sentences.
3. According to claim 1, a medical consultation method based on knowledge graph and generative dialogue is characterized in that: Step (2) specifically includes: (2.1) Process the knowledge graph triple data and ensure that the triple format is (h, r, t), where h represents the head entity, r represents the relationship, and t represents the tail entity; (2.2) Convert the knowledge triple (h, r, t) into a node and relationship format suitable for Neo4j storage; each entity h and t is mapped to a node in Neo4j, and each relationship r is mapped to a relationship edge between nodes.
4. According to claim 2, a medical consultation method based on knowledge graph and generative dialogue is characterized in that: Step (3) specifically includes: (3.1) The input representation module accepts the input text sequence h i ={u1;t1;u2;t2;...;u i ;t i } Its corresponding true summary sequence Y = {y1,y2,...,y m }, where u i and t together as X={x1,x2,...,x n }, generate word vector representation E={e1,e2,...,e n }, the formula is: (3.2) The word vector of the input text is encoded through a multi-layer self-attention mechanism to generate a context representation H = {h1,h2,...,h n }, the calculation formula of the self-attention mechanism is: Among them, Q is the query vector, K is the key vector, V is the value vector, d k is the dimension of the vector; (3.3) The context representation H generated by the encoder is generated by the summary generator module to generate an output summary. During the generation process, the decoder gradually generates each word of the summary through autoregression. The probability distribution formula of the generated words is: in, is the tth generated summary word, represents the summary word sequence generated before time step t, W o is the weight matrix of the output layer, h t is the contextual representation of the current moment; (3.4) Summary generated by comparing models and the true summary Y = {y1,y2,...,y m }, use the cross entropy loss function to calculate the loss, the loss function formula is: Among them, y t is the tth word in the true summary, and the model optimizes the accuracy of the generated summary by minimizing this loss function.
5. According to claim 1, a medical consultation method based on knowledge graph and generative dialogue is characterized in that: Step (4) specifically includes: (4.1) The BioWordVec word embedding model is used to convert entities in the conversation and entities in the knowledge graph into vector representations; each entity e i and e KG Mapped to vector E through BioWordVec i and E KG ; Matching is performed by calculating the cosine similarity between entity vectors. The similarity calculation formula is: Among them, E i and E KG Represent the vector representations of the conversation entity and the knowledge graph entity respectively. The higher the similarity, the higher the matching degree. (4.2) For each successfully matched entity pair (e i ,e KG ), extract relevant triples (h, r, t) from the knowledge graph, where h and t represent the head entity and the tail entity respectively, and r represents the relationship between them; the generated triples (h, r, t) will be used as the triple candidate set of the subsequent answer generation module, and will be secondary filtered in the subsequent model training to ensure that the generated dialogue can be associated with medical knowledge.
6. According to claim 1, a medical consultation method based on knowledge graph and generative dialogue is characterized in that: Step (5) specifically includes: (5.1) Encode the current user question and historical dialogue summary: Concatenate the patient's current input and historical summary into where h i ={u1;t1;u2;t2;...;u i ;t i },Use pre-trained BERT for encoding to generate context vectors of the patient’s current input and historical summary for model training; (5.2) Entity Encoding: To bridge the representation gap between external knowledge and conversation text, a multi-layer perceptron (MLP) is used. A knowledge triple is represented by concatenating the head, tail, and relation embeddings together. The head, tail, and relation entities are represented using pre-trained BioWordVec embeddings, which are trained on large unlabeled biomedical text data. e=MLP(concat[h; r; t]) (13) 7. A medical consultation method based on knowledge graph and generative dialogue according to claim 1, characterized in that: Step (6) specifically includes: (6.1) Embedding context H through medical multi-head attention mechanism k and triple embeddings in knowledge graphs k By calculating the dot product attention, the triplet most relevant to the current dialogue context is identified and the attention weight β is generated. j,l ; The calculation formula of the attention mechanism is: Among them, H k is the contextual embedding k is the triple embedding, z k is a scaling factor used to control the numerical range of the dot product result; this step uses a multi-head attention mechanism to achieve parallel processing of multiple triplets and generate a weighted representation; (6.2) A feedforward neural network FFN is applied to the weighted representation generated by the multi-head attention mechanism to further process and generate the fused representation; the feedforward neural network consists of two linear transformation layers connected by a ReLU activation function; the formula is as follows: F k =FFN(MultiHeadMedAttention(H k ,he k ,he k )) (15) (6.3) Attention weight β generated by the multi-head attention mechanism j,l , calculate the probability of copying an entity from the knowledge graph; by weighting the entities in all triples, calculate the probability of each entity being copied from the knowledge graph, the formula is as follows: Among them, β j,l is the attention weight corresponding to each entity, which is used to indicate the possibility of it being copied into the generated answer; (6.4) Based on the previously generated context vector H k And the fused triple information F k , the decoder generates the current word t at each time step j k,j ; The specific formula is: The probability distribution of generated words is calculated by the softmax function: (6.5) The entity copying mechanism ensures that accurate medical entities are copied from the knowledge graph when generating answers; the probability of entity copying P c (y k,j ) is calculated by the following formula: P c (y k,j )=σ(W c [h t ;T]) (19) Among them, W c is the weight matrix controlling the copy mechanism, h t is the current context representation, T is the triple embedding representation; (6.6) Generation and copying gate mechanism control: The gate mechanism g1 is used to control whether the currently generated word is generated from the vocabulary or copied from the historical dialogue entity; the calculation formula of the gate mechanism is: g1=σ(W1[H k ]+b1) (20) According to the value of g1, the probability of generating words and copying entities is fused. The specific formula is: P copy (and k,j )=g1P gen (and k,j )+(1-g1)P c (and k,j ) (21) (6.7) Calculation of the final generated probability distribution: The generated words and entities copied from the knowledge graph are fused through the second-layer gating mechanism g2 to finally generate the answer; the calculation formula is: g2=σ(W2[F k ]+b2) (22) The probability distribution of the final generated word is: P(y k,j )=g2P tr (y k,j )+(1-g2)P copy (y k,j ) (23) Among them, P tr (y k,j ) is the probability of copying an entity from a triple, P copy (y k,j ) is the fusion probability of the generated word and the copied entity.
8. A medical consultation device based on knowledge graph and generative dialogue, characterized in that: It includes a memory and one or more processors, wherein the memory stores executable code, and when the one or more processors execute the executable code, it is used to implement a medical consultation method based on a knowledge graph and a generative dialogue as described in any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that: A program is stored thereon, and when the program is executed by a processor, a medical consultation method based on a knowledge graph and a generative dialogue as described in any one of claims 1-7 is implemented.