Question answering system of knowledge base in medical knowledge field

By building a knowledge base in the medical knowledge field and fine-tuning of large language models, combining vector retrieval and template reply technology, the problem that large language models cannot collect the latest data in real time and generate factual errors in the medical field is solved, achieving more accurate and efficient answer quality.

CN119782474APending Publication Date: 2025-04-08TIANJIN HAINA ZHONGCHENG TECHNOLOGY CO LTD

Patent Information

Application Number
CN202411868450.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-18
Publication Date
2025-04-08

AI Technical Summary

Technical Problem

In the application of large language models in the medical field, there are problems that cannot include the latest data in real time and produce factual errors, resulting in low quality of answers.

Method used

A question-and-answer system for the medical knowledge field knowledge base was designed. By building a medical knowledge base, using embedded models to vectorize knowledge, and fine-tuning the large language model with supervised data sets, using technologies such as vector retrieval and template replies to improve the accuracy and efficiency of the answers.

Benefits of technology

It realizes more accurate and efficient answers to user questions in the medical field, avoids factual errors, and improves the answer quality of large language models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119782474A_ABST
    Figure CN119782474A_ABST
Patent Text Reader

Abstract

The question and answer system based on the knowledge base in the medical field is characterized by comprising the following steps: S100, constructing the knowledge base in the medical field, training an embedded model by using collected data, vectorizing the knowledge in the medical field, and storing the vectorized knowledge in a vector database; s200, constructing a supervised data set to carry out fine tuning on the Moose general large language model to obtain a language model Moose-med suitable for the medical field; s300, performing intention recognition on the questions of the user through a classification model, replying the questions in the non-medical field by using a template, and vectorizing the questions in the medical field by using an embedded model, and S400, matching question vectors with the content of a knowledge base through vector retrieval, and obtaining a matching result according to a threshold value. After a matching result is obtained, relevant paragraphs in the knowledge base are extracted; and S500, encapsulating the extracted information as a context into a cue word, and inputting the extracted information and the user question into a Moose-med model to obtain an answer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of computer natural language processing, and in particular to a question-answering system for a knowledge base in the field of medical knowledge. Background Art

[0002] In recent years, the medical industry has faced a series of challenges such as the growing patient burden, shortage of medical resources, and inefficient medical services. At the same time, with the digitization of medical information and the rise of big data, the scale of medical data has also increased dramatically. The automated question-answering system can enable users to obtain medical information instantly, and understand symptoms, diseases, and treatment plans more quickly without waiting for responses from doctors or other medical professionals. This is especially important for patients and the general public when they are in urgent need of information. In addition, medical students and medical practitioners can also obtain detailed and accurate information about diseases, treatment methods, etc. through the automated question-answering system to help with learning or diagnosis and treatment, and reduce the burden on medical personnel. For common medical questions, patients can get answers through the automated question-answering system without having to consult a doctor in person, thereby freeing up doctors' more time to handle complex cases and provide more professional medical services. The automated question-answering system also helps to popularize health knowledge to a wider range of people, provide advice on healthy lifestyles, disease prevention, etc., and promote social health education.

[0003] In recent years, natural language processing (NLP) technology has also made great progress. In particular, since the advent of the Transformers model based on the self-attention mechanism, large language models have made breakthrough progress in many fields and have many practical applications. However, large language models are not search engines. They usually include corpora in general fields. Many vertical commercial data are not within the scope of this corpus, and vertical data are updated quickly, but large language models cannot collect the latest public data in real time. Large language models also have the problem of "hallucination". In the absence of external knowledge, the autoregressive model will produce answers that are factually incorrect and misleading. In view of the particularity of the medical field, wrong answers may have serious consequences. In order to solve the above problems, a question-answering system for the knowledge base in the field of medical knowledge is proposed. Summary of the invention

[0004] In view of the above technical problems, the present invention provides a question-answering system for a medical knowledge domain knowledge base, which is characterized by including two modules: model training and reasoning. The main steps of the training module include:

[0005] S100: Build a medical knowledge base, use the collected data to train the embedding model, vectorize the medical knowledge, and store it in the vector database;

[0006] S200: Construct a supervised dataset to fine-tune the Moose general language model and obtain the Moose-med language model suitable for the medical field;

[0007] The reasoning module includes:

[0008] S300: Use the classification model to identify the intent of user questions, use template replies for non-medical questions, and use embedding models to vectorize questions in the medical field;

