Medical knowledge question and answer method, system and device based on large language model
By combining small-scale and large-scale language models with a large number of parameters, along with vector databases and execution tools, the problem of insufficient accuracy in medical knowledge question answering in the field of gastroenterology was solved, enabling fast and accurate health consultation services.
Patent Information
- Application Number
- CN202510138058.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-08
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2045-02-08
AI Technical Summary
Currently, large language models cannot accurately diagnose medical knowledge questions in the field of gastroenterology based on a single symptom description. They require comprehensive evaluation by combining more information, which leads to insufficient accuracy of the answers.
We employ a large language model with a small number of parameters for fast question answering, combined with a vector database and memory for retrieval. When no answer is found, we call a large language model with a large number of parameters for deep reasoning, use execution tools for online answer search, and improve the ability to digest knowledge and answer questions by fine-tuning the dataset.
It has improved the accuracy and speed of health consultations in the field of gastroenterology, provided personalized online health consultation services, and enhanced the intelligence level of question and answer.
Smart Images

Figure CN119577099B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a medical knowledge question-answering method, system, and device based on a large language model. Background Technology
[0002] With the development of Large Language Models (LLM), LLM can now accurately answer basic questions such as disease definitions and drug effects, which do not require complex logical reasoning. However, in the field of gastroenterology, many digestive system diseases cannot be accurately diagnosed based on a single symptom description from a patient. For example, abdominal pain may be caused by multiple factors such as gastritis, appendicitis, and duodenal ulcers, requiring further comprehensive evaluation based on the patient's detailed description, medical history, examination results, and daily diet. Therefore, the accuracy of LLM's answers to these medical questions requiring logical reasoning needs improvement.
[0003] In summary, improving the intelligence, accuracy, and speed of large language models in health consultations and medical knowledge Q&A in the field of gastroenterology has significant application value for enabling internet-based health consultations for the general public. Summary of the Invention
[0004] In view of the above problems, the present invention is proposed to provide a medical knowledge question-answering method, system and device based on a large language model to overcome the above problems.
[0005] One aspect of the present invention provides a medical knowledge question-answering method based on a large language model, the method comprising:
[0006] Get the question text entered by the user;
[0007] The system invokes a preset fast question-answering language model to retrieve answers from a preset vector database based on the questions raised by the user. The fast question-answering language model is implemented using a large language model with a small number of parameters. The vector data in the vector database are real number vectors formed from text fragments related to digestive specialty knowledge.
[0008] If an answer is found, the fast question-answering language model fills the question text and the found answer into a preset first prompt template to generate the first standardized answer text and outputs it to the user;
[0009] If no answer is found, a preset deep reasoning language model is invoked to call the execution tool related to the reasoning task corresponding to the current question to search for an online answer based on the question raised by the user. The question text and the search results are filled into a preset second prompt template to generate a second standardized answer text and output it to the user. The deep reasoning language model is implemented using a large language model with a large number of parameters, and the selected large language model with a large number of parameters is fine-tuned using a preset fine-tuning dataset, so that the large model has the ability to digest knowledge questions and answers.
[0010] Furthermore, the method for generating the fine-tuned dataset includes:
[0011] Search for key text information from a pre-built digestive specialty knowledge text library, and construct a digestive question-and-answer text pair dataset based on the key text information. Form a fine-tuned dataset of the digestive question-and-answer text pair dataset in a specified format, wherein the digestive question-and-answer text pair includes digestive question text and corresponding answer text.
[0012] Furthermore, the vector database can be created in the following ways:
[0013] Text data in a pre-built digestive specialty knowledge text library is sliced to form a dataset of text fragments that are suitable for large models to process while maintaining complete contextual semantic information.
[0014] Each text fragment in the text fragment dataset is converted into vector data and stored in a pre-defined vector database.
[0015] Furthermore, the method also includes:
[0016] The question texts of each user, along with the first standardized answer text generated by the fast question-and-answer language model or the second standardized answer text generated by the deep reasoning language model, are used to form a historical question-and-answer record.
[0017] The historical question-and-answer records are sliced into multiple text segments;
[0018] The segmented text fragments are converted into vector data, and the resulting vector data is stored in a preset memory database using the user's identification information as an index.
[0019] Furthermore, before invoking a preset fast question-answering language model to retrieve answers from a preset vector database based on the user's question, the method further includes:
[0020] The answer is retrieved from the memory database based on the question raised by the user, and the retrieved historical question and answer records are filled into the specified position in the first prompt template as part of the final answer.
[0021] If the fast question-answering language model does not retrieve any historical question-answering records, the specified position in the first prompt template will be empty.
[0022] Furthermore, retrieving answers from the memory database based on the user's question includes:
[0023] Obtain the identification information of the current questioning user, and retrieve the answer from the historical question and answer records of the current questioning user in the memory database based on the identification information;
[0024] If the answer is not found in the current user's question and answer history, the answer will be retrieved from the question and answer history of other users in the memory database.
[0025] Furthermore, a pre-defined deep reasoning language model is invoked to call execution tools related to the reasoning task corresponding to the current question, based on the user's question, to perform an online answer search, including:
[0026] Perform syntactic and semantic analysis on the question text input by the user to obtain at least one reasoning task to be executed corresponding to the question raised by the user.
[0027] According to the logical relationship of each pending reasoning task, the execution tool corresponding to each pending reasoning task is called sequentially to search for online answers.
[0028] Furthermore, the execution tools include online retrieval tools, OCR recognition models, and interfaces for hospital registration and appointment platforms.
[0029] Another aspect of the present invention provides a medical knowledge question-answering system based on a large language model. The system includes functional modules for implementing the above-described medical knowledge question-answering method based on a large language model. Specifically, the system includes:
[0030] The interaction module is used to obtain the question text input by the user;
[0031] A fast question-answering agent is used to invoke a preset fast question-answering language model to retrieve answers from a preset vector database based on the user's question. The fast question-answering language model is implemented using a large language model with a small number of parameters. The vector data in the vector database are real-number vectors formed from text fragments related to gastroenterology knowledge. If an answer is found, the fast question-answering language model fills the question text and the retrieved answer into a preset first prompt template to generate a first standardized answer text and outputs it to the user.
[0032] A deep reasoning agent is used to invoke a preset deep reasoning language model when the fast question-answering agent fails to find an answer by calling the preset fast question-answering language model. This model then uses an execution tool related to the reasoning task corresponding to the current question to perform an online answer search based on the user's question. The question text and search results are then filled into a preset second prompt template to generate a second standardized answer text, which is then output to the user. The deep reasoning language model is implemented using a large language model with a large number of parameters. A preset fine-tuning dataset is used to fine-tune and train the selected large language model with a large number of parameters, enabling the large model to digest knowledge-based question answers.
[0033] In another aspect, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor; when executed by the processor, the computer program implements the steps of the medical knowledge question-answering method based on a large language model as described in any of the preceding claims.
[0034] The medical knowledge question-answering method, system, and device based on a large language model provided in this invention achieve both accuracy and response speed in the field of gastroenterology through the collaborative work of two intelligent models. The fast question-answering language model quickly answers medical knowledge questions in the gastroenterology field by retrieving vector databases and memory, while the deep reasoning language model effectively expands the real-time information of the large language model by calling execution tools related to the reasoning task corresponding to the user's current question, thereby obtaining reasoning and analysis results. This invention helps improve the intelligence, accuracy, and speed of health consultation and medical knowledge question-answering in the field of gastroenterology, and has high application value for internet-based health consultations for the general public.
[0035] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and in order to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description
[0036] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. In the drawings:
[0037] Figure 1 This is a flowchart of a medical knowledge question-answering method based on a large language model, according to an embodiment of the present invention.
[0038] Figure 2 This is a schematic diagram of the structure of a medical knowledge question-answering system based on a large language model according to an embodiment of the present invention. Detailed Implementation
[0039] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
[0040] It will be understood by those skilled in the art that, unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. It should also be understood that terms such as those defined in general dictionaries should be understood to have the same meaning as in the context of the prior art and should not be interpreted in an idealized or overly formal sense unless specifically defined.
[0041] Example 1
[0042] This invention provides a medical knowledge question-answering method based on a large language model, such as... Figure 1 As shown, the medical knowledge question-answering method based on a large language model proposed in this invention includes the following steps:
[0043] S11. Obtain the question text input by the user.
[0044] In this embodiment, the question text is used to describe the question raised by the user. When engaging in medical knowledge Q&A with the large model system, the user can obtain the question text input by the user through a dialog box in the interactive interface, or through voice input and voice recognition.
[0045] S12. The preset fast question-answering language model LLM-S is invoked to retrieve answers from a preset vector database based on the user's question. The fast question-answering language model is implemented using a large language model with a small number of parameters. The vector data in the vector database are real-number vectors formed from text fragments related to digestive health knowledge. It is then determined whether an answer has been retrieved. If an answer has been retrieved, step S13 is executed; otherwise, step S14 is executed.
[0046] S13. The fast question-answering language model fills the question text and the retrieved answer into the preset first prompt template to generate the first standardized answer text and outputs it to the user.
[0047] S14. The preset deep reasoning language model LLM-L is invoked to call the execution tool related to the reasoning task corresponding to the current question to perform online answer search based on the question raised by the user. The question text and the search results are filled into the preset second prompt template to generate the second standardized answer text and output it to the user. The deep reasoning language model is implemented using a large language model with a large number of parameters, and the selected large language model with a large number of parameters is fine-tuned and trained using a preset fine-tuning dataset, so that the large model has the ability to digest knowledge question answering.
[0048] In this embodiment, the large-scale model LLM-S used in the fast question-answering language model can directly use an open-source model with a small number of parameters, while the large-scale model LLM-L used in the deep reasoning language model requires a model with a large number of parameters after fine-tuning training. Specifically, LLM-L can be fine-tuned by constructing a fine-tuning dataset. After fine-tuning training, LLM-L will have good question-answering and logical reasoning capabilities in the digestive domain of health consultation. Fine-tuning training can employ methods such as full-parameter fine-tuning, LORA fine-tuning, and Q-LORA fine-tuning; this invention does not specifically limit these methods.
[0049] The medical knowledge question-answering method based on a large language model provided in this invention achieves both accuracy and response speed in the field of gastroenterology through the collaborative work of two intelligent models. The fast question-answering language model quickly answers medical knowledge questions in the gastroenterology field by retrieving vector databases and memory, while the deep reasoning language model searches for answers online by calling execution tools related to the reasoning task corresponding to the user's current question. This effectively expands the real-time information of the large language model, thereby obtaining reasoning and analysis results. This invention helps improve the intelligence, accuracy, and speed of health consultations and medical knowledge question-answering in the field of gastroenterology, and has high application value for internet-based health consultations for the general public.
[0050] In this embodiment of the invention, the method for generating the fine-tuning dataset includes: searching for key text information from a pre-built digestive specialty knowledge text library, constructing a digestive question-and-answer text pair dataset based on the key text information, and forming a fine-tuning dataset in a specified format from the digestive question-and-answer text pair dataset, wherein the digestive question-and-answer text pair includes digestive question text and corresponding answer text.
[0051] In one specific embodiment, before obtaining the user-inputted question text in step S11, the method further includes the following steps, which are not shown in the accompanying drawings:
[0052] S01. Constructing a Gastroenterology Specialty Knowledge Text Database. In this embodiment, the gastroenterology specialty knowledge text database includes knowledge texts such as textbooks, books, and medical examination materials related to the field of gastroenterology. After collecting the relevant knowledge texts, the system performs data cleaning to construct the gastroenterology specialty knowledge database. Data cleaning includes data processing procedures such as text deduplication, text error correction, and missing data filling. After data cleaning, it can also be reviewed and corrected by experts in the field of gastroenterology to ensure the professionalism of the gastroenterology specialty knowledge text database. Furthermore, the gastroenterology specialty knowledge text database can be stored in text formats such as JSON and TXT.
[0053] S02. Search for key text information from the gastroenterology knowledge text library, and construct a gastroenterology question-and-answer text pair dataset based on the key text information. Form a fine-tuning dataset in a specified format for the gastroenterology question-and-answer text pair dataset. The gastroenterology question-and-answer text pair includes gastroenterology question text and corresponding answer text. In this embodiment, key text information is collected from the constructed gastroenterology knowledge text library to construct gastroenterology question-and-answer text pairs. These pairs refer to common gastroenterology questions and their corresponding standard answers. The gastroenterology question-and-answer text pairs constructed from the key text information need to cover disease definitions, common treatment methods, daily dietary precautions, common drug names and effects, and medical examination precautions in the gastroenterology field. Furthermore, they can be reviewed and corrected by experts in the gastroenterology field to ensure the professionalism of the data. Then, the text is processed to form a standard format fine-tuning dataset for fine-tuning training of LLM-L, enabling the large model to possess the ability to answer gastroenterology knowledge questions.
[0054] In this embodiment of the invention, the method of creating the vector database includes: slicing the text data in a pre-built digestive specialty knowledge text library to form a text fragment dataset suitable for large model processing and maintaining complete contextual semantic information; converting each text fragment in the text fragment dataset into vector data and storing it in a preset vector database.
[0055] In one specific embodiment, after constructing the digestive specialty knowledge text base, the method further includes the following steps (not shown in the accompanying drawings):
[0056] S03. Slice the text data in the digestive specialty knowledge text library to form a dataset of text fragments that are suitable for large-scale model processing and retain complete contextual semantic information.
[0057] In this embodiment, the digestive specialty knowledge text library formed in step S01 is used for text slicing, resulting in numerous text fragments. Specifically, for long text documents, direct processing becomes impractical due to the input length limitations of large models. To address the issue of input data length limitations imposed by large models, this invention segments large documents into smaller parts. These parts need to maintain semantic integrity. In one specific embodiment, slicing can be done by sentence or chapter. The purpose of slicing is to ensure that the text fragments are suitable for processing by large models while maintaining the integrity of contextual information. The specific fragment length can be set by the user according to the specific content and length; this invention does not impose specific limitations on this.
[0058] S04. Convert each text fragment in the text fragment dataset into vector data and store it in a preset vector database. In this embodiment, for the text fragments processed in step S03, the text fragments can be converted into vector data through a Text Embedding model. This invention converts text into real-number vectors through a text embedding model, so that semantically similar texts have similar vector representations in the embedding space. The vectorized data can be understood and further processed by the computer. Further, the converted vectorized data is stored in a vector database, and a file of a specified format is generated and stored on a local disk or cloud server. Optionally, the vector database includes Milvus, Chroma, Qdrant, etc. Through the vector database, Top-N data that are semantically or contextually related and similar can be quickly retrieved, rather than searching in a relational database with exact matching. Top-N refers to the results retrieved according to semantic similarity, for example, Top-5 represents the top five text data in terms of semantic similarity. In this embodiment of the invention, when the fast question-answering language model LLM-S retrieves answers from the preset vector database based on the user's question, it can select Top-2 to Top-5 as the results of the answer search.
[0059] The medical knowledge question-answering method based on a large language model provided in this invention also includes the storage operation of historical question-answering records. Specifically, the implementation steps include: forming historical question-answering records by combining the question text of each user with the first standardized answer text generated by the fast question-answering language model or the second standardized answer text generated by the deep reasoning language model; dividing the historical question-answering records into multiple text segments by text slicing; converting the segmented text segments into vector data, and storing the obtained vector data in a preset memory database using the user's identification information as an index.
[0060] In this embodiment, the memory is a vector database dedicated to storing and retrieving users' historical question-and-answer records. The answers from each LLM-S and LLM-L conversation, as well as the question-and-answer records generated by the user's questions, need to be stored in the memory. Furthermore, as a shared information module, both LLM-S and LLM-L can access and query the contents of the memory. The memory storage is indexed by user, facilitating personalized services based on individual user needs. Its advantage lies in constructing personalized private doctor consultations based on the differences of each user, resulting in higher accuracy.
[0061] The memory construction process is as follows: The user's question text and the standardized LLM-S or LLM-L answer text are used to form a historical question-and-answer record. Then, the question-and-answer record is sliced into multiple text segments according to paragraphs. The segmented text segments are converted into vector data using a Text Embedding model. Finally, the vector data is indexed by user and stored in the memory for personalized services. The role of the memory in storing historical records in subsequent question-and-answer sessions can be illustrated by the following specific question-and-answer example:
[0062] 1) User B asks, "May I drink alcohol?";
[0063] 2) Retrieve memory and find user B's historical question and answer records, querying question and answer record list-1;
[0064] 3) Based on list-1, LLM-S found that user B suffers from both reflux esophagitis and chronic atrophic gastritis. LLM-S returned the response: "You cannot drink alcohol. For patients with both reflux esophagitis and chronic atrophic gastritis, alcohol is significantly irritating and may worsen their condition. Alcohol directly irritates the gastric mucosa, potentially causing congestion, erosion, and even bleeding. Long-term alcohol consumption may reduce the esophageal mucosa's barrier function against reflux damage, thus exacerbating the inflammatory response of reflux esophagitis. Patients may experience more severe symptoms such as acid reflux and heartburn. Therefore, for your health, please abstain from alcohol. At the same time, follow your doctor's instructions for standardized treatment and maintain good dietary habits and lifestyle."
[0065] In this embodiment of the invention, before invoking a preset fast question-and-answer language model to retrieve answers from a preset vector database based on the user's question, the method further includes: retrieving answers from the memory database based on the user's question, and filling the retrieved historical question-and-answer records as part of the final answer into a designated position in the first prompt template; if the fast question-and-answer language model does not retrieve any historical question-and-answer records, the designated position in the first prompt template is empty. Further, retrieving answers from the memory database based on the user's question includes: obtaining the identifier information of the current questioning user, and retrieving answers from the current questioning user's historical question-and-answer records in the memory database based on the identifier information; if no answer is found in the current questioning user's historical question-and-answer records, then retrieving answers from the historical question-and-answer records of other users in the memory database.
[0066] Specifically, the memory is essentially a vector database, specifically used to store and retrieve the history of user questions and LLM answers. The memory itself has retrieval and storage functions. The system calls the memory's retrieval function to retrieve answers from the memory database based on the user's question, and then populates the prompt template with the retrieved answers. This allows the fast question-answering language model to output the answers after inputting the prompt. The implementation process is as follows:
[0067] User A's question is denoted as "User Question". Historical question-and-answer records are retrieved from memory, and the retrieved historical question-and-answer records are denoted as "Text 0". If no relevant historical question-and-answer records are found, "Text 0" is left empty. Specific details are as follows:
[0068] 1) User A submitted the question: "I went to the hospital and was diagnosed with Barrett's esophagus. What is this disease? What are the symptoms?"
[0069] 2) The historical question-and-answer record "Text 0" related to user X retrieved from memory is:
[0070] User A asked: "I am 50 years old and have recently experienced acid reflux. Can I take omeprazole?"
[0071] LLM-S replied: 'Omeprazole is an acid-suppressing drug used to treat various upper gastrointestinal diseases. It inhibits gastric acid secretion, reduces gastric acid damage to the mucosa, relieves related symptoms, and promotes healing. It is used for peptic ulcers, including gastric and duodenal ulcers; gastroesophageal reflux disease, including reflux esophagitis and non-erosive reflux disease; and in combination with antibiotics for the eradication of Helicobacter pylori. It is suitable for acid-related symptoms such as acid reflux, heartburn, upper abdominal pain or discomfort.'"
[0072] Then, the process of calling the preset fast question-answering language model to retrieve the answer from the vector database based on the user's question is as follows:
[0073] The fast question-answering agent mainly consists of two parts: LLM-S and a vector database. It retrieves answers from the vector database based on the user's question, organizes and presents the retrieved answers in a linguistic format, and returns them to the user. Referring to the specific example above, the retrieval implementation for the question text posed by user A also includes the following vector database retrieval process:
[0074] 1) A fast question-answering agent retrieves relevant content from a vector database. For example, the top-3 results for text similarity to Barrett's esophagus are as follows:
[0075] Text 1: "Barrett's esophagus is caused by repeated stimulation of the stomach acid and gastroesophageal reflux, leading to inflammation of the lower esophageal mucosa. Based on this inflammation, the mucosa undergoes repair, resulting in the replacement of normal esophageal squamous epithelium with mutated columnar epithelium. It is one of the complications of gastroesophageal reflux disease (GERD). Most patients experience symptoms of GERD such as acid reflux, heartburn, difficulty swallowing, and retrosternal pain, but some patients do not experience any obvious symptoms."
[0076] Text 2: "Barrett's esophagus has the potential to become cancerous, and having this disease can cause a series of symptoms and complications, which can also affect daily work and life. If treatment is not timely or appropriate, it may lead to serious complications such as esophageal stricture and esophageal cancer, affecting the patient's quality of life."
[0077] Text 3: "The key to preventing Barrett's esophagus lies in a healthy diet, lifestyle, weight loss, avoiding increased abdominal pressure, and regular gastroscopy. Specific preventive measures include a healthy diet, lifestyle, avoiding increased abdominal pressure, and regular gastroscopy."
[0078] 2) The "user question", the historical Q&A record "text 0", and the vector database search results "text 1", "text 2" and "text 3" are constructed and filled into the prompt template to form the final standardized text.
[0079] Modeling prompt words plays a crucial role in the development of large-scale dialogue models. Good prompt word templates can help large models make more accurate predictions and obtain more accurate answers. Prompt word templates can be modified according to the specific question-and-answer scenario requirements. In this embodiment, an example of a prompt word template is as follows:
[0080] "As a professional gastroenterologist, your task is to answer the user's question based on the retrieved context. The user's question is 'User Question,' and the context includes 'Text 0,' 'Text 1,' 'Text 2,' and 'Text 3.' If the context information is insufficient, please reply that you are waiting for deep reasoning. For the sake of rigor in your answer, please remind the user at the end that this answer is generated by AI and is for reference only. An accurate answer requires consultation with a gastroenterologist."
[0081] 3) LLM-S generates a response:
[0082] "Barrett's esophagus is caused by repeated stimulation from gastric acid and gastroesophageal reflux, leading to inflammation of the lower esophageal mucosa. On the basis of inflammation, there is mucosal repair, which results in the normal squamous epithelium of the esophagus being replaced by mutated columnar epithelium. It is one of the complications of gastroesophageal reflux disease."
[0083] Common symptoms of Barrett's esophagus include acid reflux, heartburn, difficulty swallowing, and retrosternal pain, but some patients may not experience any obvious symptoms.
[0084] The above information is AI-generated data and is for reference only. It is recommended that you consult a gastroenterologist to avoid delaying your treatment.
[0085] 4) In addition, a logical decision needs to be made regarding whether to invoke the deep inference agent. Specifically, if the fast question-answering agent does not find the answer in the vector database, it needs to directly invoke the deep inference agent.
[0086] 5) Store user A's question and the final answer generated by LLM-S as a question-and-answer history in memory.
[0087] In this embodiment of the invention, a preset deep reasoning language model is invoked to call execution tools related to the reasoning task corresponding to the current question for online answer search based on the user's question. Specifically, this includes: performing syntactic and semantic analysis on the user-input question text to obtain at least one reasoning task to be executed corresponding to the user's question; and sequentially invoking the execution tools corresponding to each reasoning task to perform online answer search according to the logical relationship between the tasks. The execution tools include online retrieval tools, OCR recognition models, and hospital appointment booking platform interfaces. The hospital appointment booking platform interface uses the FastAPI framework to build services and exchange data through interface calls.
[0088] A deep reasoning agent consists of three indispensable parts: LLM-L, step design (specifically including the determination of the reasoning task to be performed and the invocation of execution tools), and tool library.
[0089] The Deep Reasoning Language Model (LLM-L) is a finely tuned large language model with enhanced language understanding and logical reasoning capabilities.
[0090] Step design refers to establishing specific processes such as tool invocation, online retrieval, and online appointment based on the inference tasks to be executed in the user's instructions. Specific implementation examples of step design are illustrated through the following different scenarios:
[0091] Scenario 1: When a user uploads an inspection report, the agent needs to be designed with the following steps:
[0092] 1) The user asks for information related to the inspection report; 2) LLM-L sends a request to upload the inspection report image; 3) The OCR model is called to recognize the image and extract the text; 4) The recognized text is sent to LLM-L; 5) LLM-L queries the memory for relevant information and provides an answer.
[0093] Scenario 2: When a user makes a real-time information request, the intelligent agent needs to be designed with the following steps:
[0094] 1) A user asks if a specific specialist at a hospital has available appointments; 2) The user uses an online appointment tool to search for relevant information; 3) LLM-L organizes and compiles the relevant information and recommends an appointment booking link back to the user.
[0095] Scenario 3: The user has submitted a plain text query. The intelligent agent needs to be designed with the following steps:
[0096] 1) User asks a question; 2) LLM-L responds;
[0097] Specifically, the toolkit includes online search tools, OCR models, and appointment booking interfaces provided by hospitals. When a user submits a question, LLM-L can use online search tools to search for relevant information online; the OCR model can extract text information from user-uploaded physical examination and examination photos; and when a user requests an appointment booking, the hospital's appointment booking interface can be used to complete the booking process. After invoking the appropriate tools, LLM-L will comprehensively analyze the information provided by the toolkit to further deduce the answer.
[0098] Specific Q&A examples are as follows:
[0099] 1) User B asked: "I've had an upset stomach recently and went to the hospital for a checkup. What should I pay attention to in my diet?"
[0100] 2) LLM-L replied: "Please provide an image of the examination report for more detailed information."
[0101] 3) User B submits the inspection report image.
[0102] 4) Call the OCR model and save the recognized text results into "OCR Recognized Text". For example, "Orange-red mucosa is visible in the upper esophagus. The remaining esophageal mucosa is smooth and pink with clear vascular patterns and good contraction and relaxation. A longitudinal mucosal rupture, approximately 6 mm in length, is seen near the cardia at the lower end of the esophagus, reaching the cardia 40 cm from the incisors. The mucosa is smooth. The cardia is normal. The mucosa near the cardia on the lesser curvature of the upper stomach is slightly rough. The antral mucosa is not smooth, with alternating red and white patches, predominantly white. There is no deformation, congestion, edema, or ulceration in the pyloric and duodenal bulb cavities. Endoscopic diagnosis: reflux esophagitis, chronic atrophic gastritis."
[0103] 5) Use online search tools to retrieve relevant science articles on reflux esophagitis and atrophic gastritis, such as link-1, link-2, and link-3, so as to push relevant knowledge to users.
[0104] 6) Fill in "OCR-recognized text" and links-1,-2, and-3 into the prompt template to form the complete prompt: "The result of calling the OCR tool is 'OCR-recognized text,' and related popular science articles are recommended as links-1,-2, and-3. You are a senior medical expert in the field of gastroenterology. Please answer the 'user question' based on the above information. To ensure the rigor of your answer, please remind the user at the end that this answer is generated by AI and is for reference only."
[0105] 7) LLM-L generates a response based on the prompt words:
[0106] "Based on your test results, you have both reflux esophagitis and chronic atrophic gastritis. For patients with both conditions, the following dietary precautions should be taken:"
[0107] 1. Avoid irritating foods: Foods such as chili peppers, black pepper, and mustard can irritate the esophageal and gastric mucosa and worsen the condition;
[0108] 2. Avoid raw and cold foods: cold drinks, ice cream, raw foods, etc., can easily cause acid reflux and stomach discomfort;
[0109] 3. Avoid greasy foods: fried foods, fatty meats, etc., can easily increase the burden on the stomach;
[0110] 4. Avoid sweet and sour foods: Candy, chocolate, hawthorn, lemon, etc., may stimulate gastric acid secretion and worsen the symptoms of reflux esophagitis;
[0111] 5. Protein intake: Consume appropriate amounts of lean meat, fish, eggs, beans, and other foods rich in high-quality protein;
[0112] 6. Eat more fresh vegetables and fruits: They are rich in vitamins, minerals, and dietary fiber, which help with bowel movements and digestion.
[0113] In summary, we recommend the following articles (links 1, 2, and 3). The information above is AI-generated and for reference only. We suggest you consult a gastroenterologist to avoid delaying your diagnosis and treatment.
[0114] 8) Store the question and answer record in memory.
[0115] In summary, the medical knowledge question-answering method based on a large language model provided in this invention mainly consists of three parts: a fast question-answering agent, a deep reasoning agent, and a memory. During the question-answering process, the fast question-answering agent is called first; if no suitable answer is found, the deep reasoning agent is called. Wherein:
[0116] 1) Rapid Question-Answering Agent: This agent directly engages in question-and-answer sessions with patients. The large model rapidly responds based on answers and question-and-answer history retrieved from a vector database and memory. The large model of this agent uses a small-scale LLM (Limited-Scale Model), abbreviated as LLM-S. This process is similar to human intuitive responses, enabling rapid responses to patients' basic questions.
[0117] 2) Deep Reasoning Agent: This agent performs multi-step reasoning and planning through multiple rounds of dialogue with patients, online searches, and tool invocation. Its large-scale model uses a finely tuned LLM-L with a large number of parameters, resulting in enhanced language understanding and logical reasoning capabilities. The agent resembles a thoughtful and logically-driven human, comprehensively considering various factors to answer complex patient questions. Tool invocation includes access to web search tools, OCR (Optical Character Recognition) models, and hospital-provided appointment booking interfaces.
[0118] 3) Memory: Essentially a vector database, both the large models of the two agents, LLM-S and LLM-L, can interact with the memory to store and retrieve valid historical question-and-answer records. When the user asks a question again, the large model will take into account the historical question-and-answer records in the memory.
[0119] The medical knowledge question-answering method based on a large language model provided in this invention achieves both accuracy and response speed in the field of gastroenterology through the collaborative work of two intelligent models. The fast question-answering language model quickly answers medical knowledge questions in the gastroenterology field by retrieving vector databases and memory, while the deep reasoning language model searches for answers online by calling execution tools related to the reasoning task corresponding to the user's current question. This effectively expands the real-time information of the large language model, thereby obtaining reasoning and analysis results. Both LLM-S and LLM-L can retrieve and store the user's historical question-answering records through memory, enabling personalized health question-answering services in the gastroenterology field for each user. This invention helps improve the intelligence, accuracy, and speed of health consultations and medical knowledge question-answering in the gastroenterology field, and has high application value for internet-based health consultations for the general public.
[0120] To ensure the security and privacy of the final response content generated by the question-and-answer system, the medical knowledge question-and-answer method based on a large language model provided in this embodiment of the invention also includes text processing operations to de-identify and filter the response content generated by LLM-S and LLM-L. Specifically, this includes organizing the returned text from LLM-S and LLM-L, filtering user information and sensitive information from the Response, and outputting the final result text to the user.
[0121] For the sake of simplicity, the method embodiments are described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.
[0122] Example 2
[0123] Another embodiment of the present invention provides a medical knowledge question-answering system based on a large language model, the system including functional modules for implementing the medical knowledge question-answering method based on a large language model as described in any of the preceding claims. Figure 2 The schematic diagram illustrates the structure of a medical knowledge question-answering system based on a large language model provided by an embodiment of the present invention. (Refer to...) Figure 2 An embodiment of the present invention provides a medical knowledge question-answering system based on a large language model, specifically comprising an interaction module 201, a fast question-answering agent 202, and a deep reasoning agent 203, wherein:
[0124] Interaction module 201 is used to obtain the question text input by the user;
[0125] A fast question-answering agent 202 is used to invoke a preset fast question-answering language model to retrieve answers from a preset vector database based on the user's question. The fast question-answering language model is implemented using a large language model with a small number of parameters. The vector data in the vector database are real-number vectors formed from text fragments related to digestive specialty knowledge. If an answer is found, the fast question-answering language model fills the question text and the retrieved answer into a preset first prompt template to generate a first standardized answer text and outputs it to the user.
[0126] The deep reasoning agent 203 is used to call the preset deep reasoning language model when the fast question answering agent fails to find an answer by calling the preset fast question answering language model. The deep reasoning language model is used to call the execution tool related to the reasoning task corresponding to the current question to search for an online answer based on the question raised by the user. The question text and the search results are filled into the preset second prompt template to generate a second standardized answer text and output it to the user. The deep reasoning language model is implemented using a large language model with a large number of parameters. The selected large language model with a large number of parameters is fine-tuned and trained using a preset fine-tuning dataset, so that the large model has the ability to digest knowledge-based question answering.
[0127] In this embodiment of the invention, the system further includes a fine-tuning dataset generation module (not shown in the accompanying drawings), wherein:
[0128] The fine-tuning dataset generation module is used to search for key text information from a pre-built digestive specialty knowledge text library, construct a digestive question-and-answer text pair dataset based on the key text information, and form a fine-tuning dataset in a specified format, wherein the digestive question-and-answer text pair includes digestive question text and corresponding answer text.
[0129] Furthermore, the system also includes a vector database creation module (not shown in the accompanying drawings), comprising a knowledge base slicing submodule and a first text vectorization submodule, wherein:
[0130] The knowledge base slicing submodule is used to slice the text data in the pre-built digestive specialty knowledge text library to form a dataset of text fragments that are suitable for large models to process and retain the complete contextual semantic information.
[0131] The first text vectorization submodule is used to convert each text fragment in the text fragment dataset into vector data and store it in a preset vector database.
[0132] Furthermore, the system also includes a knowledge base construction module (not shown in the accompanying drawings), which is used to pre-build a digestive specialty knowledge text database.
[0133] In this embodiment of the invention, the system further includes a question-and-answer record construction module, a question-and-answer record slicing module, and a second text vectorization module (not shown in the accompanying drawings), wherein:
[0134] The question-and-answer record building module is used to form historical question-and-answer records by combining the question texts of each user with the first standardized answer text generated by the fast question-and-answer language model or the second standardized answer text generated by the deep reasoning language model.
[0135] The question and answer record slicing module is used to slice historical question and answer records into multiple text segments;
[0136] The second text vectorization module is used to convert the segmented text fragments into vector data and store the resulting vector data into a preset memory database using the user's identification information as an index.
[0137] Furthermore, the system also includes a memory, which is used to retrieve answers from the memory database based on the questions raised by the user, and to fill the retrieved historical question-and-answer records as part of the final answer into a designated position in the first prompt template; if the fast question-and-answer language model does not retrieve any historical question-and-answer records, the designated position in the first prompt template is empty.
[0138] Furthermore, the memory is specifically used to obtain the identification information of the current questioning user, and to retrieve the answer from the historical question-and-answer records of the current questioning user in the memory database based on the identification information; if the answer is not found in the historical question-and-answer records of the current questioning user, the answer is retrieved from the historical question-and-answer records of other users in the memory database.
[0139] In this embodiment of the invention, the deep reasoning agent 203 is specifically used to perform syntactic and semantic analysis on the question text input by the user to obtain at least one reasoning task to be executed corresponding to the question raised by the user; and sequentially call the execution tool corresponding to each reasoning task to perform online answer search according to the logical relationship of each reasoning task. The execution tool includes an online retrieval tool, an OCR recognition model, and a hospital registration and appointment platform interface.
[0140] In the specific implementation process of Embodiment 2, you can refer to Embodiment 1, and it has the corresponding technical effects.
[0141] Example 3
[0142] This invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps described in the various embodiments of the medical knowledge question-answering method based on a large language model. For example... Figure 1Steps S11-S14 are shown. Alternatively, when the processor executes the computer program, it implements the functions of each module in the above embodiments of the medical knowledge question-answering system based on a large language model, for example... Figure 2 The interactive module 201, the fast question-answering agent 202, and the deep reasoning agent 203 are shown.
[0143] In its specific implementation, Example 3 can be referred to Example 1 and has the same technical effects.
[0144] Furthermore, those skilled in the art will understand that although some embodiments herein include certain features included in other embodiments but not others, combinations of features from different embodiments are intended to be within the scope of the invention and form different embodiments. For example, any of the claimed embodiments can be used in any combination.
[0145] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for medical knowledge question answering based on a large language model, characterized in that, The method is applied to the field of digestive specialist, and includes: Obtaining question text input by a user; Calling a retrieval function of a memory to retrieve an answer from a memory database according to a question raised by the user, including obtaining identification information of a current user raising a question, and retrieving an answer from historical question and answer records of the current user raising a question in the memory database according to the identification information, the memory being indexed according to users to provide personalized services, so as to construct personalized private doctor consultations according to differences between users, and filling the retrieved historical question and answer records into a specified position in a first prompt template corresponding to a quick question and answer language model as part of a final answer, the quick question and answer language model analyzing user digestive disease information according to the historical question and answer records to give an answer based on the influence of the user's digestive disease; the memory is a vector database for storing and querying historical question and answer records of users; Calling a preset quick question and answer language model to retrieve an answer from a preset vector database according to a question raised by the user, the quick question and answer language model being implemented by using a small-scale parameter large language model, and vector data in the vector database being real vectors formed according to text segments related to digestive specialist knowledge; If an answer is retrieved, the quick question and answer language model fills the question text and the retrieved answer into the first prompt template filled with the historical question and answer records to generate a first standardized answer text and outputs the first standardized answer text to the user; If an answer is not retrieved, a preset deep reasoning language model is called to call an execution tool related to a reasoning task corresponding to the current question to perform online answer search according to the question raised by the user, including calling an OCR model to recognize a test report image to obtain OCR recognized text including user disease information, calling an online retrieval tool to retrieve popular science article links related to the disease information, filling the question text, the OCR recognized text and the popular science article links into a preset second prompt template to generate a second standardized answer text and outputting the second standardized answer text to the user, the deep reasoning language model being implemented by using a large-scale parameter large language model, and the large-scale parameter large language model being fine-tuned by using a preset fine-tuning data set, so that the large model has the ability of digestive knowledge question and answer; The generation method of the fine-tuning data set includes: searching for key text information from a pre-constructed digestive specialist knowledge text library, and constructing a digestive question and answer text pair data set according to the key text information, and forming a fine-tuning data set in a specified format from the digestive question and answer text pair data set, wherein the digestive question and answer text pair includes digestive question text and corresponding answer text, and the digestive question and answer text pair covers disease definitions, common treatment methods, daily diet precautions, common drug names and effects, and medical examination precautions in the digestive field.
2. The method of claim 1, wherein, The creation method of the vector database includes: Text slicing is performed on text data in a pre-constructed digestive specialist knowledge text library to form a text segment data set suitable for processing by a large model and keeping the context semantic information complete; Convert each text segment in the text segment dataset into vector data and store it in a preset vector database.
3. The method of claim 1, wherein, The method further comprises: forming the question text of each user and the first standardized answer text generated by the quick question and answer language model or the second standardized answer text generated by the deep reasoning language model into a historical question and answer record; text slicing the historical question and answer record to divide it into multiple text segments; convert the divided text segments into vector data, and store the obtained vector data in a preset memory database indexed by the user's identification information.
4. The method of claim 3, wherein, Before calling the preset quick question and answer language model to retrieve an answer from the preset vector database according to the question raised by the user, the method further comprises: If no historical question and answer record is retrieved in the memory database, the specified position in the first prompt template is empty.
5. The method of claim 4, wherein, Retrieving an answer from the memory database according to the question raised by the user comprises: If the answer is not retrieved in the historical question and answer record of the current asking user, retrieve the answer from the historical question and answer record of other users in the memory database.
6. The method of claim 1, wherein, Calling a preset deep reasoning language model to call an execution tool related to the reasoning task corresponding to the current question to perform online answer search according to the question raised by the user comprises: performing syntax and semantic analysis on the question text input by the user to obtain at least one reasoning task to be executed corresponding to the question raised by the user; sequentially calling an execution tool corresponding to each reasoning task to be executed according to the logical relationship between the reasoning tasks to perform online answer search.
7. The method of claim 6, wherein, The execution tool includes an online retrieval tool, an OCR recognition model, and a hospital appointment reservation platform interface.
8. A medical knowledge question answering system based on a large language model, characterized by, The system is applied to the field of digestive specialist, comprising: an interaction module for obtaining question text input by a user; a memory for retrieving an answer from the memory database according to the question raised by the user, comprising obtaining the identification information of the current asking user, and retrieving an answer from the historical question and answer record of the current asking user in the memory database according to the identification information, the storage of the memory is indexed according to the user, facilitating personalized service according to the user, and constructing personalized private doctor consultation according to the differences between each user; and filling the retrieved historical question and answer record as part of the final answer into the specified position in the first prompt template, the quick question and answer language model analyzes the user's digestive disease information based on the historical question and answer record to give an answer; the memory is a vector database for storing and querying user historical question and answer records; a quick question and answer agent for calling a preset quick question and answer language model to retrieve an answer from a preset vector database according to a question raised by a user, the quick question and answer language model is implemented by a small-scale parameter large language model, and the vector data in the vector database is a real vector formed according to text segments related to digestive specialist knowledge; if an answer is retrieved, the quick question and answer language model fills the question text and the retrieved answer into a preset first prompt template to generate a first standardized answer text and outputs it to the user; The deep reasoning intelligent agent is used for calling a preset deep reasoning language model to search an online answer according to an execution tool related to a current reasoning task of a question raised by a user when a preset quick question and answer language model fails to search an answer when a quick question and answer intelligent agent calls the preset quick question and answer language model, and the deep reasoning intelligent agent comprises the following steps: calling an OCR model to identify a check report image to obtain OCR identified text including disease information of the user, calling an online search tool to search a popular science article link related to the disease information, filling the question text, the OCR identified text and the popular science article link into a preset second prompt template to generate a second standardized answer text and output the second standardized answer text to the user, and the deep reasoning language model is implemented by using a large-scale parameter large language model, and the large-scale parameter large language model is trained by using a preset fine-tuning data set, so that the large model has the ability of digesting knowledge and answering questions. The generation mode of the fine-tuning data set comprises the following steps: searching key text information from a pre-constructed digestive specialist knowledge text library, and constructing a digestive question and answer text pair data set according to the key text information, forming a fine-tuning data set in a specified format, wherein the digestive question and answer text pair data set comprises digestive question texts and corresponding answer texts, and the digestive question and answer text pair data set covers disease definitions, common treatment methods, daily diet precautions, common drug names and functions, and medical examination precautions in the digestive field.
9. A computer device, comprising: A computer program product comprising a memory, a processor and a computer program stored on the memory and loadable on the processor; the computer program, when executed by the processor, implements the steps of the method according to any one of claims 1-7.
Citation Information
Patent Citations
Method for improving response speed of large-scale language model based on similarity retrieval
CN116910221A
Intelligent question answering method and device based on emotion assistance, medium and equipment
CN118394910A