Medical automatic question and answer method and system based on common sense fusion

By constructing a medical automated question-answering system based on common sense fusion, and utilizing a multi-layer partitioned transformer encoder to fuse common sense and knowledge base information, the system solves the problem of existing systems' limitations on question types, generates answers that conform to human language habits and professionalism, and improves user experience and question-answering effectiveness in the medical field.

CN114385799BActive Publication Date: 2025-12-30SHANGHAI JIAOTONG UNIV
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202111552888.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-17
Publication Date
2025-12-30
Estimated Expiration
2041-12-17

AI Technical Summary

Technical Problem

Existing medical question-answering systems cannot effectively integrate common sense knowledge, resulting in limitations on question types, poor user experience, and a lack of professional domain knowledge, making them unsuitable for application in the medical field.

Method used

By segmenting and querying entity relationships in the training statements, entity relationship triples are constructed. Information from the common sense base and knowledge base is integrated, and a multi-level partitioned transformer encoder is used to train the language model to generate answers that conform to human language habits and possess medical common sense.

Benefits of technology

It enables unlimited responses to question types, improves user experience, and generates professional answers that conform to grammatical rules in the medical field, thereby enhancing the model's understanding and reasoning capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114385799B_ABST
    Figure CN114385799B_ABST
Patent Text Reader

Abstract

The application provides a medical automatic question and answer method and system based on common sense fusion, comprising: performing word segmentation on training sentences, querying a common sense database and a knowledge base to obtain entity relationship triples; fusing and encoding the triples and the training sentences; randomly selecting part of entities of the fused and encoded training sentences to mask, replacing the next sentence into other random sentences according to a fixed probability, and inputting the obtained training corpus into a multi-layer partition encoder for training; performing word segmentation and entity relationship query on question sentences in question and answer data, and fusing and encoding; taking common sense fusion encoding sequences of the questions as model inputs, taking answers as supervision labels, training a common sense fusion language model; and building a visual medical automatic question and answer system, inputting questions into the model through a front end, and displaying outputs of the model as answers to an interface. The application has no type limitation on user questions, and fuses common sense and medical knowledge into a language model, thereby ensuring that answers conform to grammatical rules and improving professionalism.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of automated medical question answering, and more specifically, to a method and system for automated medical question answering based on common sense fusion. Background Technology

[0002] Automated medical question-and-answer systems can identify users' medical-related questions and provide answers automatically. Traditional search engines require users to extract and evaluate the search results themselves, while question-and-answer systems can automatically generate answers based on a knowledge base. For example, they can directly provide relevant answers to questions about diseases, medications, symptoms, and examinations, greatly benefiting users and reducing the workload of medical staff.

[0003] Existing medical question-answering systems typically only answer questions of a given type and generate answers with fixed syntax. Specifically, these systems first match the user's input question with keywords from a given question bank. Common questions include "Which department does this disease belong to?", "What are the commonly used medications for this disease?", and "What are the symptoms of this disease?". Then, the question type is determined, keywords are extracted, and relevant knowledge is retrieved from the knowledge base. Finally, an answer is generated according to the given syntax rules for the corresponding answer type. For example, a drug-related answer might be generated based on a fixed rule like "Common medications for disease XX include XXX". Such question-answering systems are too rigid, lack the ability to understand questions, and result in a poor user experience.

[0004] Another approach to building question-answering systems is end-to-end natural language generation based on language models. However, this method lacks domain common sense and knowledge. Specifically, by building an end-to-end model, it learns the maximum p(answer|question), enabling it to obtain the answer with the highest conditional probability after inputting a question. This type of method has a certain ability to understand questions, thus allowing for unrestricted question types, and the answers are more fluent and natural, resulting in a better user experience. However, current models are usually trained on large-scale open corpora, therefore they can only be applied to open domains and cannot be directly used in specialized fields such as medicine.

[0005] Existing methods have made some attempts to integrate knowledge and language models. Baidu proposed ERNIE in 2019 (Sun Y, Wang S, Li Y, et al. Ernie: Enhanced representation through knowledge integration[J]. arXiv preprint arXiv:1904.09223,2019.), modifying BERT's character masking method to a word masking method, which to some extent increases the knowledge in the corpus; however, this method does not consider the relationships between entities. Bosselut proposed COMET in 2019 (Bosselut A, Rashkin H, Sap M, et al. Comet: Commonsense transformers for automatic knowledge graph construction[J]. arXiv preprint arXiv:1906.05317,2019.), using triples from the knowledge base as training corpus, increasing the model's knowledge mastery; however, directly generating training sentences from the commonsense base for training is too costly. In 2020, Weijie Liu et al. proposed K-BERT (Liu W, Zhou P, Zhao Z, et al. K-bert: Enabling language representation with knowledge graph [C] / / Proceedings of the AAAI Conference on Artificial Intelligence. 2020, 34(03): 2901-2908.), which embeds triples from the knowledge graph into the training corpus, increasing the model's knowledge in professional domains. However, common sense can only be obtained through pre-trained models, and the semantic relationships between triples of different relation types are not considered.

[0006] Chinese patent document CN101373532 (Yu Zhengtao, Meng Xiangyan, Zhang Zhikun, et al. FAQ Chinese request-answering system implementing method in tourism field:, 2009.) discloses a method for implementing a tourism-related question-answering system that integrates a common knowledge base. This method, based on ontological principles, first manually defines terms and relationships within the tourism field, then merges data from a "tourism-related knowledge base" and the "knowledge base" "CNKI," constructing a common knowledge base on this basis. Finally, the question-answering system is built upon this self-constructed knowledge base. This patent proposes a method for calculating question similarity, which can categorize questions into a given type. Therefore, this method still requires limiting the types of questions.