[0009] S400: The question vector is matched with the content of the knowledge base through vector retrieval, and a matching result is obtained according to a threshold. When no matching result is found, the reply template is used to clarify the question to the user and the question is retrieved again. When a matching result is successfully obtained, the relevant paragraphs in the knowledge base are extracted;

[0010] S500: Encapsulate the extracted information as context into the prompt word, and input it into the Moose-med model together with the user question to obtain the answer.

[0011] Further, S100: Use the collected medical data to train the embedding model to vectorize the medical field knowledge. First, the collected original text is segmented into multiple paragraphs, and then the paragraphs are vectorized using the embedding model. The embedding model uses the Bert model and is fine-tuned using medical field data;

[0012] First, we use the BPE (Byte Pair Encoding, an unsupervised word segmentation algorithm based on statistics) model to build a word segmenter, split common words into smaller subwords, and enhance the ability to identify unregistered and rare words. The trained word segmentation is integrated with the Bert model word segmentation, and then the Bert model parameters are fine-tuned using mask prediction combined with paragraph matching. After fine-tuning, we get an embedded model, and we can get a feature vector by inputting a text paragraph into the model.

[0013] The knowledge base of this system uses a vector database, which can store and query data efficiently. Compared with traditional relational databases, the vector database uses a vector embedded data representation method that is more compatible with deep learning models. The feature vector and the corresponding text paragraph are stored in the database, and the similarity between vectors is used to represent the relationship between the corresponding paragraphs. The knowledge most relevant to the query vector can be found by calculating the vector similarity. At this point, the knowledge base is built;

[0014] Furthermore, S200: A supervised dataset was constructed, which contains a large number of medical consultation records, including multi-round and single-round dialogues. The questions in the dataset were used as the input of the Moose general language model, and the answers and keywords were used as the output of the model for training, thus obtaining the Moose-med model.

[0015] Since the large language model has a large number of parameters, the full fine-tuning method is costly. This system uses the LORA (Low-Rank Adaption) fine-tuning method. Assuming that the model parameters are represented by W, the full fine-tuning uses the gradient descent method to adjust the parameters. The new parameters are W+ΔW. The calculation of the update value ΔW is as shown in formula (1):

[0016] ΔW=α(-ΔL W ) (1),

[0017] Where ΔL W represents the gradient of the parameter relative to the loss function, and α represents the learning rate. For LORA fine-tuning, ΔW is decomposed into two low-rank matrices A and B, as shown in formula (2):

[0018] ΔW=AB,A∈R d*r ,B∈R r*k (2)

[0019] Since the rank r of the two matrices is much smaller than the rank of ΔW (the smaller value of d and k), the number of parameters calculated by LORA fine-tuning is much smaller than that of full-scale fine-tuning, which can improve the efficiency of fine-tuning. After fine-tuning, the Moose-med model suitable for the medical field is obtained;

[0020] Further, S300: Intent recognition is performed through a text classification model to determine whether the question input by the user is related to the medical field, and a template is used to respond to irrelevant questions. This system uses Bert as a classification model to determine whether the text is related to the medical field. Text data from the medical field and other fields is collected and used, and the pre-trained Bert is fine-tuned to determine whether the text belongs to the medical field. The binary cross entropy is used as the loss function to fine-tune the model parameters. The cross entropy formula is as shown in formula (3):

