Auxiliary medical management method and system based on natural questions and answers and knowledge graph
By pre-training the BERT model and BiLSTM/CRF sequence annotation, combined with top-k skip search and the attention mechanism of the Seq2Seq framework, the existing medical question answering system solves the problems of incomplete knowledge graphs and single answer generation, and achieves a better Accurate and efficient medical information retrieval and answer generation.
Patent Information
- Application Number
- CN202410697477.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2024-08-30
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing medical question answering systems based on knowledge graphs have problems such as incomplete knowledge graph construction, limited problem understanding and semantic analysis capabilities, a single answer generation method, and a lack of user interaction and feedback mechanisms, making it difficult to provide accurate and comprehensive answers.
Use the pre-trained BERT model to extract semantic vectors of medical texts and questions, combine BiLSTM and CRF for sequence annotation, and dynamically program to decode medical entities; use top-k jump search to search for relationship paths on the knowledge graph, and combine with multi-granularity scoring mechanisms to generate Answer; use the attention mechanism under the Seq2Seq framework for answer generation.
It improves the accuracy of medical entity recognition and the quality and readability of answer generation, enhances the accuracy of question understanding and the efficiency of answer retrieval, and provides rich and complete answer clues.
Smart Images

Figure CN118568228A
Abstract
Description
Technical Field
[0001] The present invention relates to medical management technology, and in particular to an auxiliary medical management method and system based on natural question answering and knowledge graph. Background Art
[0002] In recent years, artificial intelligence technology has been widely used in the field of medical health. In particular, with the development of technologies such as natural language processing and knowledge graphs, intelligent question-answering systems have provided new possibilities for auxiliary medical management. Traditional medical management mainly relies on the experience and professional knowledge of doctors, and has problems such as low efficiency, high cost, and strong subjectivity. Therefore, it is urgent to develop an auxiliary medical management system based on natural question-answering and knowledge graphs to help doctors quickly and accurately obtain the required information and improve the intelligent level of medical management.
[0003] At present, there are mainly the following types of question-answering systems in the medical field: rule-based question-answering systems, retrieval-based question-answering systems, and knowledge graph-based question-answering systems. The rule-based method constructs question templates and answer templates and uses pattern matching to achieve question-answering, but it requires a lot of manual construction of rules and has poor scalability. The retrieval-based method searches for the sentence with the highest similarity to the question in the text library as the answer, but it is difficult to handle complex questions and generate complete answers. The knowledge graph-based method uses structured knowledge to represent questions and answers, generates answers through semantic parsing and reasoning, and can provide more accurate and comprehensive answers.
[0004] The existing medical question-answering systems based on knowledge graphs have the following main deficiencies: 1) The knowledge graph is not well constructed and lacks high-quality medical knowledge; 2) The question understanding and semantic parsing capabilities are limited, making it difficult to accurately extract key information from the questions; 3) The answer generation method is single and lacks diversity and flexibility; 4) There is a lack of user interaction and feedback mechanisms, making it difficult to adapt to actual application scenarios. Summary of the invention
[0005] The embodiments of the present invention provide an auxiliary medical management method and system based on natural question answering and knowledge graph, which can solve the problems in the prior art.
[0006] According to a first aspect of the embodiments of the present invention,
[0007] Provides auxiliary medical management methods based on natural question answering and knowledge graph, including:
[0008] Use the pre-trained BERT model to extract the semantic vector of each word in the medical text, input the semantic vector extracted by the BERT model into the BiLSTM layer for sequence encoding, send the output vector of the BiLSTM layer to the CRF layer for sequence labeling, and decode the global optimal label sequence through the dynamic programming algorithm to identify the medical entities in the medical text;
[0009] Use the pre-trained BERT model to convert natural language questions into question vectors, calculate the similarity between the question vector and the embedding vectors of all entities in the pre-built medical knowledge graph, select multiple most similar entities as candidate answers, search for relationship paths related to the question vector on the medical knowledge graph starting from multiple most similar entities, and determine the knowledge triples that match the question vector;
[0010] The medical entity, candidate answer and knowledge triples are respectively input into three independent BiGRU encoders for feature extraction. The output of the BiGRU encoder is dynamically weighted and aggregated using the attention mechanism under the Seq2Seq framework as the attention context vector of the decoder at each time step. The decoder predicts the probability distribution of the next answer word based on the current hidden state, the attention context vector and the previously generated words, and generates the answer text in natural language form through maximum likelihood estimation.
[0011] In an optional embodiment,
[0012] The output vector of the BiLSTM layer is sent to the CRF layer for sequence labeling. The global optimal label sequence is decoded through the dynamic programming algorithm to identify the medical entities in the medical text, including:
[0013] Determine an emission feature corresponding to an output vector of the BiLSTM layer, where the emission feature is used to measure the compatibility between the output vector of the BiLSTM layer and the label;
[0014] The label sequence is modeled using a conditional random field model, and the dependency between labels is characterized by emission features and transfer features, wherein the transfer features are used to characterize the dependency between adjacent labels;
[0015] The emission feature and the transfer feature are used in the inference stage of the conditional random field model, and an approximate decoding algorithm is used to recursively retain multiple candidate label sequences of each reasoning step, and the candidate label sequences exceeding a preset length threshold are terminated in advance;
[0016] Candidate label sequences whose cumulative probability is lower than the dynamic threshold are pruned, repeated label substrings in the candidate label sequence are merged, and illegal label combinations are pruned according to preset label constraint rules until the end of the sequence is reached, and the label sequence with the largest conditional probability is selected from the multiple candidate label sequences as the global optimal label sequence.
[0017] In an optional embodiment,
[0018] The approximate decoding algorithm is used to recursively retain multiple candidate label sequences for each reasoning step, including:
[0019]
[0020] in, represents the unnormalized probability of the bth optimal prefix label sequence obtained in the i-th step beam search, b represents the candidate sequence index retained in the beam search, and b' represents the candidate sequence index retained in the previous step beam search; y i Represents the label of the current moment i; Indicates the end label of the b'th sequence in the previous step; represents the transfer feature value between adjacent labels; f() represents the emission feature function, and the measurement input represents the difference between X at position i and label y i compatibility; n represents the length of the input sequence.
[0021] In an optional embodiment,
[0022] Select multiple most similar entities as candidate answers, and use the multiple most similar entities as starting points to search for relationship paths related to the question vector on the medical knowledge graph. Determine the knowledge triples that match the question vector, including:
[0023] Get the vector representation of the target question, calculate the similarity between the question vector and the entity vectors in the knowledge graph, and select the k entities with the highest similarity as the starting points of the candidate answers;
[0024] Taking the starting point of the candidate answer as the center, a top-k jumping search strategy is adopted to search for a relationship path whose length does not exceed a preset threshold L on the knowledge graph to obtain a set of candidate relationship paths, wherein the top-k jumping search strategy selects the k nodes with the highest similarity in each jump, and selects the k nodes with the highest comprehensive similarity from the entire search process, and the similarity between the candidate relationship path and the question vector is calculated using an encoder based on an attention mechanism;
[0025] For each candidate relationship path in the candidate relationship path set, extract all knowledge triples contained therein, and adopt a multi-granularity scoring mechanism to calculate the relevance of each knowledge triple with the target problem. The multi-granularity scoring mechanism includes single-granularity scoring, double-granularity scoring and overall scoring. The single-granularity scoring considers the similarity between the head entity, relationship and tail entity of the triple and the problem. The double-granularity scoring considers the similarity between the combination of the head entity-relationship, relationship-tail entity and head entity-tail entity of the triple and the problem. The overall scoring considers the similarity between the entire triple and the problem.
[0026] According to the relevance of each knowledge triple obtained by the multi-granularity scoring mechanism and combined with the preset weights, the final comprehensive relevance score of each knowledge triple is calculated, and the tail entity of the knowledge triple with the highest score is selected as the final answer to the target question; if the tail entities of different knowledge triples are inconsistent, the tail entity of the knowledge triple with the highest comprehensive relevance score of the corresponding candidate relationship path is selected as the final answer.
[0027] In an optional embodiment,
[0028] Taking the starting point of the candidate answer as the center, a top-k jumping search strategy is adopted to search for relationship paths whose length does not exceed the preset threshold L on the knowledge graph, and the candidate relationship path set obtained includes:
[0029] Get the text description vector of the current node in the knowledge graph and the vector representation of the question, and calculate the cosine similarity of the two vectors as the semantic similarity scoring item;
[0030] The semantic similarity scoring item is weightedly summed with the original scoring item based on the Euclidean distance of the TransE embedding vector to obtain an improved node scoring function, wherein the improved node scoring function is used to evaluate the relevance of the node to the question;
[0031] The entity importance weight is calculated based on the frequency of occurrence of the entity in the knowledge graph. The higher the frequency of occurrence of the entity, the lower its importance weight;
[0032] Introduce entity importance weights into the improved node scoring function to adjust the scoring results;
[0033] A path encoder based on the attention mechanism is used to represent the relationship path. The path attention weight is calculated according to the similarity between the problem vector and each relationship vector in the path. The path vector is obtained by weighted summation, and multiple path vectors are summarized to obtain a set of candidate relationship paths.
[0034] In an optional embodiment,
[0035] Introducing entity importance weights into the improved node scoring function includes:
[0036] Score(r k )=α * (-||e ans +r path -e k ||2)+β * sim(e k , Q)+γ * w(e k );
[0037] Among them, e krepresents the kth node, α * , β * , γ * They represent the coefficients of path relevance coefficient, semantic similarity coefficient, and entity importance weight respectively, e ans 、r path They represent the candidate answer entity and relationship path vectors respectively, Q represents the question vector, and w represents the entity importance weight.
[0038] In an optional embodiment,
[0039] In the Seq2Seq framework, the attention mechanism is used to dynamically weight the output of the BiGRU encoder as the attention context vector of each time step of the decoder. The decoder predicts the probability distribution of the next answer word based on the current hidden state, the attention context vector, and the previously generated words, and generates the answer text in natural language form through maximum likelihood estimation, including:
[0040] The question, the candidate answer entity and the candidate answer relationship are respectively encoded using a bidirectional GRU to obtain a question encoding vector, a candidate answer entity encoding vector and a candidate answer relationship encoding vector. The bidirectional GRU can simultaneously utilize past and future context information to obtain a more comprehensive semantic representation.
[0041] At each step, the decoder calculates the attention weights of all question encoding vectors, candidate answer entity encoding vectors, and candidate answer relationship encoding vectors based on the current hidden state, and obtains the attention context vector by weighted summation. The attention mechanism enables the decoder to adaptively focus on different encoding information.
[0042] The current decoder hidden state is concatenated with the attention context vector and passed through the fully connected layer and the Softmax layer to obtain the probability distribution of the answer token at the current time step.
[0043] Sampling or selecting the token with the highest probability from the probability distribution as the prediction output at the current moment, and inputting it into the decoder at the next moment, until the end-of-sentence marker is encountered, generating a complete answer text;
[0044] The teacher forcing strategy is used during training, where the true answer token is input into the decoder at each step; during inference, the next token is sampled based on the prediction at the current moment;
[0045] Heuristic rules are introduced to constrain the decoding process and select the beginning and end of the target answer according to the question intent type.
[0046] In the second aspect of the embodiments of the present application,
[0047] Provides an auxiliary medical management system based on natural question answering and knowledge graph, including:
[0048] The first unit is used to extract the semantic vector of each word in the medical text using the pre-trained BERT model, input the semantic vector extracted by the BERT model into the BiLSTM layer for sequence encoding, and send the output vector of the BiLSTM layer to the CRF layer for sequence labeling. The global optimal label sequence is decoded through the dynamic programming algorithm to identify the medical entities in the medical text;
[0049] The second unit is used to convert natural language questions into question vectors using the pre-trained BERT model, calculate the similarity between the question vector and the embedding vectors of all entities in the pre-built medical knowledge graph, select multiple most similar entities as candidate answers, search for relationship paths related to the question vector on the medical knowledge graph starting from multiple most similar entities, and determine the knowledge triples that match the question vector;
[0050] The third unit is used to input medical entities, candidate answers and knowledge triples into three independent BiGRU encoders for feature extraction. The output of the BiGRU encoder is dynamically weighted and aggregated using the attention mechanism under the Seq2Seq framework as the attention context vector of the decoder at each time step. The decoder predicts the probability distribution of the next answer word based on the current hidden state, the attention context vector and the previously generated words, and generates the answer text in natural language form through maximum likelihood estimation.
[0051] According to a third aspect of the embodiments of the present invention,
[0052] An electronic device is provided, comprising:
[0053] processor;
[0054] a memory for storing processor-executable instructions;
[0055] The processor is configured to call the instructions stored in the memory to execute the aforementioned method.
[0056] A fourth aspect of the embodiments of the present invention is:
[0057] A computer-readable storage medium is provided, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the aforementioned method is implemented.
[0058] This application uses a pre-trained BERT model to extract the semantic features of medical texts, making full use of the domain-independent language knowledge learned by the BERT model on large-scale corpora to enhance the generalization and robustness of medical entity recognition. The BiLSTM+CRF sequence annotation architecture can effectively capture the contextual information and long-distance dependencies of medical entities, while using the CRF layer for global optimization to improve the accuracy of medical entity recognition. The globally optimal label sequence is decoded through a dynamic programming algorithm, avoiding the error propagation problem that may be caused by greedy decoding, making the recognition result more reliable.
[0059] In addition, the pre-trained BERT model is used to map natural language questions to semantic space, and a low-dimensional dense representation of the question vector is obtained, which effectively eliminates the vocabulary gap and improves the accuracy of question understanding. By calculating the similarity between the question vector and the entity embedding vector in the knowledge graph, the candidate answer entities related to the question are quickly and accurately retrieved, which reduces the search space and improves the efficiency of answer retrieval. Starting from the candidate answer entity, the relationship path related to the question is searched on the knowledge graph, which makes full use of the structured information of the knowledge graph, obtains rich and complete answer clues, and provides strong support for subsequent answer generation.
[0060] Furthermore, multi-source information such as medical entities, candidate answers, and knowledge triples are input into independent BiGRU encoders for feature extraction, making full use of the complementary information between questions, answers, and background knowledge to generate semantically rich and comprehensive answer representations. The attention mechanism is used in the Seq2Seq framework to dynamically weight and aggregate the encoder output, so that the decoder can adaptively allocate attention weights according to the current generated content, capture the key connection between questions and answers, and generate more coherent and fluent answer text. The answer generation process is optimized through maximum likelihood estimation, so that the conditional probability of the generated answer and the reference answer is maximized, improving the quality and readability of the answer. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] Figure 1 It is a flowchart of an auxiliary medical management method based on natural question answering and knowledge graph according to an embodiment of the present invention;
[0062] Figure 2 This is a structural diagram of an auxiliary medical management system based on natural question answering and knowledge graph according to an embodiment of the present invention. DETAILED DESCRIPTION
[0063] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0064] The technical solution of the present invention is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0065] Figure 1 FIG. 1 is a flow chart of an auxiliary medical management method based on natural question answering and knowledge graph according to an embodiment of the present invention. Figure 1 As shown, the method includes:
[0066] S101. Use the pre-trained BERT model to extract the semantic vector of each word in the medical text, input the semantic vector extracted by the BERT model into the BiLSTM layer for sequence encoding, send the output vector of the BiLSTM layer to the CRF layer for sequence labeling, decode the global optimal label sequence through the dynamic programming algorithm, and identify the medical entities in the medical text;
[0067] In an optional embodiment,
[0068] The output vector of the BiLSTM layer is sent to the CRF layer for sequence labeling. The global optimal label sequence is decoded through the dynamic programming algorithm to identify the medical entities in the medical text, including:
[0069] Determine an emission feature corresponding to an output vector of the BiLSTM layer, where the emission feature is used to measure the compatibility between the output vector of the BiLSTM layer and the label;
[0070] The label sequence is modeled using a conditional random field model, and the dependency between labels is characterized by emission features and transfer features, wherein the transfer features are used to characterize the dependency between adjacent labels;
[0071] The emission feature and the transfer feature are used in the inference stage of the conditional random field model, and an approximate decoding algorithm is used to recursively retain multiple candidate label sequences of each reasoning step, and the candidate label sequences exceeding a preset length threshold are terminated in advance;
[0072] Candidate label sequences whose cumulative probability is lower than the dynamic threshold are pruned, repeated label substrings in the candidate label sequence are merged, and illegal label combinations are pruned according to preset label constraint rules until the end of the sequence is reached, and the label sequence with the largest conditional probability is selected from the multiple candidate label sequences as the global optimal label sequence.
[0073] In an optional embodiment,
[0074] The approximate decoding algorithm is used to recursively retain multiple candidate label sequences for each reasoning step, including:
[0075]
[0076] in, represents the unnormalized probability of the bth optimal prefix label sequence obtained in the i-th step beam search, b represents the candidate sequence index retained in the beam search, and b' represents the candidate sequence index retained in the previous step beam search; y i Represents the label of the current moment i; Indicates the end label of the b'th sequence in the previous step; represents the transfer feature value between adjacent labels; f() represents the emission feature function, and the measurement input represents the difference between X at position i and label y i compatibility; n represents the length of the input sequence.
[0077] For example,
[0078] Medical named entity recognition aims to extract key entity information such as drugs, diseases, symptoms, examinations, and treatments from unstructured medical texts. Traditional methods are mainly based on probabilistic graph models such as manually constructed feature templates and conditional random fields (CRFs). However, such methods are difficult to characterize the semantic information of words and rely on a large amount of feature engineering. In recent years, the development of deep learning technology has brought new breakthroughs in the task of named entity recognition. In particular, pre-trained language models such as BERT can significantly improve the performance of downstream NLP tasks by learning general language representations on large-scale unsupervised corpora.
[0079] This paper adopts a BERT-based sequence annotation architecture to achieve medical entity recognition. First, the input medical text is encoded using a pre-trained Chinese BERT model (such as RoBERTa-wwm-ext or MacBERT). Specifically, each character is converted into a corresponding word vector, and then the position vector and segment vector are concatenated and input into the multi-layer Transformer encoder of BERT to obtain the contextual semantic representation of each character position.
[0080] Secondly, a BiLSTM layer is connected on top of the BERT output to further extract contextual features of the input sequence. BiLSTM can capture both past and future sequence information, thereby obtaining a more comprehensive feature representation. The forward LSTM processes the BERT embedding vector of each character in the order of the text to obtain a series of hidden states. The reverse LSTM encodes in the opposite order. The hidden states of the two directional LSTMs are concatenated to obtain a sequence representation containing bidirectional semantic information.
[0081] Finally, a CRF layer is used after the BiLSTM layer to predict the entity label of each character. Compared with the simple Softmax multi-classification, CRF can consider the constraints and dependencies between adjacent labels and is more suitable for sequence labeling tasks. This paper adopts the BIO labeling system, that is, B (Begin) represents the beginning of the entity, I (Inside) represents the middle part of the entity, and O (Outside) represents the non-entity. For the medical field, different entity types such as diseases, drugs, and treatments can also be subdivided. The emission score of the CRF layer comes from the affine transformation of the hidden state of the BiLSTM and the label, and the transition score explicitly models the transition probability between labels. In the inference stage, the Viterbi dynamic programming algorithm is used to decode the globally optimal label sequence.
[0082] In addition, in order to classify medical intents at the same time, a fully connected layer and a Softmax layer can be connected to the output of the [CLS] position of BERT. [CLS] represents the aggregated representation of the entire input sequence, which can be well adapted to downstream classification tasks through fine-tuning. The fully connected layer maps the output of BERT to the intent label space, and the Softmax layer calculates the normalized probability of each intent category. Common medical intents include disease diagnosis, treatment plans, medication consultation, etc. This paper takes entity recognition and intent classification as two subtasks of multi-task learning, sharing the parameters of the BERT encoder.
[0083] When training the model, a joint objective function of multi-task learning is used. The loss function of the entity recognition task is the negative log-likelihood of CRF, and the loss function of the intent classification task is the cross entropy. The weighted sum of the two losses is used as the overall optimization goal, and the entire model is trained end-to-end. Experiments show that joint learning can improve the performance of the two tasks, which is better than training them separately.
[0084] In order to further improve the generalization and robustness of the model, this application also adopts the following strategies: randomly performing data augmentation operations such as word masking and position transposition in the input of BERT to increase the model's adaptability to noise; using FocalLoss instead of cross entropy loss to alleviate the problem of imbalanced medical data labels; using ensemble learning methods in the inference stage to vote or average the prediction results of multiple models to improve the reliability of the prediction.
[0085] On the CCKS2019 medical entity recognition dataset, the F1 value of this application model reached 92.5%, which is better than baseline methods such as BERT-CRF. Qualitative analysis found that this application model can handle professional terms and complex sentences in medical texts well, and identify key entities such as drugs and diseases. At the same time, the accuracy of intent classification also reached more than 95%, which is of great significance to the medical question-answering system. In general, the multi-task learning framework that integrates BERT, BiLSTM and CRF has achieved good results in the recognition of medical entities and intents.
[0086] Exemplarily, medical entity recognition is essentially a sequence labeling problem, that is, assigning a predefined entity type label to each token in the input text. The traditional softmax multi-classification method assumes that the labels are independent of each other and ignores the existing contextual constraints. For example, in the BIO labeling system, the I label cannot be directly followed by the O label, and the starting B label of the drug entity is often followed by the I label, etc. In order to model the overall dependency of the label sequence, the present application adds a conditional random field (CRF) layer after the BiLSTM layer.
[0087] CRF is a log-linear model that defines the conditional probability over the entire label sequence. In this application, the affine transformation of the hidden state of the BiLSTM layer and the label is used as the emission feature, and the training goal of the CRF layer is to maximize the log-likelihood function of the training data.
[0088] In the inference phase, CRF needs to find the label sequence with the largest conditional probability. This optimization problem can be solved by the Viterbi dynamic programming algorithm. The Viterbi algorithm uses the "Viterbi variable" to record the local optimal state sequence up to each position, and then uses the properties of the local optimal substructure to recursively calculate the global optimal solution.
[0089] The time complexity of the Viterbi algorithm is O(nK^2), where n is the sequence length and K is the number of labels. In practice, since the BiLSTM layer can already learn the dependencies between local labels, the transfer matrix is often sparse. Therefore, some acceleration strategies, such as beam search and pruning, can be used to improve decoding efficiency while ensuring performance.
[0090] This application uses the CRF layer to model the overall dependency of the label sequence, and uses the Viterbi dynamic programming algorithm for global optimal decoding, which effectively improves the accuracy and consistency of medical entity recognition. Experiments show that compared with local classification models such as BiLSTM+Softmax, adding the CRF layer can increase the F1 value by an average of 1 to 2 percentage points. Qualitative analysis found that CRF is particularly effective in identifying entity boundaries and eliminating errors such as misjudgment of labels.
[0091] In addition, medical entity recognition is essentially a sequence labeling problem, that is, assigning a predefined entity type label to each token in the input text. In order to model the overall dependency of the label sequence, this paper adds a conditional random field (CRF) layer after the BiLSTM layer. CRF is a log-linear model that defines the conditional probability over the entire label sequence. This optimization problem can be solved by the Viterbi dynamic programming algorithm. However, the naive Viterbi algorithm requires an exhaustive enumeration of all possible label sequences, and the time complexity is relatively high. In order to improve decoding efficiency, this application further adopts acceleration strategies such as beam search and pruning.
[0092] Beam search is a heuristic graph search algorithm that avoids exhaustive search in the search space by retaining the most likely B partial candidate results at each step.
[0093] In order to further speed up the search process, this paper also adopts a variety of pruning strategies, including:
[0094] Sequence length pruning: During the search process, if the length of the candidate sequence exceeds the maximum length of the entity, the expansion of the sequence is terminated early.
[0095] Probability threshold pruning: If the cumulative probability α of a candidate sequence is lower than a fraction of the maximum probability in the current beam, it is considered a suboptimal solution and pruned in advance.
[0096] Repeated substring pruning: If repeated label substrings (such as multiple consecutive I labels) appear in the candidate sequence, they are merged into one substring to reduce repeated searches.
[0097] Label constraint pruning: According to the constraint rules between labels (such as a B label can only be followed by an I label), some illegal label combinations are removed in advance to narrow the search scope.
[0098] Through beam search and pruning, the decoder of the present application has achieved a good balance between time cost and recognition performance. On the one hand, beam search reduces the search complexity from exponential level to polynomial level, which basically meets the needs of real-time inference. On the other hand, appropriate pruning does not significantly reduce the decoding quality, but further shortens the decoding time.
[0099] On the CCKS2019 medical entity recognition dataset, the BiLSTM-CRF model of this application uses a beam size of 5 and enables the above pruning strategy, which ultimately reduces the average decoding speed from the original 350ms to 25ms, basically achieving real-time medical entity recognition, and the F1 value reaches an industry-leading level of 92.5%. Compared with the naive Viterbi algorithm, the accelerated decoder shortens the inference time by more than one order of magnitude, while the performance degradation is controlled within 1%.
[0100] S102. Use the pre-trained BERT model to convert the natural language question into a question vector, calculate the similarity between the question vector and the embedding vectors of all entities in the pre-built medical knowledge graph, select multiple most similar entities as candidate answers, search for relationship paths related to the question vector on the medical knowledge graph starting from the multiple most similar entities, and determine the knowledge triples matching the question vector;
[0101] In an optional embodiment,
[0102] Select multiple most similar entities as candidate answers, and use the multiple most similar entities as starting points to search for relationship paths related to the question vector on the medical knowledge graph. Determine the knowledge triples that match the question vector, including:
[0103] Get the vector representation of the target question, calculate the similarity between the question vector and the entity vectors in the knowledge graph, and select the k entities with the highest similarity as the starting points of the candidate answers;
[0104] Taking the starting point of the candidate answer as the center, a top-k jumping search strategy is adopted to search for a relationship path whose length does not exceed a preset threshold L on the knowledge graph to obtain a set of candidate relationship paths, wherein the top-k jumping search strategy selects the k nodes with the highest similarity in each jump, and selects the k nodes with the highest comprehensive similarity from the entire search process, and the similarity between the candidate relationship path and the question vector is calculated using an encoder based on an attention mechanism;
[0105] For each candidate relationship path in the candidate relationship path set, extract all knowledge triples contained therein, and adopt a multi-granularity scoring mechanism to calculate the relevance of each knowledge triple with the target problem. The multi-granularity scoring mechanism includes single-granularity scoring, double-granularity scoring and overall scoring. The single-granularity scoring considers the similarity between the head entity, relationship and tail entity of the triple and the problem. The double-granularity scoring considers the similarity between the combination of the head entity-relationship, relationship-tail entity and head entity-tail entity of the triple and the problem. The overall scoring considers the similarity between the entire triple and the problem.
[0106] According to the relevance of each knowledge triple obtained by the multi-granularity scoring mechanism and combined with the preset weights, the final comprehensive relevance score of each knowledge triple is calculated, and the tail entity of the knowledge triple with the highest score is selected as the final answer to the target question; if the tail entities of different knowledge triples are inconsistent, the tail entity of the knowledge triple with the highest comprehensive relevance score of the corresponding candidate relationship path is selected as the final answer.
[0107] For example, the core challenge of medical knowledge question answering is how to accurately find evidence fragments related to the question from massive heterogeneous knowledge. Traditional information retrieval methods often have difficulty handling multi-hop relational reasoning involved in complex questions. To this end, this paper proposes a multi-hop relational path reasoning method based on knowledge graph, which searches for relational paths matching the question vector on the medical knowledge graph to obtain the multi-hop reasoning evidence required for the question.
[0108] Specifically, we first calculate the similarity between the question vector and all entity vectors in the knowledge graph, and select the top-k most similar entities as the starting points for candidate answers. Then, starting from each candidate entity, we search for a relational path of length L on the knowledge graph. The path search process adopts a breadth-first strategy, that is, all outgoing edges of the current node are expanded first, and then the next layer of nodes is expanded further. In order to introduce question relevance to guide path search, the semantic similarity between the candidate path and the question is evaluated at each expansion, and the paths with similarity below the threshold are pruned.
[0109] In addition, during the path search process, a constraint-based pruning strategy is applied to further improve the search efficiency:
[0110] Path length constraint: The maximum search depth L is set in advance, and paths exceeding L hops will be terminated early. This can prevent the search space from being too large.
[0111] Entity type constraints: Based on the types of questions and answers, limit the entity types that can be expanded at each hop. For example, for a "disease-drug" type question, the odd-numbered hops of the path can only be disease entities, and the even-numbered hops can only be drug entities.
[0112] Relationship type constraints: Based on domain knowledge, some relationship types that are not allowed are predefined. For example, the Drug entity cannot point to the Symptom entity through the "has_symptom" relationship.
[0113] Finally, for all the paths obtained by the search, the knowledge triples contained in them are extracted, and the relevance of each triple to the question is evaluated. The triple with the highest score is selected as the supporting evidence, and the final answer is determined based on the tail entity of the triple. If the answers obtained by different paths are inconsistent, the answer from the highest scoring path is selected.
[0114] In an optional embodiment,
[0115] Taking the starting point of the candidate answer as the center, a top-k jumping search strategy is adopted to search for relationship paths whose length does not exceed the preset threshold L on the knowledge graph, and the candidate relationship path set obtained includes:
[0116] Get the text description vector of the current node in the knowledge graph and the vector representation of the question, and calculate the cosine similarity of the two vectors as the semantic similarity scoring item;
[0117] The semantic similarity scoring item is weightedly summed with the original scoring item based on the Euclidean distance of the TransE embedding vector to obtain an improved node scoring function, wherein the improved node scoring function is used to evaluate the relevance of the node to the question;
[0118] The entity importance weight is calculated based on the frequency of occurrence of the entity in the knowledge graph. The higher the frequency of occurrence of the entity, the lower its importance weight;
[0119] Introduce entity importance weights into the improved node scoring function to adjust the scoring results;
[0120] A path encoder based on the attention mechanism is used to represent the relationship path. The path attention weight is calculated according to the similarity between the problem vector and each relationship vector in the path. The path vector is obtained by weighted summation, and multiple path vectors are summarized to obtain a set of candidate relationship paths.
[0121] For example, the question vector is used to calculate the similarity with all entity vectors in the knowledge graph, and the top-k most similar entities are selected as the starting points of the candidate answers. The similarity calculation uses cosine similarity.
[0122] Taking each candidate entity as the starting point, a relation path of length L is searched on the knowledge graph. The path search process adopts a top-k jumping strategy, taking into account the top-k nodes of each layer and the entire search process.
[0123] Initialize the empty path set P = {} and the candidate node set N = {e_1, e_2, ..., e_k}.
[0124] Repeat the following process for L rounds:
[0125] a. Initialize the candidate path set P_l = {};
[0126] b. For each candidate node e_i∈N:
[0127] i. Find all neighbor nodes {n_j} connected to e_i through one-hop relationship r_j;
[0128] ii. Concatenate e_i and each n_j to form a new candidate path p_ij, and calculate the similarity between p_ij and question q;
[0129] iii. Add p_ij to P_l;
[0130] c. Select the top-k paths with the highest problem similarity from P_l and add them to P;
[0131] d. Select the end nodes corresponding to the top-k paths with the highest problem similarity from P as the new candidate node set N;
[0132] Output the final candidate path set P.
[0133] When splicing paths, a path encoder based on the attention mechanism is used to calculate the similarity between the candidate path p_ij and the question q.
[0134] At the same time, the search process applies constraints based on entity type and relationship type. For the current node e_i, only the outgoing edges r_j allowed by its type are expanded, and the type of the target entity n_j of r_j is constrained.
[0135] All knowledge triples {t_i} contained in the final candidate path set P are extracted, and the relevance of the triples to the problem is evaluated based on a multi-granularity scoring mechanism.
[0136] Single particle size rating:
[0137] score(q, t_i)=sim(q, h_i)+sim(q, r_i)+sim(q, t_i);
[0138] Dual Granularity Scoring:
[0139] score_h(q, t_i)=sim(q, concat(h_i, r_i));
[0140] score_t(q,t_i)=sim(q,concat(r_i,t_i));
[0141] score_ht(q, t_i)=sim(q, concat(h_i, t_i));
[0142] Overall rating:
[0143] score_hrt(q, t_i)=sim(q, concat(h_i, r_i, t_i));
[0144] Final relevance score:
[0145] score(q,t_i)=score(q,t_i)+λ_1score_h(q,t_i)+λ_2score_t(q,t_i)+λ_3score_ht(q,t_i)+λ_4score_hrt(q,t_i).
[0146] According to the final score of the knowledge triples, the tail entity pointed to by the triple with the highest score is selected as the final answer. If different triples point to different answers, the answer corresponding to the triple with the highest total score is selected.
[0147] In an optional embodiment,
[0148] Introducing entity importance weights into the improved node scoring function includes:
[0149] Score(e k )=α * (-||e ans +r path -e k ||2)+β * sim(e k , Q)+γ * w(e k );
[0150] Among them, e k represents the kth node, α * , β * , γ * They represent the coefficients of path relevance coefficient, semantic similarity coefficient, and entity importance weight respectively, e ans 、r path They represent the candidate answer entity and relationship path vectors respectively, Q represents the question vector, and w represents the entity importance weight.
[0151] For example, in the knowledge graph, entities are connected by multiple relationship paths, which contain rich semantic information. In order to extract the relationship paths related to the question from the knowledge graph, this application proposes a top-k jumping search strategy. This strategy takes the candidate answer entity as the starting point, searches for the relationship path whose length does not exceed the preset threshold L on the knowledge graph, and obtains the candidate relationship path set.
[0152] Specifically, the knowledge graph is set to G = (E, R), where E is the entity set and R is the relationship set. For the candidate answer entity e_ans, first add it to the node queue to be expanded Q. Then, take the k nodes with the highest scores from Q, add their unvisited neighbor nodes to Q, and record the relationship and path from the current node to the neighbor node. Repeat the above process until the queue is empty or the maximum search length L is reached.
[0153] During the search process, a TransE-based scoring function is used to evaluate the priority of nodes. TransE is a knowledge graph representation learning method that embeds both entities and relations into the same continuous vector space and assumes that for a real triple (h, r, t), its embedding vector should satisfy h+r≈t. Therefore, for the candidate answer entity e_ans and the current node e_i, the more relevant the path between them, the smaller the deviation of e_i's TransE embedding vector from e_ans+r_path.
[0154] In actual implementation, in order to improve search efficiency, all entities in the knowledge graph can be pre-embedded with TransE, and the embedding vectors can be quickly retrieved using the approximate nearest neighbor (ANN) index. In addition, since there are a large number of high-frequency entities and relationships in the knowledge graph, in order to avoid the search space being too large, an upper threshold of the frequency of occurrence can be set to filter out some very common entities and relationships.
[0155] After the search is completed, all relationship paths with a length not exceeding L starting from the candidate answer entity can be obtained. Furthermore, these paths can be filtered and sorted to select the top-K paths most relevant to the question as the candidate relationship path set. The filtering and sorting strategy can comprehensively consider factors such as path length, semantic similarity of entities and relationships on the path, etc. In order to intuitively demonstrate the search process, a simple example is given below. Assume that the following triples exist in the knowledge graph:
[0156] (Tonsillitis, causes, recurrent inflammation of the tonsils);
[0157] (recurrent tonsillitis, related diseases, chronic pharyngitis);
[0158] (Chronic pharyngitis, treatment methods, antibiotics);
[0159] (chronic pharyngitis, complications, otitis media);
[0160] Given the question "What are the complications of tonsillitis?", and the candidate answer entity "tonsillitis".
[0161] Through top-k jump search, we can get the following two candidate relationship paths:
[0162] Tonsillitis -- Causes -> Recurrent inflammation of tonsils -- Related diseases -> Chronic pharyngitis -- Complications -> Otitis media;
[0163] Tonsillitis -- Cause -> Repeated inflammation of tonsils -- Related diseases -> Chronic pharyngitis;
[0164] The first path shows that "otitis media" is a complication of "tonsillitis". Although the second path does not directly derive complications, it provides useful background information "chronic pharyngitis". These two paths capture the complex semantic relationship between questions and answers, which helps to generate complete and reasonable answer texts.
[0165] In summary, the top-k jumping search strategy uses the structured characteristics of the knowledge graph to start from the candidate answer entity and purposefully search for the relationship path related to the question, which not only reduces the search space but also obtains rich semantic information. In the subsequent answer generation, these relationship paths can serve as important knowledge basis to guide the model to produce coherent and accurate natural language expressions.
[0166] S103. The medical entity, candidate answer and knowledge triples are respectively input into three independent BiGRU encoders for feature extraction. The output of the BiGRU encoder is dynamically weighted and aggregated using the attention mechanism under the Seq2Seq framework as the attention context vector of the decoder at each time step. The decoder predicts the probability distribution of the next answer word based on the current hidden state, the attention context vector and the previously generated words, and generates the answer text in natural language form through maximum likelihood estimation.
[0167] In an optional embodiment,
[0168] In the Seq2Seq framework, the attention mechanism is used to dynamically weight the output of the BiGRU encoder as the attention context vector of each time step of the decoder. The decoder predicts the probability distribution of the next answer word based on the current hidden state, the attention context vector, and the previously generated words, and generates the answer text in natural language form through maximum likelihood estimation, including:
[0169] The question, the candidate answer entity and the candidate answer relationship are respectively encoded using a bidirectional GRU to obtain a question encoding vector, a candidate answer entity encoding vector and a candidate answer relationship encoding vector. The bidirectional GRU can simultaneously utilize past and future context information to obtain a more comprehensive semantic representation.
[0170] At each step, the decoder calculates the attention weights of all question encoding vectors, candidate answer entity encoding vectors, and candidate answer relationship encoding vectors based on the current hidden state, and obtains the attention context vector by weighted summation. The attention mechanism enables the decoder to adaptively focus on different encoding information.
[0171] The current decoder hidden state is concatenated with the attention context vector and passed through the fully connected layer and the Softmax layer to obtain the probability distribution of the answer token at the current time step.
[0172] Sampling or selecting the token with the highest probability from the probability distribution as the prediction output at the current moment, and inputting it into the decoder at the next moment, until the end-of-sentence marker is encountered, generating a complete answer text;
[0173] The teacher forcing strategy is used during training, where the true answer token is input into the decoder at each step; during inference, the next token is sampled based on the prediction at the current moment;
[0174] Heuristic rules are introduced to constrain the decoding process and select the beginning and end of the target answer according to the question intent type.
[0175] Exemplarily, the input natural language question Q = [q_1, q_2, ..., q_n] is converted into a one-hot vector or a word embedding vector. The question is encoded using a bidirectional GRU; similarly, for the candidate answer entity set E = {e_1, e_2, ..., e_m}, each entity e_i is represented as a one-hot vector or an entity embedding vector. For the candidate answer relation set R = {r_1, r_2, ..., r_k}, each relation r_i is represented as a one-hot vector or a relation embedding vector.
[0176] At each step of the decoder, the attention weights of the current hidden state s_t and the question encoding vector, the candidate answer entity encoding vector, and the candidate answer relationship encoding vector are calculated. The encoding vector is weighted summed using the attention weights to obtain the attention context vector;
[0177] Concatenate the current hidden state with the attention context vector, and calculate the probability distribution of the answer token at the current time step through the fully connected layer and the Softmax layer; sample or select the token with the largest probability from the probability distribution as the predicted output at the current moment; use the predicted output as the input of the decoder at the next moment, and update the hidden state at the same time; repeat the above steps until the end-of-sentence marker is encountered to generate a complete answer text.
[0178] During training, a teacher forcing strategy is adopted. At each step, the true answer token is input into the decoder and the cross entropy loss function is calculated. During inference, the next token is sampled according to the prediction at the current moment to generate the answer text.
[0179] Choose the appropriate answer opening and closing according to the question's intended type (such as whether, why, how, etc.). For example, for whether, why, etc., you can limit the answer opening to "yes" or "no"; for why, etc., you can limit the answer opening to "because", "due to", etc. During the decoding process, generate reasonable and coherent answer text according to the constraints.
[0180] This application uses a pre-trained BERT model to extract the semantic features of medical texts, making full use of the domain-independent language knowledge learned by the BERT model on large-scale corpora to enhance the generalization and robustness of medical entity recognition. The BiLSTM+CRF sequence annotation architecture can effectively capture the contextual information and long-distance dependencies of medical entities, while using the CRF layer for global optimization to improve the accuracy of medical entity recognition. The globally optimal label sequence is decoded through a dynamic programming algorithm, avoiding the error propagation problem that may be caused by greedy decoding, making the recognition result more reliable.
[0181] In addition, the pre-trained BERT model is used to map natural language questions to semantic space, and a low-dimensional dense representation of the question vector is obtained, which effectively eliminates the vocabulary gap and improves the accuracy of question understanding. By calculating the similarity between the question vector and the entity embedding vector in the knowledge graph, the candidate answer entities related to the question are quickly and accurately retrieved, which reduces the search space and improves the efficiency of answer retrieval. Starting from the candidate answer entity, the relationship path related to the question is searched on the knowledge graph, which makes full use of the structured information of the knowledge graph, obtains rich and complete answer clues, and provides strong support for subsequent answer generation.
[0182] Furthermore, multi-source information such as medical entities, candidate answers, and knowledge triples are input into independent BiGRU encoders for feature extraction, making full use of the complementary information between questions, answers, and background knowledge to generate semantically rich and comprehensive answer representations. The attention mechanism is used in the Seq2Seq framework to dynamically weight and aggregate the encoder output, so that the decoder can adaptively allocate attention weights according to the current generated content, capture the key connection between questions and answers, and generate more coherent and fluent answer text. The answer generation process is optimized through maximum likelihood estimation, so that the conditional probability of the generated answer and the reference answer is maximized, improving the quality and readability of the answer.
[0183] Figure 2 FIG. 1 is a schematic diagram of the structure of an auxiliary medical management system based on natural question answering and knowledge graph according to an embodiment of the present invention. Figure 2 As shown, the system comprises:
[0184] The first unit is used to extract the semantic vector of each word in the medical text using the pre-trained BERT model, input the semantic vector extracted by the BERT model into the BiLSTM layer for sequence encoding, and send the output vector of the BiLSTM layer to the CRF layer for sequence labeling. The global optimal label sequence is decoded through the dynamic programming algorithm to identify the medical entities in the medical text;
[0185] The second unit is used to convert natural language questions into question vectors using the pre-trained BERT model, calculate the similarity between the question vector and the embedding vectors of all entities in the pre-built medical knowledge graph, select multiple most similar entities as candidate answers, search for relationship paths related to the question vector on the medical knowledge graph starting from multiple most similar entities, and determine the knowledge triples that match the question vector;
[0186] The third unit is used to input medical entities, candidate answers and knowledge triples into three independent BiGRU encoders for feature extraction. The output of the BiGRU encoder is dynamically weighted and aggregated using the attention mechanism under the Seq2Seq framework as the attention context vector of the decoder at each time step. The decoder predicts the probability distribution of the next answer word based on the current hidden state, the attention context vector and the previously generated words, and generates the answer text in natural language form through maximum likelihood estimation.
[0187] According to a third aspect of the embodiments of the present invention,
[0188] An electronic device is provided, comprising:
[0189] processor;
[0190] a memory for storing processor-executable instructions;
[0191] The processor is configured to call the instructions stored in the memory to execute the aforementioned method.
[0192] A fourth aspect of the embodiments of the present invention is:
[0193] A computer-readable storage medium is provided, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the aforementioned method is implemented.
[0194] The present invention may be a method, an apparatus, a system and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for executing various aspects of the present invention.
[0195] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. An auxiliary medical management method based on natural question answering and knowledge graph, characterized in that: include: Use the pre-trained BERT model to extract the semantic vector of each word in the medical text, input the semantic vector extracted by the BERT model into the BiLSTM layer for sequence encoding, send the output vector of the BiLSTM layer to the CRF layer for sequence labeling, and decode the global optimal label sequence through the dynamic programming algorithm to identify the medical entities in the medical text; Use the pre-trained BERT model to convert natural language questions into question vectors, calculate the similarity between the question vector and the embedding vectors of all entities in the pre-built medical knowledge graph, select multiple most similar entities as candidate answers, search for relationship paths related to the question vector on the medical knowledge graph starting from multiple most similar entities, and determine the knowledge triples that match the question vector; The medical entity, candidate answer and knowledge triples are respectively input into three independent BiGRU encoders for feature extraction. The output of the BiGRU encoder is dynamically weighted and aggregated using the attention mechanism under the Seq2Seq framework as the attention context vector of the decoder at each time step. The decoder predicts the probability distribution of the next answer word based on the current hidden state, the attention context vector and the previously generated words, and generates the answer text in natural language form through maximum likelihood estimation.
2. The method according to claim 1, characterized in that The output vector of the BiLSTM layer is sent to the CRF layer for sequence labeling. The global optimal label sequence is decoded through the dynamic programming algorithm to identify the medical entities in the medical text, including: Determine an emission feature corresponding to an output vector of the BiLSTM layer, where the emission feature is used to measure the compatibility between the output vector of the BiLSTM layer and the label; The label sequence is modeled using a conditional random field model, and the dependency between labels is characterized by emission features and transfer features, wherein the transfer features are used to characterize the dependency between adjacent labels; The emission feature and the transfer feature are used in the inference stage of the conditional random field model, and an approximate decoding algorithm is used to recursively retain multiple candidate label sequences of each reasoning step, and the candidate label sequences exceeding a preset length threshold are terminated in advance; Candidate label sequences whose cumulative probability is lower than the dynamic threshold are pruned, repeated label substrings in the candidate label sequence are merged, and illegal label combinations are pruned according to preset label constraint rules until the end of the sequence is reached, and the label sequence with the largest conditional probability is selected from the multiple candidate label sequences as the global optimal label sequence.
3. The method according to claim 2, characterized in that The approximate decoding algorithm is used to recursively retain multiple candidate label sequences for each reasoning step, including: in, represents the unnormalized probability of the bth optimal prefix label sequence obtained in the i-th step beam search, b represents the candidate sequence index retained in the beam search, and b' represents the candidate sequence index retained in the previous step beam search; y i Represents the label of the current moment i; Indicates the end tag of the b'th sequence in the previous step; represents the transfer feature value between adjacent labels; f() represents the emission feature function, and the measurement input represents the difference between X at position i and label y i compatibility; n represents the length of the input sequence.
4. The method according to claim 1, characterized in that: Select multiple most similar entities as candidate answers, and use the multiple most similar entities as starting points to search for relationship paths related to the question vector on the medical knowledge graph. Determine the knowledge triples that match the question vector, including: Get the vector representation of the target question, calculate the similarity between the question vector and the entity vectors in the knowledge graph, and select the k entities with the highest similarity as the starting points of the candidate answers; Taking the starting point of the candidate answer as the center, a top-k jumping search strategy is adopted to search for a relationship path whose length does not exceed a preset threshold L on the knowledge graph to obtain a set of candidate relationship paths, wherein the top-k jumping search strategy selects the k nodes with the highest similarity in each jump, and selects the k nodes with the highest comprehensive similarity from the entire search process, and the similarity between the candidate relationship path and the question vector is calculated using an encoder based on an attention mechanism; For each candidate relationship path in the candidate relationship path set, extract all knowledge triples contained therein, and adopt a multi-granularity scoring mechanism to calculate the relevance of each knowledge triple with the target problem. The multi-granularity scoring mechanism includes single-granularity scoring, double-granularity scoring and overall scoring. The single-granularity scoring considers the similarity between the head entity, relationship and tail entity of the triple and the problem. The double-granularity scoring considers the similarity between the combination of the head entity-relationship, relationship-tail entity and head entity-tail entity of the triple and the problem. The overall scoring considers the similarity between the entire triple and the problem. According to the relevance of each knowledge triple obtained by the multi-granularity scoring mechanism and combined with the preset weights, the final comprehensive relevance score of each knowledge triple is calculated, and the tail entity of the knowledge triple with the highest score is selected as the final answer to the target question; if the tail entities of different knowledge triples are inconsistent, the tail entity of the knowledge triple with the highest comprehensive relevance score of the corresponding candidate relationship path is selected as the final answer.
5. The method according to claim 4, characterized in that Taking the starting point of the candidate answer as the center, a top-k jumping search strategy is adopted to search for relationship paths whose length does not exceed the preset threshold L on the knowledge graph, and the candidate relationship path set obtained includes: Get the text description vector of the current node in the knowledge graph and the vector representation of the question, and calculate the cosine similarity of the two vectors as the semantic similarity scoring item; The semantic similarity scoring item is weightedly summed with the original scoring item based on the Euclidean distance of the TransE embedding vector to obtain an improved node scoring function, wherein the improved node scoring function is used to evaluate the relevance of the node to the question; The entity importance weight is calculated based on the frequency of occurrence of the entity in the knowledge graph. The higher the frequency of occurrence of the entity, the lower its importance weight; Introduce entity importance weights into the improved node scoring function to adjust the scoring results; A path encoder based on the attention mechanism is used to represent the relationship path. The path attention weight is calculated according to the similarity between the problem vector and each relationship vector in the path. The path vector is obtained by weighted summation, and multiple path vectors are summarized to obtain a set of candidate relationship paths.
6. The method according to claim 5, characterized in that Introducing entity importance weights into the improved node scoring function includes: Score(e) k )=a * (-||e ans +r path -e k ||2)+b * sim(e k ,Q)+γ * w(e k ); Among them, e k represents the kth node, α * , β * , γ * They represent the coefficients of path relevance coefficient, semantic similarity coefficient, and entity importance weight respectively, e ans 、r path They represent the candidate answer entity and relationship path vectors respectively, Q represents the question vector, and w represents the entity importance weight.
7. The method according to claim 1, characterized in that In the Seq2Seq framework, the attention mechanism is used to dynamically weight the output of the BiGRU encoder as the attention context vector of each time step of the decoder. The decoder predicts the probability distribution of the next answer word based on the current hidden state, the attention context vector, and the previously generated words, and generates the answer text in natural language form through maximum likelihood estimation, including: The question, the candidate answer entity and the candidate answer relationship are respectively encoded using a bidirectional GRU to obtain a question encoding vector, a candidate answer entity encoding vector and a candidate answer relationship encoding vector. The bidirectional GRU can simultaneously utilize past and future context information to obtain a more comprehensive semantic representation. At each step, the decoder calculates the attention weights of all question encoding vectors, candidate answer entity encoding vectors, and candidate answer relationship encoding vectors based on the current hidden state, and obtains the attention context vector by weighted summation. The attention mechanism enables the decoder to adaptively focus on different encoding information. The current decoder hidden state is concatenated with the attention context vector and passed through the fully connected layer and the Softmax layer to obtain the probability distribution of the answer token at the current time step. Sampling or selecting the token with the highest probability from the probability distribution as the prediction output at the current moment, and inputting it into the decoder at the next moment, until the end-of-sentence marker is encountered, generating a complete answer text; The teacher forcing strategy is used during training, where the true answer token is input into the decoder at each step; during inference, the next token is sampled based on the prediction at the current moment; Heuristic rules are introduced to constrain the decoding process and select the beginning and end of the target answer according to the question intent type.
8. An auxiliary medical management system based on natural question answering and knowledge graph, used to implement the method described in any one of claims 1 to 7, characterized in that: include: The first unit is used to extract the semantic vector of each word in the medical text using the pre-trained BERT model, input the semantic vector extracted by the BERT model into the BiLSTM layer for sequence encoding, and send the output vector of the BiLSTM layer to the CRF layer for sequence labeling. The global optimal label sequence is decoded through the dynamic programming algorithm to identify the medical entities in the medical text; The second unit is used to convert natural language questions into question vectors using the pre-trained BERT model, calculate the similarity between the question vector and the embedding vectors of all entities in the pre-built medical knowledge graph, select multiple most similar entities as candidate answers, search for relationship paths related to the question vector on the medical knowledge graph starting from multiple most similar entities, and determine the knowledge triples that match the question vector; The third unit is used to input medical entities, candidate answers and knowledge triples into three independent BiGRU encoders for feature extraction. The output of the BiGRU encoder is dynamically weighted and aggregated using the attention mechanism under the Seq2Seq framework as the attention context vector of the decoder at each time step. The decoder predicts the probability distribution of the next answer word based on the current hidden state, the attention context vector and the previously generated words, and generates the answer text in natural language form through maximum likelihood estimation.
9. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to call the instructions stored in the memory to execute the method described in any one of claims 1 to 7.
10. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Industrial knowledge graph question answering method based on large language model and computer readable medium
CN118861259A
Multi-scene intelligent question and answer management system and method based on artificial intelligence
CN119025661A
LLM problem optimization method combined with enterprise portrait, medium and system
CN119046447A
Page information pushing method applied to user health management and intelligent nursing system
CN119311957A
Page information push method and intelligent nursing system applied to user health management
CN119311957B