[0007] Patent document CN112071429A discloses a technical field of automatic question answering, revealing a method for constructing a medical automatic question answering system based on knowledge graphs. The method includes: predefining entities, relationships, and attributes in a medical domain knowledge graph; acquiring medical domain data and annotating the data using an automatic data annotation algorithm based on the predefined medical domain knowledge graph; constructing a knowledge graph from the annotated data using a knowledge graph construction model; encoding the user's dialogue text using a dialogue encoder to obtain encoded dialogue text data; and using a knowledge graph-based reinforcement learning network to perform path inference on the encoded text data to obtain the user's intent path. The knowledge graph result pointed to by the intent path is the automatic question answering result. The invention also constructs a medical automatic question answering system based on knowledge graphs. However, this invention has limitations on the types of questions that can be asked. Summary of the Invention

[0008] In view of the deficiencies in the existing technology, the purpose of this invention is to provide a medical automatic question answering method and system based on common sense fusion.

[0009] A medical automatic question-answering method based on common sense fusion provided by the present invention includes:

[0010] Step S1: Segment the training statement into words, use the segmented words as keywords, and query the commonsense base and knowledge base to obtain entity relation triples;

[0011] Step S2: Fusion encoding of triples and training statements to integrate structured common sense data from the library with training statements;

[0012] Step S3: Randomly select some entities to mask after the training sentence is fused and encoded, replace the next sentence with other random sentences with a fixed probability, and input the obtained training corpus into the multi-layer partition transformer encoder for training to obtain a preliminary common sense fusion language model.

[0013] Step S4: Perform word segmentation and entity relation query on the questions in the question-answer data, and perform common sense fusion encoding to obtain the common sense fusion encoding sequence of the questions;

[0014] Step S5: The common sense fusion encoding sequence of the question is used as the input to the model, and the answer is used as the supervision label. Based on supervised learning, a common sense fusion language model is trained.

[0015] Step S6: Build a visual medical automatic question-and-answer system. Input questions into a common sense fusion language model through the front-end interface, and display the model's output as the answer on the interface.

[0016] Preferably, the multi-layer partitioned transformer encoder refers to a transformer encoder that considers common sense fusion information. The statement that incorporates common sense is no longer a one-dimensional statement, but a two-dimensional statement with common sense. Each relationship in it is a partition, and there are different attentions between partitions. Therefore, before calculating the attention between characters, it is necessary to calculate the attention between partitions. In this way, common sense information can be learned into the model.

[0017] Preferably, in step S2:

[0018] Step S2.1: Add to the beginning of sentences in the training corpus <cls>Mark, add at the end of the sentence <sep>logo;

[0019] Step S2.2: Assign numbers to the common sense triplet and the training corpus. The numbering has an adjustment function for the attention weight during later training. In this way, common sense and training sentences are integrated.

[0020] Step S2.2.1: From <cls>Initially, each character is assigned a number, starting from 1 and incrementing;

[0021] Step S2.2.2: Classify the triples according to their relationships;

[0022] Step S2.2.3: The tail entity number of each type of relation is incremented sequentially from the head entity number, and the length of the longest tail entity is denoted as l;

[0023] Step S2.2.4: Assign a relation number to each type of relation, starting from 1 and incrementing;

[0024] Step S2.2.5: Increase the character number of each character following the header entity by 1;

[0025] Step S2.3: Append the triplet tail entities with assigned numbers to the end of the statement to form a one-dimensional sequence;

[0026] In step S4:

[0027] The questions in the question-and-answer data are segmented into words and entity relationships are queried and common sense fusion encoding is performed. The common sense fusion encoding sequence of the questions is obtained according to the method in step S2.

[0028] Preferably, in step S3:

[0029] Step S3.1: Count the positions of entities in the sequence;

[0030] Step S3.2: Mask entities according to probability and train the model to learn context and common sense;

[0031] Step S3.2.1: Mask the head entity according to probability p1, replacing each character of the head entity with... <mask>;

[0032] Step S3.2.2: If the head entity is masked, the tail entity is not masked;

[0033] Step S3.2.3: If the head entity is not masked, then the tail entity is masked according to probability p2, and each character of the tail entity is replaced with... <mask>;

[0034] Step S3.2.4: Take the obtained sequence as input and pass it into the multi-layer partition transformer to train the masked entities as labels;

[0035] Step S3.3: Replace the next sentence in the training corpus with a certain probability, and train the model to learn the relationship between the next and next sentences.

[0036] Preferably, in step S5:

[0037] Step S5.1: Input the question sequence after common sense fusion encoding into the multi-layer partition transformer encoder;

[0038] Step S5.2: Use the output of the last partition transformer encoder as the input of the decoder;

[0039] Step S5.3: The answers in the question-answer pair are not encoded using common sense, but are directly used as supervision labels. The loss is calculated with the output of the decoder to train the encoder and decoder.

[0040] According to the present invention, a medical automated question-answering system based on common sense fusion includes:

[0041] Module M1: Segment the training statements into words, use the segmented words as keywords, query the commonsense base and knowledge base to obtain entity relation triples;

[0042] Module M2: Fusion encoding of triples and training statements, enabling the integration of structured common sense data from the library with training statements;

[0043] Module M3: Randomly selects some entities to mask after the training sentence is fused and encoded, replaces the next sentence with other random sentences with a fixed probability, and inputs the obtained training corpus into the multi-layer partition transformer encoder for training to obtain a preliminary common sense fusion language model.