[0021] BCE=-(ylog(p(x)+(1-y)log(1-p(x)) (3),

[0022] Where y is the real label, and p(x) is the predicted probability of belonging to the label. The trained model can judge the user's files and determine whether the question is related to the medical field. For irrelevant questions, a fixed template is used to reply, and the user system can only answer questions related to the medical field, and the user is requested to resubmit the question. For relevant questions, the embedding model trained in step S100 is used for vectorization and input into the database for query;

[0023] Further, S400: the vector in S300 is input into the database for query, and a vector similar to the question vector is found in the knowledge base through a search algorithm. After the search, the database will return multiple results that best match the question vector. In order to ensure the quality of the answer, the present invention sets a threshold. The returned vector will be retained only if the similarity with the question vector is higher than the threshold, and the corresponding text paragraph is returned. The similarity is expressed by cosine distance, as shown in formula (4):

[0024]

[0025] Where a and b represent the returned vector and question vector respectively. When all the results returned by the knowledge base are below the threshold, it is considered that there is no result matching the question. The system will use a template reply to clarify the question to the user and ask the user to ask again. The user's new question will go through steps S300 and S400 again until a matching result is obtained or the user stops asking questions;

[0026] Furthermore, S500: the paragraph related to the question obtained from the knowledge base in S400 is used as context and added to the prompt word of the large language model Moose-med. By adding the context, the large language model can obtain knowledge related to the question, thereby avoiding factual errors and obtaining more reliable answers. Since the user's question may be related to a lot of content in the knowledge base, compared with directly returning the paragraph from the knowledge base, the answer returned by Moose-med is more refined and easier to understand.

[0027] Beneficial effects of the present invention:

[0028] The present invention establishes a question-answering system for a medical knowledge domain knowledge base to more accurately and efficiently improve the answer quality of a large language model in the medical field. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 A schematic diagram of the process flow of the question-answering system of the medical knowledge domain knowledge base of the present invention;

[0030] Figure 2 This is a schematic diagram of the overall architecture of the question-answering system of the medical knowledge domain knowledge base of the present invention.

[0031] Figure 3 It is a schematic diagram of the process of answering user questions by the question-answering system of the medical knowledge domain knowledge base of the present invention. DETAILED DESCRIPTION

[0032] The technical solution of the present invention will be described clearly and completely below in conjunction with the accompanying drawings. 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.

[0033] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.

[0034] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected" and "connected" should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal connection of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances. In addition, the technical features involved in the different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.

[0035] Example 1

[0036] The present invention provides a question-answering system for a medical knowledge domain knowledge base, which is characterized by comprising S100: using the collected medical data to train an embedding model to vectorize the medical domain knowledge, firstly segmenting the collected original text into multiple paragraphs, and then vectorizing the paragraphs using the embedding model, the embedding model using the Bert model, and fine-tuning using the medical domain data, the Bert model used in this example maintains the original model structure and dimension;

[0037] In this example, the BPE model is first used to build a word segmenter, which splits common words into smaller subwords to enhance the ability to identify unregistered and rare words. The trained word segmentation is integrated with the Bert model word segmentation, and then the Bert model is fine-tuned. In this example, in addition to the loss of the mask prediction part, the loss of the semantic similarity part is added to the loss function during fine-tuning. Specifically, two texts are input into the Bert model, and the similarity of the output vectors is calculated. The similarity is given by the cosine distance of formula (4). For related input texts, the distance of the output vector is reduced; for irrelevant input texts, the distance of the output vector is increased. The fine-tuned model with the addition of similarity loss can better extract the semantic information of the text. The text paragraphs are respectively input into the fine-tuned embedding model to obtain feature vectors, and the feature vectors and the corresponding text paragraphs are stored in the database to complete the construction of the knowledge base.

[0038] S200: This example constructs a supervised dataset, which contains a large number of medical consultation records, including multi-round and single-round dialogues. The questions in the dataset are used as the input of the Moose general large language model, and the answers and keywords are used as the output of the model for training to obtain the Moose-med model. Due to the large number of parameters in the large language model, the full-scale fine-tuning method is costly. This example uses the LORA fine-tuning method to obtain the Moose-med model suitable for the medical field after fine-tuning.

[0039] S300: Determine whether the question input by the user is related to the medical field through the text classification model, and use the template to reply to irrelevant questions. The present invention uses Bert as a classification model, uses text data from the medical field and other fields to fine-tune the pre-trained Bert, and uses the cross entropy of formula (3) as the loss function. The trained model can determine whether the text is related to the medical field;

[0040] In this example, the intent is divided into 4 categories, including opening words, closing words, medical-related and non-medical-related. Except for questions related to medical care, the present invention uses a fixed template for reply, as shown in Table 1.

[0041] Table 1 Response template

[0042]

[0043] For medical-related questions, the embedding model trained in step S100 is used for vectorization and input into the database for query;

[0044] S400: Input the vector in S300 into the database for query, and use the search algorithm to find the vector in the knowledge base that is similar to the question vector. After the search, the database will return multiple results that best match the question vector. In order to ensure the quality of the answer, a threshold is set in this example. The returned vector will be retained only if the similarity with the question vector is higher than the threshold, and the corresponding text paragraph will be returned. In this example, 0.65 is used as the threshold. When all the results returned by the knowledge base are lower than the threshold, it is considered that there is no result matching the question. The system will use a template reply to clarify the question to the user and request the user to ask the question again.

[0045] S500: The paragraph related to the question obtained from the knowledge base in S400 is used as context and added to the prompt words of the large language model Moose-med. By adding the context, the large language model can obtain knowledge related to the question, thereby avoiding factual errors and obtaining a more reliable answer.

[0046] The above shows and describes the basic principles and main features of the present invention and the advantages of the present invention. The various components mentioned in the present invention are common technologies in the existing field. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The above embodiments and descriptions are only to illustrate the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, which fall within the scope of the present invention to be protected. The scope of protection claimed by the present invention is defined by the attached claims and their equivalents.

Claims

1. A question-answering system for a knowledge base in the field of medical knowledge, characterized in that: The following steps are involved: S100: Build a medical knowledge base, use the collected data to train the embedding model, vectorize the medical knowledge, and store it in the vector database; S200: Construct a supervised dataset to fine-tune the Moose general language model and obtain the Moose-med language model suitable for the medical field; S300: Use the classification model to identify the intent of user questions, use template replies for non-medical questions, and use embedding models to vectorize questions in the medical field; S400: the question vector is matched with the content of the knowledge base through vector retrieval, and a matching result is obtained according to a threshold. After the matching result is successfully obtained, relevant paragraphs in the knowledge base are extracted; S500: Encapsulate the extracted information as context into the prompt word, and input it into the Moose-med model together with the user question to obtain the answer.

2. The question-answering system of the medical knowledge domain knowledge base according to claim 1, characterized in that: In step S100, the collected medical data is used to train the embedding model, and the medical field knowledge is vectorized and stored in the vector database. The collected original text is first segmented into multiple paragraphs, and then the paragraphs are vectorized using the embedding model. Finally, the vectors and paragraphs are stored in the knowledge base. Compared with traditional relational databases, vector databases are different in data models, data storage and data query. Data storage and retrieval are completed through the characteristics of vectors.

3. The question-answering system of the medical knowledge domain knowledge base according to claim 2, characterized in that: In step S200, a supervised dataset is constructed, which includes a large number of medical consultation records. The questions in the dataset are used as the input of the Moose general large language model, and the answer sentences and keywords are used as the output of the model for training to obtain the Moose-med model.

4. The question-answering system of the medical knowledge domain knowledge base according to claim 3, characterized in that: In step S300, a text classification model is used to determine whether the question input by the user is related to the medical field, and a template is used to reply to irrelevant questions. The classification model uses Bert as a pre-trained model, and is fine-tuned using text data from the medical field and other fields. After fine-tuning, a classification model is obtained to determine the relevance of the user's question to the medical field. A fixed template is used to reply to questions irrelevant to the medical field, and questions related to the medical field are vectorized using the embedding model in step S200.

5. The question-answering system of the medical knowledge domain knowledge base according to claim 4, characterized in that: In step S400, a vector similarity threshold is set to determine whether the question is related to the content of the knowledge base. The question vectorized in step S300 is used to query the database, and a vector similar to the question vector in the knowledge base is found through a search algorithm. The vector matching the question is obtained through threshold screening, and the relevant paragraphs are obtained. When there is no matching result in the knowledge base, a reply template is used to clarify the question to the user and the question is retrieved.

6. The question-answering system of the medical knowledge domain knowledge base according to claim 5, characterized in that: Step S500 takes the paragraph related to the question obtained from the knowledge base in step S400 as context and adds it to the prompt words of the large language model Moose-med.

Citation Information

Patent Citations

  • Auxiliary inquiry method and system based on medical entity extraction

    CN117457237A

  • Medical auxiliary question and answer method and system based on knowledge calibration and retrieval enhancement

    CN117573843A

  • Knowledge management question-answering system construction method and device

    CN118446296A

  • Medical question and answer method and device, electronic equipment and storage medium

    CN118692704A

Cited By

  • Knowledge retrieval enhancement-based oral medical large model question and answer prediction method

    CN120196725A

  • Question answering prediction method for large oral medical model based on knowledge retrieval enhancement

    CN120196725B

  • Wisdom medical query question and answer service system based on large model

    CN121092673A

  • Hospital health education intelligent question and answer method based on large language model and knowledge base

    CN121119151A

  • Question and answer method integrating target detection and large language model reasoning framework under open source swan Mongolia platform

    CN121210617A