[0044] Module M4: Performs word segmentation and entity relation query on the questions in the question-and-answer data, and performs common sense fusion encoding to obtain the common sense fusion encoding sequence of the question;

[0045] Module M5: The common sense fusion encoding sequence of the question is used as the input to the model, and the answer is used as the supervision label. Based on supervised learning, a common sense fusion language model is trained.

[0046] Module M6: Build a visual medical automated question-and-answer system. Input questions into a common sense and language model through a front-end interface, and display the model's output as the answer on the interface.

[0047] Preferably, the multi-layer partitioned transformer encoder refers to a transformer encoder that considers common sense fusion information. The statement that incorporates common sense is no longer a one-dimensional statement, but a two-dimensional statement with common sense. Each relationship in it is a partition, and there are different attentions between partitions. Therefore, before calculating the attention between characters, it is necessary to calculate the attention between partitions. In this way, common sense information can be learned into the model.

[0048] Preferably, in module M2:

[0049] Module M2.1: Adds to the beginning of sentences in the training corpus <cls>Mark, add at the end of the sentence <sep>logo;

[0050] Module M2.2: Assign numbers to common sense triples and training corpora. The numbering has an adjustment function for attention weights during later training. In this way, common sense is integrated with training sentences.

[0051] Module M2.2.1: From <cls>Initially, each character is assigned a number, starting from 1 and incrementing;

[0052] Module M2.2.2: Classifies triples based on their relationships;

[0053] Module M2.2.3: The tail entity number of each type of relation is incremented sequentially from the head entity number, and the length of the longest tail entity is denoted as l;

[0054] Module M2.2.4: Each type of relation is assigned a relation number, starting from 1 and incrementing.

[0055] Module M2.2.5: The character numbers following the header entity are all incremented by 1;

[0056] Module M2.3: Appends the numbered triplet tail entities to the end of the statement to form a one-dimensional sequence.

[0057] In module M4:

[0058] The questions in the question-and-answer data are segmented into words and entity relationships are queried and common sense fusion encoding is performed. The common sense fusion encoding sequence of the questions is obtained according to the method of module M2.

[0059] Preferably, in module M3:

[0060] Module M3.1: Counts the positions of entities in a sequence;

[0061] Module M3.2: Masks entities according to probability, trains the model to learn context and common sense;

[0062] Module M3.2.1: Masks the head entity according to probability p1, replacing each character of the head entity with... <mask>;

[0063] Module M3.2.2: If the head entity is masked, the tail entity is not masked;

[0064] Module M3.2.3: If the head entity is not masked, the tail entity is masked according to probability p2, and each character of the tail entity is replaced with... <mask>;

[0065] Module M3.2.4: Takes the obtained sequence as input and passes it to the multi-layer partition transformer, using the masked entities as labels for training;

[0066] Module M3.3: Replace the next sentence in the preceding and following sentences of the training corpus with a certain probability, and train the model to learn the relationship between the preceding and following sentences.

[0067] Preferably, in module M5:

[0068] Module M5.1: Inputs the question sequence after common sense fusion encoding into the multi-layer partition transformer encoder;

[0069] Module M5.2: Uses the output of the last partition transformer encoder as the input of the decoder;

[0070] Module M5.3: The answers in the question-answer pairs are not encoded using common sense, but are directly used as supervision labels. The loss is calculated with the output of the decoder to train the encoder and decoder.

[0071] Compared with the prior art, the present invention has the following beneficial effects:

[0072] 1. This invention uses a language model to generate answers to questions. Compared with traditional question-answering systems based on medical knowledge bases and given grammatical rules, this invention does not limit the type of question, and the answers are more in line with human language habits, making them easier for users to understand and improving the user experience.

[0073] 2. Compared with ordinary language model-based question answering systems, this invention integrates structured triples from common sense bases and medical knowledge bases into the training corpus, enabling the learned model to have a certain understanding and reasoning ability for questions, and to master basic medical common sense and knowledge, thus achieving better results in question answering in the medical field.

[0074] 3. This invention does not restrict the types of user questions and integrates common sense and medical knowledge into the language model, which improves the professionalism of the answers while ensuring that they conform to grammatical rules. Attached Figure Description

[0075] Other features, objects, and advantages of the present invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:

[0076] Figure 1 This is a schematic diagram illustrating the training of a medical automatic question-answering model based on common sense fusion in an embodiment of the present invention;

[0077] Figure 2 This is a schematic diagram of common sense encoding fusion in an embodiment of the present invention;

[0078] Figure 3 This is a schematic diagram of a multi-layer partition transformer encoder in an embodiment of the present invention;

[0079] Figure 4 This is a schematic diagram of a medical automatic question-answering system based on common sense fusion, as described in an embodiment of the present invention. Detailed Implementation

[0080] The present invention will now be described in detail with reference to specific embodiments. These embodiments will help those skilled in the art to further understand the present invention, but do not limit the invention in any way. It should be noted that those skilled in the art can make several changes and improvements without departing from the concept of the present invention. These all fall within the scope of protection of the present invention.

[0081] Example 1:

[0082] According to the present invention, a medical automatic question-answering method based on common sense fusion is provided, such as... Figures 1-4 As shown, it includes:

[0083] Step S1: Segment the training statement into words, use the segmented words as keywords, and query the commonsense base and knowledge base to obtain entity relation triples;

[0084] Step S2: Fusion encoding of triples and training statements to integrate structured common sense data from the library with training statements;

[0085] Step S3: Randomly select some entities to mask after the training sentence is fused and encoded, replace the next sentence with other random sentences with a fixed probability, and input the obtained training corpus into the multi-layer partition transformer encoder for training to obtain a preliminary common sense fusion language model.

[0086] Step S4: Perform word segmentation and entity relation query on the questions in the question-answer data, and perform common sense fusion encoding to obtain the common sense fusion encoding sequence of the questions;

[0087] Step S5: The common sense fusion encoding sequence of the question is used as the input to the model, and the answer is used as the supervision label. Based on supervised learning, a common sense fusion language model is trained.

[0088] Step S6: Build a visual medical automatic question-and-answer system. Input questions into a common sense fusion language model through the front-end interface, and display the model's output as the answer on the interface.

[0089] Specifically, the multi-partition transformer encoder refers to a transformer encoder that considers common sense fusion information. The sentence that incorporates common sense is no longer a one-dimensional sentence, but a two-dimensional sentence with common sense. Each relationship in it is a partition, and there are different attentions between partitions. Therefore, before calculating the attention between characters, it is necessary to calculate the attention between partitions. In this way, common sense information can be learned into the model.

[0090] Specifically, in step S2:

[0091] Step S2.1: Add to the beginning of sentences in the training corpus <cls>Mark, add at the end of the sentence <sep>logo;

[0092] Step S2.2: Assign numbers to the common sense triplet and the training corpus. The numbering has an adjustment function for the attention weight during later training. In this way, common sense and training sentences are integrated.

[0093] Step S2.2.1: From <cls>Initially, each character is assigned a number, starting from 1 and incrementing;

[0094] Step S2.2.2: Classify the triples according to their relationships;

[0095] Step S2.2.3: The tail entity number of each type of relation is incremented sequentially from the head entity number, and the length of the longest tail entity is denoted as l;

[0096] Step S2.2.4: Assign a relation number to each type of relation, starting from 1 and incrementing;

[0097] Step S2.2.5: Increase the character number of each character following the header entity by 1;

[0098] Step S2.3: Concatenate the numbered triplet tail entities to the end of the statement to form a one-dimensional sequence.

[0099] In step S4:

[0100] The questions in the question-and-answer data are segmented into words and entity relationships are queried and common sense fusion encoding is performed. The common sense fusion encoding sequence of the questions is obtained according to the method in step S2.

[0101] Specifically, in step S3:

[0102] Step S3.1: Count the positions of entities in the sequence;

[0103] Step S3.2: Mask entities according to probability and train the model to learn context and common sense;

[0104] Step S3.2.1: Mask the head entity according to probability p1, replacing each character of the head entity with... <mask>;

[0105] Step S3.2.2: If the head entity is masked, the tail entity is not masked;

[0106] Step S3.2.3: If the head entity is not masked, then the tail entity is masked according to probability p2, and each character of the tail entity is replaced with... <mask>;

[0107] Step S3.2.4: Take the obtained sequence as input and pass it into the multi-layer partition transformer to train the masked entities as labels;

[0108] Step S3.3: Replace the next sentence in the training corpus with a certain probability, and train the model to learn the relationship between the next and next sentences.

[0109] Specifically, in step S5:

[0110] Step S5.1: Input the question sequence after common sense fusion encoding into the multi-layer partition transformer encoder;

[0111] Step S5.2: Use the output of the last partition transformer encoder as the input of the decoder;

[0112] Step S5.3: The answers in the question-answer pair are not encoded using common sense, but are directly used as supervision labels. The loss is calculated with the output of the decoder to train the encoder and decoder.

[0113] Example 2:

[0114] Example 2 is a preferred embodiment of Example 1, and is used to illustrate the present invention in more detail.

[0115] Those skilled in the art can understand the medical automatic question-answering method based on common sense fusion provided by the present invention as a specific implementation of the medical automatic question-answering system based on common sense fusion, that is, the medical automatic question-answering system based on common sense fusion can be implemented by executing the steps of the medical automatic question-answering method based on common sense fusion.

[0116] According to the present invention, a medical automated question-answering system based on common sense fusion includes:

[0117] Module M1: Segment the training statements into words, use the segmented words as keywords, query the commonsense base and knowledge base to obtain entity relation triples;

[0118] Module M2: Fusion encoding of triples and training statements, enabling the integration of structured common sense data from the library with training statements;

[0119] Module M3: Randomly selects some entities to mask after the training sentence is fused and encoded, replaces the next sentence with other random sentences with a fixed probability, and inputs the obtained training corpus into the multi-layer partition transformer encoder for training to obtain a preliminary common sense fusion language model.

[0120] Module M4: Performs word segmentation and entity relation query on the questions in the question-and-answer data, and performs common sense fusion encoding to obtain the common sense fusion encoding sequence of the question;

[0121] Module M5: The common sense fusion encoding sequence of the question is used as the input to the model, and the answer is used as the supervision label. Based on supervised learning, a common sense fusion language model is trained.

[0122] Module M6: Build a visual medical automated question-and-answer system. Input questions into a common sense and language model through a front-end interface, and display the model's output as the answer on the interface.

[0123] Specifically, the multi-partition transformer encoder refers to a transformer encoder that considers common sense fusion information. The sentence that incorporates common sense is no longer a one-dimensional sentence, but a two-dimensional sentence with common sense. Each relationship in it is a partition, and there are different attentions between partitions. Therefore, before calculating the attention between characters, it is necessary to calculate the attention between partitions. In this way, common sense information can be learned into the model.

[0124] Specifically, in module M2:

[0125] Module M2.1: Adds to the beginning of sentences in the training corpus <cls>Mark, add at the end of the sentence <sep>logo;

[0126] Module M2.2: Assign numbers to common sense triples and training corpora. The numbering has an adjustment function for attention weights during later training. In this way, common sense is integrated with training sentences.

[0127] Module M2.2.1: From <cls>Initially, each character is assigned a number, starting from 1 and incrementing;

[0128] Module M2.2.2: Classifies triples based on their relationships;

[0129] Module M2.2.3: The tail entity number of each type of relation is incremented sequentially from the head entity number, and the length of the longest tail entity is denoted as l;

[0130] Module M2.2.4: Each type of relation is assigned a relation number, starting from 1 and incrementing.

[0131] Module M2.2.5: The character numbers following the header entity are all incremented by 1;

[0132] Module M2.3: Appends the numbered triplet tail entities to the end of the statement to form a one-dimensional sequence.

[0133] In module M4:

[0134] The questions in the question-and-answer data are segmented into words and entity relationships are queried and common sense fusion encoding is performed. The common sense fusion encoding sequence of the questions is obtained according to the method of module M2.

[0135] Specifically, in module M3:

[0136] Module M3.1: Counts the positions of entities in a sequence;

[0137] Module M3.2: Masks entities according to probability, trains the model to learn context and common sense;

[0138] Module M3.2.1: Masks the head entity according to probability p1, replacing each character of the head entity with... <mask>;

[0139] Module M3.2.2: If the head entity is masked, the tail entity is not masked;

[0140] Module M3.2.3: If the head entity is not masked, the tail entity is masked according to probability p2, and each character of the tail entity is replaced with... <mask>;

[0141] Module M3.2.4: Takes the obtained sequence as input and passes it to the multi-layer partition transformer, using the masked entities as labels for training;

[0142] Module M3.3: Replace the next sentence in the preceding and following sentences of the training corpus with a certain probability, and train the model to learn the relationship between the preceding and following sentences.

[0143] Specifically, in module M5:

[0144] Module M5.1: Inputs the question sequence after common sense fusion encoding into the multi-layer partition transformer encoder;

[0145] Module M5.2: Uses the output of the last partition transformer encoder as the input of the decoder;

[0146] Module M5.3: The answers in the question-answer pairs are not encoded using common sense, but are directly used as supervision labels. The loss is calculated with the output of the decoder to train the encoder and decoder.

[0147] Example 3:

[0148] Example 3 is a preferred example of Example 1, and is used to illustrate the present invention in more detail.

[0149] This invention provides a medical automated question-answering method and system based on common sense fusion, comprising the following steps:

[0150] Step S1: Segment the training statement into words, use the resulting word segments as keywords, query the commonsense base and knowledge base to obtain entity relation triples;

[0151] Step S2: Fuse the triples with the training statements to encode the structured common sense into the ordinary training statements.

[0152] Step S3: Randomly select some entities to mask after fusing and encoding the sentence, replace the next sentence with other random sentences with a fixed probability, and input the training data obtained in the two ways into the multi-layer partition transformer encoder for training to obtain the preliminary model;

[0153] Step S4: Following the method in step S2, process the questions in the medical question-and-answer pair to obtain the common sense fusion encoding sequence of the questions;

[0154] Step S5: Use the processing result of step S4 as the input to the model, and the answer as the supervision label to continue training the model and obtain the final model;

[0155] Step S6: Build a user interface system to receive user input questions through the interface, input the questions into the final model obtained in step S4, and display the model's output as the answer on the interface;

[0156] Specifically, the fusion encoding of the triples and training statements in step S2 includes:

[0157] Step S2.1: Add to the beginning of sentences in the training corpus <cls>Mark, add at the end of the sentence <sep>logo;

[0158] Step S2.2: Assign numbers to the common sense triplet and the training corpus. These numbers have an adjustment function for the attention weights during later training. In this way, common sense is integrated with ordinary training corpus.

[0159] Step S2.3: Append the numbered relationships to the end of the statement to form a one-dimensional sequence;

[0160] Specifically, assigning numbers to the common sense triples and training corpus in step S2.2 includes the following steps:

[0161] Step S2.2.1: From <cls>Initially, each character is assigned a number, starting from 1 and incrementing;

[0162] Step S2.2.2: Classify the triples according to their relationships;

[0163] Step S2.2.3: The tail entity number of each type of relation is incremented sequentially from the head entity number;

[0164] Step S2.2.4: Assign a relation number to each type of relation, starting from 1 and incrementing;

[0165] Step S2.2.5: Adjust the character sequence following the main clause header entity;

[0166] Specifically, step S3 includes the following steps:

[0167] Step S3.1: Count the positions of entities in the sequence obtained in step S2;

[0168] Step S3.2: Mask entities according to probability and train the model to learn context and common sense;

[0169] Step S3.3: Replace the next sentence in the training corpus with a certain probability, and train the model to learn the relationship between the next and next sentences;

[0170] Specifically, the main structure of the commonsense fusion language model is a multi-layer partitioned transformer encoder. Sentences incorporating commonsense are no longer one-dimensional but two-dimensional, possessing both commonsense and semantic meaning. Each entity relationship is represented as a partition, and different partitions have different attention levels. Therefore, before calculating the attention between characters, it is necessary to first calculate the attention between partitions. This method allows commonsense information to be learned into the model.

[0171] Specifically, step S 3.2 includes:

[0172] Step S3.2.1: Mask the head entity according to probability p1, replacing each character of the head entity with... <mask>;

[0173] Step S3.2.2: If the head entity is masked, the tail entity is not masked;

[0174] Step S3.2.3: If the head entity is not masked, the tail entity is masked with probability p2, and each character of the tail entity is replaced with... <mask>;

[0175] Step S3.2.4: Take the obtained sequence as input and pass it into the multi-layer partition transformer to train the masked entities as labels;

[0176] Specifically, the probabilities p1 and p2 in steps S3.2.1 and S3.2.3 can be 50% and 50%, respectively.

[0177] Specifically, step S5 includes the following steps:

[0178] Step S5.1: Input the question sequence after common sense fusion encoding into the multi-layer partition transformer encoder;

[0179] Step S5.2: Use the output of the last partition transformer encoder as the input of the decoder;

[0180] Step S5.3: The answers in the question-answer pair are not encoded using common sense, but are directly used as supervision labels. The loss is calculated with the output of the decoder to train the encoder and decoder.

[0181] The end-to-end medical automated question-answering system based on common sense fusion, implemented according to the above-mentioned invention technology, includes the following modules:

[0182] Module M1: Entity relation triple query module for the commonsense base and knowledge base. It segments the training corpus and queries the commonsense base and knowledge base to obtain entity relation triples.

[0183] Module M2: Common Sense Fusion Encoding Module. It fuses the entities and relations obtained from Module M1 with the training corpus to produce training sentences incorporating common sense.

[0184] Module M3: Training data construction module. The training statements obtained from module M2 are processed in step S3 to obtain two types of training corpora.

[0185] Module M4: Multi-level partitioning transformer encoding module. It trains on the training corpus obtained from M3 to learn a language model that includes common sense and medical knowledge and can generate sentences that conform to grammatical rules.

[0186] Module M5: Medical Question-Answer Pair Training Module. This module processes medical question-answer pairs data, inputs it into the model for further training, and learns a language model capable of generating answers to medical questions.

[0187] Module M6: Question Input and Answer Output Module. It receives user input questions and provides answers using a language model.

[0188] Example 4:

[0189] Example 4 is a preferred example of Example 1, which is used to illustrate the present invention in more detail.

[0190] like Figure 1 As shown, the training method of the medical automatic question answering model based on common sense fusion of the present invention includes the following steps:

[0191] Step S1: Segment the training statement into words, use the resulting word segments as keywords, query the commonsense base and knowledge base to obtain entity relation triples;

[0192] Step S2: Fuse the triples with the training statements to encode the structured common sense into the ordinary training statements.

[0193] Step S3: Randomly select some entities to mask after fusing and encoding the sentence, replace the next sentence with other random sentences with a fixed probability, and input the training data obtained in the two ways into the multi-layer partition transformer encoder for training to obtain the preliminary model;

[0194] Step S4: Following the method in step S2, process the questions in the medical question-and-answer pair to obtain a fusion encoding sequence of questions and common sense;

[0195] Step S5: The processing result of step S4 is used as the input to the model, and the answer is used as the supervision label to continue training the model and obtain the final model;

[0196] Specifically, step S1 includes the following steps:

[0197] Step S1.1: Segment the sentences in the training corpus into words;

[0198] Step S1.2: Treat each word segment as a keyword, query the entity in the knowledge base and common sense base, and obtain the entity relation triplet. <e h ,r,e t >;where entity e h A sequence of multiple characters<x0,x1,x2…> ;

[0199] Specifically, the fusion encoding of the triples and training statements in step S2 includes:

[0200] Step S2.1: Add to the beginning of sentences in the training corpus <cls>Mark, add at the end of the sentence <sep>These two flags, as special flags, are also word vectors encoded with the same dimensions as ordinary characters;

[0201] Step S2.2: Assign numbers to the common sense triplet and the training corpus. These numbers have an adjustment function for the attention weights during later training. In this way, common sense is integrated with ordinary training corpus.

[0202] Step S2.3: Append the numbered relations to the end of the statement to form a one-dimensional sequence.<x0,x1,x2…> The main clause in the triplet only has a number, while the tail entity of the triplet has a relation type number.

[0203] Specifically, such as Figure 2 As shown, the steps in S2.2 involving assigning numbers to the common sense triples and the training corpus include the following:

[0204] Step S2.2.1: From <cls>Initially, each character is assigned a number, starting from 1 and incrementing. For example... <cls>ABCDEFGHIJ <sep>Each character is assigned a number, resulting in <cls>1A2B3C4D5E6F7G8H9I10J11 <sep>12;

[0205] Step S2.2.2: Classify the triples according to their relationships, for example... Figure 2 As shown, they are divided into four categories;

[0206] Step S2.2.3: The tail entity number of each type of relation increments sequentially from the head entity number, for example... Figure 2 As shown, O(8,1)P(9,1) etc. are assigned incremental numbers 8 and 9 starting from entity E6F7;

[0207] Step S2.2.4: Assign a relation number to each type of relation, starting from 1 and incrementing, for example... Figure 2 As shown, each category has one type number, resulting in O(8,1)P(9,1) etc., which are assigned the number 1 of the relation type;

[0208] Step S2.2.5: Adjust the numbering of the characters following the header entity in the main clause, for example... Figure 2 As shown, we obtain G10H11... Through this fusion encoding method, the information of the common sense triples can be trained together with ordinary sentences, thus realizing the fusion of common sense.

[0209] Specifically, step S3 includes the following steps:

[0210] Step S3.1: Count the number of entities in the sequence obtained in step S2;

[0211] Step S3.2: Mask the entities according to a certain probability, and train the model to learn the context and common sense;

[0212] Step S3.3: Replace the next sentence in the training corpus with a certain probability, and train the model to learn the relationship between the next and next sentences;

[0213] Specifically, step S 3.2 includes:

[0214] Step S3.2.1: Mask the head entity with a 50% probability, replacing each character of the head entity with... <mask>。;

[0215] Step S3.2.2: If the head entity is masked, the tail entity is not masked. Figure 2 Taking the sequence shown as an example, if the head entity is masked, the resulting sequence is... <cls>1A2B3C4D5 <mask> 6 <mask>7G10H11……;

[0216] Step S3.2.3: If the head entity is not masked, the tail entity is masked with a 50% probability, and each character of the tail entity is replaced with... <mask>.by Figure 2 Taking the sequence shown as an example, if the head entity is not masked, the following sequence might be obtained...E6F7G10... <mask> (8,4) <mask>(9,4)……;

[0217] Step S3.2.4: The obtained sequence is used as input to the multi-layer partitioning transformer, and the masked entities are used as labels for training. Figure 2 Taking the sequence shown as an example, if the sequence after the head entity is masked is input into the encoder, the corresponding label is E6F7;

[0218] Specifically, step S3.4 includes the following steps:

[0219] Step S3.4.1: Replace the preceding and following sentences with a 50% probability, for example... <cls>ABCDEF <sep> <cls>GHIJK <seq>The replacement may result in <cls>ABCDEF <sep> <cls>UVWXYZ <seq>

[0220] Step S3.4.2: Concatenate the previous and next sentences as input, pass them into the partition transformer, determine whether they are related as upper and lower sentences, calculate the error, and update the model parameters;

[0221] Specifically, step S5 includes the following steps:

[0222] Step S5.1: Input the question sequence after common sense fusion encoding into the multi-layer partition transformer encoder;

[0223] Step S5.2: Use the output of the last partition transformer encoder as the input of the decoder;

[0224] Step S5.3: The answers in the question-answer pair are not encoded using common sense, but are directly used as supervision labels. The loss is calculated with the output of the decoder, the parameters are updated, and the encoder and decoder are trained.

[0225] Specifically, such as Figure 3 As shown, the multi-layer partitioned transformer encoder in steps S3 and S5 refers to a sentence that incorporates common sense, no longer a one-dimensional sentence, but a two-dimensional sentence with common sense. Each relationship is treated as a partition, and different partitions have different attention levels. Therefore, before calculating the attention between characters, it is necessary to calculate the attention between partitions. In this way, common sense information can be learned into the model. Specifically, taking... Figure 3 For example, K(8,4)L(9,4) is partition 4, M(8,3)N(9,3) is partition 3, O(8,1)P(9,1), Q(8,1)R(9,1), S(8,1)T(9,1) is partition 1, and U(8,2)V(9,2) is partition 2. The four partitions form a weight matrix wij. The values ​​of the partition weight matrix are also learned through the training process before input character attention.

[0226] Those skilled in the art will understand that, in addition to implementing the system, apparatus, and their modules provided by this invention in purely computer-readable program code, the same program can be implemented in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, the system, apparatus, and their modules provided by this invention can be considered a hardware component, and the modules included therein for implementing various programs can also be considered structures within the hardware component; alternatively, modules for implementing various functions can be considered both software programs implementing the method and structures within the hardware component.

[0227] Specific embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the specific embodiments described above, and those skilled in the art can make various changes or modifications within the scope of the claims, which do not affect the essence of the present invention. Unless otherwise specified, the embodiments and features described in this application can be arbitrarily combined with each other.< / seq> < / cls> < / sep> < / cls> < / seq> < / cls> < / sep> < / cls> < / mask> < / mask> < / mask> < / mask> < / mask> < / cls> < / mask> < / sep> < / cls> < / sep> < / cls> < / cls> < / sep> < / cls> < / mask> < / mask> < / cls> < / sep> < / cls> < / mask> < / mask> < / cls> < / sep> < / cls> < / mask> < / mask> < / cls> < / sep> < / cls> < / mask> < / mask> < / cls> < / sep> < / cls> < / mask> < / mask> < / cls> < / sep> < / cls>

Claims

1. A medical automatic question and answer method based on common sense fusion, characterized in that, Comprise: Step S1: word segmentation of training sentences, taking the segmented words as keywords, querying the common sense library and knowledge base to obtain entity relationship triples; Step S2: fuse the triples with the training sentences to encode the structured common sense in the library with the training sentences; Step S3: randomly select part of the entities in the fused and encoded training sentences to mask, replace the next sentence with other random sentences according to a fixed probability, input the obtained training corpus into a multi-layer partition transformer encoder for training, and obtain a preliminary common sense fusion language model; Step S4: perform word segmentation and entity relationship query on the question in the question and answer data, and perform common sense fusion encoding to obtain the common sense fusion encoding sequence of the question; Step S5: taking the common sense fusion encoding sequence of the question as the model input and the answer as the supervision label, a common sense fusion language model is trained based on supervised learning; Step S6: build a visual medical automatic question and answer system, input the question into the common sense fusion language model through the front-end interface, and display the output of the model as the answer to the interface; The multi-layer partition transformer encoder refers to a transformer encoder considering common sense fusion information. The sentence fused with common sense is not one-dimensional, but two-dimensional, and each relationship is a partition. The partitions have different attention between each other. Therefore, before calculating the attention between characters, the attention between partitions needs to be calculated first. In this way, common sense information can be learned into the model; In the step S2: Step S2.1: Adding <cls>sign, added at the end of a sentence <sep>Sign;< / sep> < / cls> Step S2.2: assign numbers to the common sense triples and training corpus. The numbers have a regulating function on the attention weight during later training. In this way, the common sense is fused with the training sentence; Step S2.2.1 : From <cls>Start, assign a number to each character, and the number starts from 1 and increases by 1;< / cls> Step S2.2.2: classify the triples according to the relationship; Step S2.2.3: the tail entity number of each type of relationship is increased from the head entity number in sequence, and the length of the longest tail entity is recorded as l; Step S2.2.4: assign a relationship number to each type of relationship, starting from 1 and increasing by 1; Step S2.2.5: increase the character number after the head entity by l; Step S2.3: concatenate the tail entity of the triple with the assigned number to the end of the sentence to form a one-dimensional sequence; In the step S4: Perform word segmentation and entity relationship query on the question in the question and answer data and perform common sense fusion encoding to obtain the common sense fusion encoding sequence of the question according to the method of step S2.

2. The medical automatic question answering method based on common sense fusion according to claim 1, characterized in that, In the step S3: Step S3.1: count the position of the entity in the sequence; Step S3.2: mask the entity according to the probability to train the model to learn the context and common sense; Step S3.2.1 : masking the header entity with a probability p1, each character of the header entity being replaced by <mask> ;< / mask> Step S3.2.2: if the head entity is masked, the tail entity is not masked; Step S3.2.3: If the head entity does not mask, the tail entity masks with probability p2, the tail entity replaces each character with <mask> ;< / mask> Step S3.2.4: input the obtained sequence into the multi-layer partition transformer, and train the masked entity as a label; Step S3.3: replace the next sentence in the training corpus according to a certain probability to train the model to learn the association between the sentences. 3.The medical automatic question answering method based on common sense fusion according to claim 1, characterized in that, In the step S5: Step S5.1: input the common sense fused encoded question sequence into the multi-layer partition transformer encoder; Step S5.2: take the output of the last layer of the partition transformer encoder as the input of the decoder; Step S5.3: the answer in the question and answer pair is not encoded with common sense, and is directly taken as a supervised label to calculate the loss with the output of the decoder, so as to train the encoder and the decoder.

4. A medical automatic question-answering system based on common sense fusion, characterized in that, Comprise: Module M1: segment the training sentence, take the segmentation as a keyword, query the common sense library and the knowledge base, and obtain entity relationship triples; Module M2: fuse and encode the triples and the training sentence, so as to fuse the structured common sense in the library with the training sentence; Module M3: randomly mask part of the entities of the fused and encoded training sentence, replace the next sentence with other random sentences according to a fixed probability, input the obtained training corpus into the multi-layer partition transformer encoder for training, and obtain a preliminary common sense fusion language model; Module M4: segment the question in the question and answer data and query the entity relationship, and fuse and encode the common sense to obtain the common sense fusion encoding sequence of the question; Module M5: take the common sense fusion encoding sequence of the question as the model input, take the answer as the supervised label, and train the common sense fusion language model based on supervised learning; Module M6: build a visual medical automatic question and answer system, input the question into the common sense fusion language model through the front-end interface, and display the output of the model as the answer to the interface; The multi-layer partition transformer encoder refers to a transformer encoder considering common sense fusion information, and the sentence fused with common sense is not one-dimensional, but two-dimensional, in which each relationship is taken as a partition, and the partitions have different attention between each other. Therefore, the attention between partitions needs to be calculated before the attention between characters is calculated, so that the common sense information can be learned into the model; In the module M2: Module M2.1 : Adding at the beginning of the sentence of the training corpus <cls>sign, added at the end of the sentence <sep>Mark;< / sep> < / cls> Module M2.2: assign numbers to the common sense triples and the training corpus, and the numbers have a regulating function on the attention weight during the later training, so as to fuse the common sense with the training sentence; Module M2.2.1 : from <cls>First, assign a number to each character, and the number starts from 1 and increases;< / cls> Module M2.2.2: classify the triples according to the relationship; Module M2.2.3: the tail entity number of each type of relationship is increased from the tail entity number of the head entity in sequence, and the length of the longest tail entity is recorded as l; Module M2.2.4: assign a relationship number to each type of relationship, which starts from 1 and increases; Module M2.2.5: increase the character number after the head entity by l; Module M2.3: splice the tail entity of the triple with the assigned number to the tail of the sentence to form a one-dimensional sequence; In the module M4: Segment the question in the question and answer data and query the entity relationship, and fuse and encode the common sense, to obtain the common sense fusion encoding sequence of the question according to the method of module M2.

5. The common sense fusion-based medical automatic question answering system according to claim 4, characterized in that, In the module M3: Module M3.1: count the position of the entity in the sequence; Module M3.2: Masking entities with probability, training model to learn context and common sense; Module M3.2.1 : masking of the header entity with a probability p1, each character of the header entity being replaced by <mask> ;< / mask> Module M3.2.2: If the head entity is masked, the tail entity is not masked; Module M3.2.3: If the head entity does not mask, the tail entity masks with probability p2, the tail entity replaced by <mask> ;< / mask> Module M3.2.4: The obtained sequence is input into a multi-layer partition transformer, and the masked entity is trained as a label; Module M3.3: Replace the second sentence in the training corpus with a certain probability, and train the model to learn the relationship between the upper and lower sentences.

6. The common sense fusion-based medical automatic question answering system according to claim 4, characterized in that, In the module M5: Module M5.1: Input the encoded question sequence with common sense fusion into a multi-layer partition transformer encoder; Module M5.2: The output of the last layer of the partition transformer encoder is used as the input of the decoder; Module M5.3: The answer in the question and answer pair is not encoded with common sense, and is directly used as a supervision label to calculate the loss with the output of the decoder, to train the encoder and the decoder.

Citation Information

Patent Citations

  • Medical automatic question-answering system construction method based on knowledge graph

    CN112071429A

  • Visual question-answering method based on fusion of fine-grained image features and external knowledge

    CN112100346A

  • Knowledge graph intelligent question-answer method fusing pointer generation network

    CN113010693A