Medical knowledge question-answering method, system and equipment based on large language model

By adopting the collaborative work of the fast question-and-answer language model and the deep reasoning language model in the field of digestive specialties, the problem of accuracy and speed of large language models in the medical knowledge question-and-answer field is solved, and more efficient medical knowledge question-and-answer service is achieved.

CN119577099AActive Publication Date: 2025-03-07QINGDAO MEDICON DIGTAL ENG CO LTD

Patent Information

Application Number
CN202510138058.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-08
Publication Date
2025-03-07
Estimated Expiration
2045-02-08

AI Technical Summary

Technical Problem

At this stage, the large language model has problems of accuracy and speed in medical knowledge Q&A in the field of digestive specialties, especially in complex situations where logical reasoning is required.

Method used

Using a medical knowledge question-and-answer method based on large language models, the fast question-and-answer language model and deep inference language model are used to quickly retrieve vector databases and memory, or call relevant execution tools online for answer search. The fast question-and-answer language model uses a large language model with small-scale parameters, and the deep reasoning language model has been fine-tuned and trained to have the ability to digest knowledge question-and-answer.

Benefits of technology

It improves the accuracy and speed of medical knowledge questions and answers in the field of digestive specialties, can quickly answer medical knowledge questions in the field of digestive, and expands real-time information through in-depth reasoning to provide more accurate analysis results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119577099A_ABST
    Figure CN119577099A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of artificial intelligence, and provides a medical knowledge question answering method, system and device based on a large language model, and the method comprises the steps: obtaining a question text inputted by a user; calling a quick question and answer language model to retrieve answers from a vector database according to questions proposed by a user, vector data in the vector database being real number vectors formed according to text fragments related to the digestive specialized knowledge, if the answer is retrieved, filling the question text and the retrieved answer into a prompt template to generate a standardized answer text, and outputting the standardized answer text to the user; and if no answer is retrieved, calling a deep reasoning language model to call an execution tool related to a reasoning task corresponding to the current question according to the question to perform online answer search, filling a question text and a search result into a prompt template to generate a second standardized answer text, and outputting the second standardized answer text to the user. Through cooperative work of the two intelligent models, the accuracy and the reply speed of medical knowledge questions and answers are considered.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present 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 Art

[0002] With the development of Large Language Model (LLM), LLM can now accurately answer basic questions such as disease definition and drug effects, which do not require complex logical reasoning. However, in the field of gastroenterology, many digestive system diseases cannot be accurately diagnosed through a single symptom description of the patient. For example, the symptom of abdominal pain may be due to multiple reasons such as gastritis, appendicitis, duodenal ulcer, etc., and further comprehensive evaluation is required based on the patient's detailed description, medical history, test results, daily diet, etc. Therefore, the accuracy of the answers given by LLM to such medical questions that require logical reasoning needs to be improved at this stage.

[0003] In summary, how to improve the intelligence, accuracy, and speed of large language models in health consultation and medical knowledge question and answer in the field of digestive medicine has important application value for realizing Internet health consultation 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 and answer 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: Get the question text entered by the user; Calling a preset fast question-answering language model to retrieve answers from a preset vector database according to questions raised by the user, wherein the fast question-answering language model is implemented by a large language model with a small number of parameters, and the vector data in the vector database are real number vectors formed according to text fragments 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 output it to the user; If no answer is retrieved, the preset deep reasoning language model is called to call the execution tool related to the reasoning task corresponding to the current question according to the question raised by the user to perform an online answer search, and the question text and 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, and a preset fine-tuning data set is used to fine-tune the selected large language model with a large number of parameters, so that the large model has the ability to digest knowledge questions and answers.

[0006] Furthermore, the method of generating the fine-tuning dataset includes: Key text information is searched from a pre-built digestive specialty knowledge text library, and a digestive question-answer text pair dataset is constructed based on the key text information, and the digestive question-answer text pair dataset is formed into a fine-tuned dataset in a specified format, wherein the digestive question-answer text pair includes a digestive question text and a corresponding answer text.

[0007] Furthermore, the vector database is created in the following manner: Slice the text data in the pre-built digestive knowledge text library to form a text segment dataset suitable for large model processing and with complete contextual semantic information; Each text segment in the text segment data set is converted into vector data and stored in a preset vector database.

[0008] Furthermore, the method further comprises: The question text of each user and 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 form a historical question and answer record; Slice the historical question and answer records into multiple text segments; The segmented text segments are converted into vector data, and the obtained vector data is stored in a preset memory database using the user's identification information as an index.

[0009] Furthermore, before calling the preset fast question-answering language model to retrieve answers from a preset vector database according to the questions raised by the user, the method further includes: Retrieving answers from the memory database according to the questions raised by the user, and filling the retrieved historical question and answer records into a designated position in the first prompt template as part of the final answer; If the quick question and answer language model does not retrieve any historical question and answer records, the designated position in the first prompt template is empty.

[0010] Further, retrieving answers from the memory database according to questions raised by the user includes: Obtain identification information of the user currently asking the question, and preferentially retrieve answers from historical question and answer records of the user currently asking the question in a memory database according to 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.

[0011] Furthermore, the preset deep reasoning language model is called to call the 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, including: Performing grammatical and semantic analysis on the question text input by the user to obtain at least one to-be-performed reasoning task corresponding to the question raised by the user; According to the logical relationship of each reasoning task to be executed, the execution tool corresponding to each reasoning task to be executed is called in turn to perform online answer search.

[0012] Furthermore, the execution tool includes an online search tool, an OCR recognition model and a hospital registration and appointment platform interface.

[0013] Another aspect of the present invention provides a medical knowledge question-answering system based on a large language model, the system comprising a functional module for implementing the above medical knowledge question-answering method based on a large language model. Specifically, the system comprises: An interactive module, used to obtain question text input by the user; A quick question-answering agent is used to call a preset quick question-answering language model to retrieve an answer from a preset vector database according to a question raised by a user, wherein the quick question-answering language model is implemented by a large language model with a small number of parameters, and the vector data in the vector database are real number vectors formed according to text fragments related to digestive specialist knowledge; if an answer is retrieved, the quick 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 output it to the user; A deep reasoning agent is used to call a preset deep reasoning language model to call an execution tool related to the reasoning task corresponding to the current question according to the question raised by the user to perform an online answer search when the quick question and answer agent calls a preset quick question and answer language model and fails to retrieve an answer. The question text and 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 a preset fine-tuning data set is used to fine-tune the selected large language model with a large number of parameters, so that the large model has the ability to digest knowledge questions and answers.

[0014] Another aspect of the present invention provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor; when the computer program is executed by the processor, the steps of the medical knowledge question and answer method based on a large language model as described in any one of the above items are implemented.

[0015] The medical knowledge question-and-answer method, system and device based on a large language model provided by the embodiment of the present invention take into account the accuracy and response speed of questions and answers in the digestive field through the collaborative work of two intelligent models, wherein the fast question-and-answer language model can quickly answer medical knowledge questions in the digestive field by retrieving the vector database and memory, and the deep reasoning language model can search for answers online by calling the execution tool related to the reasoning task corresponding to the current question raised by the user, which can effectively expand the real-time information of the large language model and obtain the reasoning and analysis results. The present invention helps to improve the intelligence, accuracy and speed of health consultation and medical knowledge question-and-answer in the field of digestive specialty, and has a high application value for Internet health consultation of the general public.

[0016] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only used for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. In the accompanying drawings: Figure 1 A flowchart of a medical knowledge question-answering method based on a large language model according to an embodiment of the present invention; Figure 2 The figure is a schematic diagram of the structure of a medical knowledge question and answer system based on a large language model according to an embodiment of the present invention. DETAILED DESCRIPTION

[0018] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.

[0019] Those skilled in the art will understand that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as generally understood by those skilled in the art in the art to which the present invention belongs. It should also be understood that terms such as those defined in general dictionaries should be understood to have meanings consistent with the meanings in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless specifically defined.

[0020] Embodiment 1 The embodiment of the present 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 the present invention comprises the following steps: S11. Obtain the question text input by the user.

[0021] In this embodiment, the question text is used to describe the question raised by the user. When the user conducts medical knowledge Q&A with the large model system, the user can obtain the question text input by the user through the dialog box in the interactive interface, or through voice input and voice recognition.

[0022] S12, calling the preset fast question-answering language model LLM-S to retrieve the answer from the preset vector database according to the question raised by the user, the fast question-answering language model is implemented by a large language model with a small parameter amount, and the vector data in the vector database is a real vector formed according to the text fragments related to digestive specialist knowledge. Determine whether the answer is retrieved, if the answer is retrieved, execute step S13, if not, execute step S14; S13. The quick question and answer language model fills the question text and the retrieved answer into the preset first prompt template to generate a first standardized answer text and output it to the user.

[0023] S14. Call the preset deep reasoning language model LLM-L to call the execution tool related to the reasoning task corresponding to the current question according to the question raised by the user to perform online answer search, fill the question text and search results 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, and a preset fine-tuning data set is used to fine-tune the selected large language model with a large number of parameters, so that the large model has the ability to digest knowledge questions and answers.

[0024] In this embodiment, the large model LLM-S used in the quick question and answer language model can directly use an open source model with a small-scale parameter amount, and the large model LLM-L used in the deep reasoning language model needs to use a model with a large-scale parameter amount after fine-tuning training. Specifically, fine-tuning training of LLM-L can be performed by constructing a fine-tuning data set. After fine-tuning training, LLM-L will have good health consultation question and answer and logical reasoning capabilities in the field of digestion. Among them, fine-tuning training can select methods such as full parameter fine-tuning, LORA fine-tuning, Q-LORA fine-tuning, etc., and the present invention does not specifically limit this.

[0025] The medical knowledge question-and-answer method based on a large language model provided by an embodiment of the present invention takes into account the accuracy and response speed of questions and answers in the digestive field through the collaborative work of two intelligent models, wherein the fast question-and-answer language model can quickly answer medical knowledge questions in the digestive field by retrieving a vector database and memory, and the deep reasoning language model searches for answers online by calling execution tools related to the reasoning tasks corresponding to the current questions raised by the user, which can effectively expand the real-time information of the large language model, and then obtain reasoning and analysis results. The present invention helps to improve the intelligence, accuracy and speed of health consultation and medical knowledge question-and-answer in the field of digestive specialists, and has a high application value for Internet health consultations for the general public.

[0026] In an embodiment of the present invention, the method for generating the fine-tuning dataset includes: searching for key text information from a pre-constructed digestive specialty knowledge text library, and constructing a digestive question and answer text pair dataset based on the key text information, and forming the digestive question and answer text pair dataset into a fine-tuning dataset of a specified format, wherein the digestive question and answer text pair includes a digestive question text and a corresponding answer text.

[0027] In a specific embodiment, before obtaining the question text input by the user in step S11, the method further includes the following steps which are not shown in the drawings: S01. Construct a digestive specialist knowledge text library. In this embodiment, the digestive specialist knowledge text library includes knowledge texts such as teaching materials, books, and medical examination materials related to the digestive field. After the system collects the relevant knowledge texts, it performs data cleaning to construct a digestive specialist knowledge base. Data cleaning includes data processing processes such as text deduplication, text error correction, and missing filling. After data cleaning, it can also be reviewed and corrected by experts in the digestive field to ensure the professionalism of the digestive specialist knowledge text library. Furthermore, the digestive specialist knowledge text library can be stored in text formats such as json and txt.

[0028] S02, search for key text information from the digestive specialist knowledge text library, and construct a digestive question and answer text pair data set based on the key text information, and form the digestive question and answer text pair data set into a fine-tuning data set of a specified format, wherein the digestive question and answer text pair includes a digestive question text and a corresponding answer text. In this embodiment, in the constructed digestive specialist knowledge text library, key text information is collected to construct a digestive question and answer text pair, and the digestive question and answer text pair refers to a conventional digestive question and a corresponding standard answer. The digestive question and answer text pair constructed by key text information needs to cover the disease definition, common treatment methods, daily diet precautions, common drug names and functions, medical examination precautions and other contents in the digestive field, and can also be reviewed and revised by experts in the digestive field to ensure the professionalism of the data. Then the text is processed to form a fine-tuning data set in a standard format for fine-tuning training of LLM-L, so that the large model has the ability to digest knowledge questions and answers.

[0029] In an embodiment of the present invention, the method for creating the vector database includes: slicing the text data in a pre-constructed digestive specialty knowledge text library to form a text fragment data set suitable for large model processing and keeping contextual semantic information intact; converting each text fragment in the text fragment data set into vector data and storing it in a preset vector database.

[0030] In a specific embodiment, after constructing the digestive specialist knowledge text library, the method further includes the following steps which are not shown in the accompanying drawings: S03. Slice the text data in the digestive specialist knowledge text library to form a text fragment dataset that is suitable for large model processing and keeps contextual semantic information intact.

[0031] In this embodiment, the digestive specialty knowledge text library formed in step S01 is used to perform text slicing operations, and many text fragments are formed after slicing. Specifically, for long text documents, direct processing becomes infeasible due to the input length limit of the large model. In order to solve the problem of the length limit of the input data for the large model, the present invention divides and slices large documents into smaller parts. These parts need to maintain semantic integrity. In a specific embodiment, it can be segmented according to sentences or chapters. The purpose of segmentation is to ensure that the text slices are suitable for large model processing while maintaining the integrity of the context information. The specific slice length can be set by the user according to the specific content and length, and the present invention does not make specific limitations on this.

[0032] S04, convert each text segment in the text segment data set into vector data and store it in a preset vector database. In this embodiment, for the text segment processed in step S03, the text segment can be converted into vector data through the Text Embedding text embedding model. The present invention converts the text into a real vector 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 a computer. Further, the converted vectorized data is stored in a vector database, and a file in a specified format is generated and stored in a local disk or a cloud server. Optionally, the vector database includes Milvus, Chroma, Qdrant, etc., and the vector database can quickly retrieve the Top-N data with semantic or contextual meanings and similarities, rather than the search of an exact matching relational database. Among them, Top-N refers to the results found by sorting according to semantic similarity, for example, Top-5 represents the top five text data in semantic similarity sorting. In an embodiment of the present invention, when the fast question and answer language model LLM-S retrieves the answer from the preset vector database according to the question raised by the user, Top-2~Top-5 can be selected as the answer search result.

[0033] The medical knowledge question and answer method based on a large language model provided in an embodiment of the present invention also includes a storage operation of historical question and answer records, which specifically includes the implementation steps of: forming a historical question and answer record with 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; slicing the historical question and answer record to divide it into multiple text segments; converting the segmented text segments into vector data, and storing the obtained vector data in a preset memory database with the user's identification information as the index.

[0034] In this embodiment, the memory is a vector database dedicated to storing and querying the user's historical question and answer records. The answers of LLM-S and LLM-L in each conversation process and the question and answer records formed by the user's questions need to be stored in the memory. And the memory is used as a shared information module, and both LLM-S and LLM-L can access the contents of the query memory. The storage of the memory is indexed according to the user, which is convenient for personalized services based on the user. Its advantage is that a personalized private doctor consultation is constructed according to the differences of each user, and its accuracy is higher.

[0035] The process of building the memory is as follows: The text of the user's question and the standardized answer text of LLM-S or LLM-L are used to form a historical question and answer record. Then the question and answer record is sliced ​​and divided into multiple text segments according to paragraphs. The segmented text segments are converted into vector data using the Text Embedding model. Finally, the vector data is indexed and stored in the memory according to the user, which facilitates personalized services based on the user. After the memory stores the historical records, the role it plays in the next question and answer can be explained through the following specific question and answer example: 1) User B asks “Can I drink?”; 2) Search the memory, retrieve the historical question and answer records of user B, and query the question and answer record list-1; 3) LLM-S finds that user B suffers from reflux esophagitis and chronic atrophic gastritis based on list-1. LLM-S returns the response: "You cannot drink alcohol. For patients with both reflux esophagitis and chronic atrophic gastritis, alcohol is a significant irritant and may aggravate the condition. Alcohol directly irritates the gastric mucosa, which may cause congestion, erosion, and even bleeding. Long-term drinking may reduce the barrier function of the esophageal mucosa against damage by reflux, thereby aggravating the inflammatory response of reflux esophagitis. Patients may experience more severe symptoms such as acid reflux and heartburn. Therefore, for the sake of your health, please be sure to quit drinking. At the same time, follow the doctor's advice for standardized treatment and maintain a good diet and lifestyle." In an embodiment of the present invention, before calling a preset quick question and answer language model to retrieve answers from a preset vector database according to questions raised by the user, the method further includes: retrieving answers from the memory database according to the questions raised by the user, and filling the retrieved historical question and answer records into a designated position in the first prompt template as part of the final answer; if the quick question and answer language model does not retrieve the historical question and answer records, the designated position in the first prompt template is empty. Further, retrieving answers from the memory database according to questions raised by the user includes: obtaining identification information of the current questioning user, and preferentially retrieving answers from the historical question and answer records of the current questioning user in the memory database according to the identification information; if the answer is not retrieved in the historical question and answer records of the current questioning user, then retrieving answers from the historical question and answer records of other users in the memory database.

[0036] Specifically, the memory is essentially a vector database, which is specially used to store and query the history of user questions and LLM answers. The memory itself has the functions of retrieval and storage. The system calls the retrieval function of the memory to retrieve the answer from the memory database according to the question raised by the user, and then fills the retrieved answer into the prompt template for the fast question and answer language model to input the prompt and output the answer. The implementation process is as follows: User A's question is recorded as "user question", and the historical question and answer records are retrieved in the memory, and the retrieved historical question and answer records are recorded as "text 0". If no relevant historical question and answer records are retrieved, "text 0" is empty. The specific instructions are as follows: 1) User A submits a question: "I went to the hospital and was diagnosed with Barrett's esophagus. What is this disease? What are the symptoms?" 2) The historical question and answer record "text 0" related to user X is retrieved from the memory as follows: "User A asked: 'I am 50 years old and have recently developed symptoms of acid reflux. Can I take omeprazole?' LLM-S replied: 'Omeprazole is an acid-suppressing drug suitable for the treatment of a variety of upper gastrointestinal diseases. It can inhibit gastric acid secretion, reduce gastric acid damage to the mucosa, relieve related symptoms, and promote healing. It is used for peptic ulcers, including gastric ulcers and duodenal ulcers; gastroesophageal reflux disease, including reflux esophagitis and non-erosive reflux disease; combined with antibiotics, it is used to eradicate Helicobacter pylori. It is suitable for gastric acid-related symptoms such as acid reflux, heartburn, upper abdominal pain or discomfort. '" Then, the implementation process of calling the preset fast question-answering language model to retrieve the answer from the vector database according to the question asked by the user is as follows: The fast question-answering agent mainly consists of two parts: LLM-S and vector database. It is used to retrieve answers from the vector database according to the user's questions and organize the retrieved answers in language and return them to the user. Referring to the above specific example, for the question text raised by user A, the specific retrieval implementation also includes the following vector database retrieval process: 1) The fast question-answering agent retrieves relevant content from the vector database. For example, the top-3 similarity results for the article about Barrett’s esophagus are as follows: Text 1: "Barrett's esophagus is caused by repeated gastric acid stimulation and gastroesophageal reflux, which leads to inflammation of the lower esophageal mucosa. On the basis of inflammation, there is mucosal repair, resulting in the replacement of normal esophageal squamous epithelium with mutant columnar epithelium. It is one of the complications of gastroesophageal reflux disease. Most patients will experience symptoms of gastroesophageal reflux disease such as acid reflux, heartburn, dysphagia, and pain behind the sternum, but some patients do not have obvious symptoms." Text 2: "Barrett's esophagus has the possibility of canceration, and after suffering from the disease, a series of symptoms and complications will occur, which will also affect daily work and life. If the treatment is not timely or improper, it may cause serious complications such as esophageal stenosis and esophageal cancer, affecting the patient's quality of life." Text 3: "The key to preventing Barrett's esophagus is a healthy diet, lifestyle, weight loss, avoiding increased abdominal pressure, regular gastroscopy, etc. Specific preventive measures include a healthy diet, lifestyle, avoiding increased abdominal pressure, regular gastroscopy, etc." 2) Construct and fill in the "user question", historical question and answer record "text 0", and vector database search results "text 1", "text 2", and "text 3" into the prompt template to form the final standardized text.

[0037] The modeling of prompt word engineering plays an important role in the development of large model dialogues. A good prompt word template can assist the large model in making more accurate predictions and obtaining more accurate answers. The prompt word template can be modified according to the specific question and answer scenario requirements. In this embodiment, the prompt word template is as follows: "As a professional medical expert in the field of digestion, 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 you encounter insufficient context information, please reply that you are waiting for deep reasoning. For the rigor of the answer, please remind the user at the end that the answer is AI-generated data for reference only, and an accurate answer requires consultation with a digestion expert." 3) LLM-S generates Response: "Barrett's esophagus is caused by repeated gastric acid stimulation and gastroesophageal reflux, which leads to inflammation of the lower esophageal mucosa. On the basis of inflammation, there is mucosal repair, resulting in the replacement of normal esophageal squamous epithelium with mutant columnar epithelium. It is one of the complications of gastroesophageal reflux disease.

[0038] Common symptoms of Barrett's esophagus include acid reflux, heartburn, difficulty swallowing, pain behind the sternum, etc., but some patients do not have obvious symptoms.

[0039] The above information is AI-generated data for reference only. It is recommended that you consult a doctor in the field of digestion to avoid delaying your condition. " 4) In addition, a logical judgment is required as to whether to call the deep reasoning agent. Specifically, if the quick question-answering agent does not retrieve the answer in the vector database, it needs to directly call the deep reasoning agent.

[0040] 5) User A’s question and the final answer generated by LLM-S are stored in the memory as question-answering history records.

[0041] In an embodiment of the present invention, a preset deep reasoning language model is called to call the execution tool related to the reasoning task corresponding to the current question according to the question raised by the user to perform an online answer search, specifically including: performing grammatical and semantic analysis on the question text input by the user to obtain at least one to-be-executed reasoning task corresponding to the question raised by the user; calling the execution tool corresponding to each to-be-executed reasoning task in turn according to the logical relationship of each to-be-executed reasoning task to perform an online answer search. Among them, the execution tools include online search tools, OCR recognition models, and hospital registration and appointment platform interfaces. The hospital registration and appointment platform interface uses the FastAPI framework to build services through interface calls to perform interactive data transmission.

[0042] The deep reasoning agent consists of LLM-L, step design (specifically including the determination of the reasoning task to be executed and the call of the execution tool), and a tool library. These three parts are indispensable.

[0043] The deep reasoning language model LLM-L is a large language model that has been fine-tuned and has stronger language understanding, logical reasoning and other capabilities.

[0044] Step design refers to establishing specific processes such as tool calling, online search, and online reservation according to the reasoning tasks to be executed in the user's instructions. The specific implementation examples of step design can be illustrated through the following different scenarios: Scenario 1: When the user uploads the inspection report, the agent needs to be designed to perform the following steps: 1) The user asks questions about 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 content to answer.

[0045] Scenario 2: When the user makes a real-time information inquiry, the agent needs to be designed to: 1) The user asks whether there is an appointment for a certain specialist in a certain hospital; 2) The user calls the online appointment tool to query relevant information; 3) LLM-L organizes the relevant information and recommends the appointment registration link back to the user; Scenario 3: The user makes a plain text consultation. The steps that the agent needs to be designed to take are: 1) User asks questions; 2) LLM-L answers; Specifically, the tool library includes online search tools, OCR models, and registration appointment interfaces provided by hospitals. When users raise questions, LLM-L can use online search tools to search for relevant information on network resources; when users upload physical examination and inspection photos, the text information is extracted through the OCR model; when users make an appointment, they call the registration appointment interface provided by the hospital to complete the registration function. After calling the corresponding tools, LLM-L will comprehensively analyze the information provided by the tool library to further infer the answer.

[0046] The following are some specific Q&A examples: 1) User B asked: "I have been feeling uncomfortable in my stomach recently and went to the hospital for a check-up. What should I pay attention to in my diet?" 2) LLM-L replied: “Please provide the inspection report image for detailed information.” 3) User B submits the inspection report image.

[0047] 4) Call the OCR model and store the recognized text results in "OCR recognized text", for example, "Orange-red mucosa can be seen in the upper esophagus, and the rest of the esophageal mucosa is smooth and pink, with clear vascular texture and good contraction. A longitudinal mucosal rupture is seen near the cardia at the lower end of the esophagus, with a length of about 6 mm, 40 cm from the incisors to the cardia, and the mucosa is smooth. The cardia is normal. The mucosa near the cardia of the lesser curvature of the upper stomach is slightly rough, and the mucosa of the gastric antrum is not smooth, red and white, with the white phase as the main phase. There is no deformation, congestion, edema or ulcer in the pyloric duodenal bulb cavity. Microscopic diagnosis: reflux esophagitis and chronic atrophic gastritis." 5) Use online search tools to search for popular science articles on reflux esophagitis and atrophic gastritis, such as link-1, link-2, link-3, etc., so as to push relevant knowledge to users.

[0048] 6) Fill in "OCR recognized text" and link-1, link-2, link-3 into the prompt word template to form a complete prompt word "The result of calling the OCR tool is "OCR recognized text", and the relevant popular science articles recommended are link-1, link-2, link-3. You are a senior medical expert in the field of digestion. Please answer the "user question" based on the above information. And for the rigor of the answer, please remind the user at the end that the answer is AI-generated data for reference only." 7) LLM-L generates a Response based on the prompt: "According to your test results, you have reflux esophagitis and chronic atrophic gastritis. For patients with both diseases, you need to pay attention to the following matters in terms of diet: 1. Avoid irritating foods: chili, pepper, mustard and other foods, which irritate the esophageal mucosa and gastric mucosa and aggravate the condition; 2. Avoid cold food: cold drinks, ice cream, raw food, etc., which can easily cause esophageal reflux and stomach discomfort; 3. Avoid greasy food: fried food, fatty meat, etc., which can easily increase the burden on the stomach; 4. Avoid sweet and sour foods: candy, chocolate, hawthorn, lemon, etc., which may stimulate gastric acid secretion and aggravate the symptoms of reflux esophagitis; 5. Protein intake: Eat a moderate amount of lean meat, fish, eggs, beans and other foods rich in high-quality protein; 6. Eat more fresh vegetables and fruits: rich in vitamins, minerals and dietary fiber, which help gastrointestinal motility and digestion.

[0049] In summary, we recommend the following popular science articles link-1, link-2, and link-3. The above information is AI-generated data and is for reference only. It is recommended that you consult a doctor in the field of digestion to avoid delaying your condition. ” 8) Store the question and answer record in the memory.

[0050] In summary, the medical knowledge question-answering method based on a large language model provided by the embodiment of the present invention mainly consists of three parts: a fast question-answering agent, a deep reasoning agent, and a memory. In the question-answering process, the fast question-answering agent is called first, and if no suitable answer is found, the deep reasoning agent will be called. Among them: 1) Fast Q&A Agent: The agent directly asks and answers questions to patients. The large model quickly answers questions based on the answers and Q&A history retrieved from the vector database and memory. The large model of this agent uses an LLM with small volume parameters, referred to as LLM-S. This process is similar to human intuitive response and can quickly respond to patients' basic questions.

[0051] 2) Deep Reasoning Agent: Through multiple rounds of dialogue with patients, online search, tool calls and other steps, multi-step reasoning and planning are carried out. The large model of this agent uses LLM-L with large volume parameters fine-tuned, which has stronger language understanding and logical reasoning capabilities. This agent is similar to the thoughtful and logical thinking mode of humans, and answers patients' complex questions based on various situations. Tool calls include calling Web search tools, OCR (Optical Character Recognition) models, registration appointment interfaces provided by hospitals and other tools.

[0052] 3) Memory: It is essentially a vector database. Both the large models LLM-S and LLM-L of the two agents can interact with the memory and use it to store and query valid historical question and answer records. When the user asks the next time, the large model will take the historical question and answer records in the memory into consideration.

[0053] The medical knowledge question-and-answer method based on a large language model provided by an embodiment of the present invention takes into account the accuracy and response speed of questions and answers in the digestive field through the collaborative work of two intelligent models, wherein the fast question-and-answer language model can quickly answer medical knowledge questions in the digestive field by retrieving a vector database and memory, and the deep reasoning language model searches for answers online by calling execution tools related to the reasoning tasks corresponding to the current questions raised by the user, which can effectively expand the real-time information of the large language model and obtain reasoning and analysis results. Both LLM-S and LLM-L can retrieve and store the user's historical question-and-answer records through memory, and can form personalized health question-and-answer services in the digestive field for the user. The present invention helps to improve the intelligence, accuracy and speed of health consultation and medical knowledge question-and-answer in the field of digestive specialty, and has a high application value for Internet health consultation for the general public.

[0054] In order to ensure the security and privacy of the final reply content generated by the question-and-answer system, the medical knowledge question-and-answer method based on a large language model provided in an embodiment of the present invention also includes a text processing operation of desensitizing and filtering the reply content generated by LLM-S and LLM-L. Specifically, it includes collating the return text of LLM-S and LLM-L, filtering the user information and sensitive information of the Response, and outputting the final result text to the user.

[0055] For the method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0056] Embodiment 2 Another embodiment of the present invention further provides a medical knowledge question and answer system based on a large language model, the system comprising a functional module for implementing the medical knowledge question and answer method based on a large language model as described in any of the above items. Figure 2 The schematic diagram of the structure of a medical knowledge question-answering system based on a large language model provided by an embodiment of the present invention is shown schematically. Figure 2A medical knowledge question-answering system based on a large language model according to an embodiment of the present invention specifically includes an interaction module 201, a fast question-answering agent 202, and a deep reasoning agent 203, wherein: Interaction module 201, used to obtain question text input by the user; The quick question-answering agent 202 is used to call a preset quick question-answering language model to retrieve an answer from a preset vector database according to the question raised by the user. The quick question-answering language model is implemented by a large language model with a small number of parameters. The vector data in the vector database are real vectors formed according to text fragments related to digestive specialist knowledge. If an answer is retrieved, the quick 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 output it to the user. The deep reasoning agent 203 is used to call the preset deep reasoning language model to call the execution tool related to the reasoning task corresponding to the current question according to the question raised by the user to perform an online answer search when the quick question and answer agent calls the preset quick question and answer language model and fails to retrieve the answer, fill the question text and the search result 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, and a preset fine-tuning data set is used to fine-tune the selected large language model with a large number of parameters, so that the large model has the ability to digest knowledge questions and answers.

[0057] In the embodiment of the present invention, the system further includes a fine-tuning data set generation module not shown in the drawings, wherein: The fine-tuning dataset generation module is used to 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, and form the digestive question and answer text pair dataset into a fine-tuning dataset in a specified format, wherein the digestive question and answer text pair includes a digestive question text and a corresponding answer text.

[0058] Furthermore, the system further includes a vector database creation module not shown in the drawings, including a knowledge base slicing submodule and a first text vectorization submodule, wherein: The knowledge base slicing submodule is used to slice the text data in the pre-built digestive specialist knowledge text base to form a text segment dataset suitable for large model processing and keeping the contextual semantic information intact; The first text vectorization submodule is used to convert each text segment in the text segment data set into vector data and store it in a preset vector database.

[0059] Furthermore, the system also includes a knowledge base construction module not shown in the drawings, and the knowledge base construction module is used to pre-construct a digestive specialist knowledge text library.

[0060] In the embodiment of the present 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, which are not shown in the drawings, wherein: A question-and-answer record construction module, used to form a historical question-and-answer record from the question text of each user and 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; The question-and-answer record slicing module is used to slice the historical question-and-answer records into multiple text segments; The second text vectorization module is used to convert the segmented text segments into vector data, and store the obtained vector data into a preset memory database using the user's identification information as an index.

[0061] Furthermore, the system also includes a memory, which is used to retrieve answers from the memory database based on questions raised by the user, and fill the retrieved historical question and answer records into a designated position in the first prompt template as part of the final answer; if the quick question and answer language model does not retrieve the historical question and answer records, the designated position in the first prompt template is empty.

[0062] Furthermore, the memory is specifically used to obtain identification information of the current user asking the question, and based on the identification information, preferentially retrieve the answer from the historical question and answer records of the current user asking the question in the memory database; if the answer is not retrieved in the historical question and answer records of the current user asking the question, retrieve the answer from the historical question and answer records of other users in the memory database.

[0063] In the embodiment of the present invention, the deep reasoning agent 203 is specifically used to perform grammatical and semantic analysis on the question text input by the user to obtain at least one to-be-executed reasoning task corresponding to the question raised by the user; and to sequentially call the execution tool corresponding to each to-be-executed reasoning task according to the logical relationship of each to-be-executed reasoning task to perform online answer search. Among them, the execution tool includes an online search tool, an OCR recognition model, and a hospital registration and appointment platform interface.

[0064] In the specific implementation process of the second embodiment, reference may be made to the first embodiment, which has the corresponding technical effects.

[0065] Embodiment 3 An embodiment of the present 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, the steps in the above-mentioned embodiments of the medical knowledge question-answering method based on a large language model are implemented, for example Figure 1 Alternatively, when the processor executes the computer program, the functions of each module in the above-mentioned medical knowledge question-answering system based on a large language model are implemented, for example Figure 2 The interactive module 201, the quick question-answering agent 202 and the deep reasoning agent 203 are shown.

[0066] In the specific implementation process of the third embodiment, reference can be made to the first embodiment, which has the corresponding technical effects. In addition, those skilled in the art will appreciate that, although some embodiments herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present invention and form different embodiments. For example, any one of the claimed embodiments may be used in any combination.

[0067] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A medical knowledge question-answering method based on a large language model, characterized in that: The method comprises: Get the question text entered by the user; Calling a preset fast question-answering language model to retrieve answers from a preset vector database according to questions raised by the user, wherein the fast question-answering language model is implemented by a large language model with a small number of parameters, and the vector data in the vector database are real number vectors formed according to text fragments 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 output it to the user; If no answer is retrieved, the preset deep reasoning language model is called to call the execution tool related to the reasoning task corresponding to the current question according to the question raised by the user to perform an online answer search, and the question text and 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, and a preset fine-tuning data set is used to fine-tune the selected large language model with a large number of parameters, so that the large model has the ability to digest knowledge questions and answers.

2. The method according to claim 1, characterized in that The method of generating the fine-tuning dataset includes: Key text information is searched from a pre-built digestive specialty knowledge text library, and a digestive question-answer text pair dataset is constructed based on the key text information, and the digestive question-answer text pair dataset is formed into a fine-tuned dataset in a specified format, wherein the digestive question-answer text pair includes a digestive question text and a corresponding answer text.

3. The method according to claim 1, characterized in that The vector database is created in the following manner: Slice the text data in the pre-built digestive knowledge text library to form a text segment dataset suitable for large model processing and with complete contextual semantic information; Each text segment in the text segment data set is converted into vector data and stored in a preset vector database.

4. The method according to claim 1, characterized in that: The method further comprises: The question text of each user and 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 form a historical question and answer record; Slice the historical question and answer records into multiple text segments; The segmented text segments are converted into vector data, and the obtained vector data is stored in a preset memory database using the user's identification information as an index.

5. The method according to claim 4, characterized in that Before calling the preset fast question-answering language model to retrieve answers from a preset vector database according to the question raised by the user, the method further includes: Retrieving answers from the memory database according to the questions raised by the user, and filling the retrieved historical question and answer records into a designated position in the first prompt template as part of the final answer; If the quick question and answer language model does not retrieve any historical question and answer records, the designated position in the first prompt template is empty.

6. The method according to claim 5, characterized in that Retrieving answers from the memory database based on questions asked by the user, including: Obtaining identification information of the user currently asking the question, and preferentially retrieving answers from historical question and answer records of the user currently asking the question in a memory database according to 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.

7. The method according to claim 1, characterized in that Call the preset deep reasoning language model to call the execution tools related to the reasoning task corresponding to the current question according to the question raised by the user to perform online answer search, including: Performing grammatical and semantic analysis on the question text input by the user to obtain at least one to-be-performed reasoning task corresponding to the question raised by the user; According to the logical relationship of each reasoning task to be executed, the execution tool corresponding to each reasoning task to be executed is called in turn to perform online answer search.

8. The method according to claim 7, characterized in that The execution tools include online search tools, OCR recognition models and hospital registration and appointment platform interfaces.

9. A medical knowledge question-answering system based on a large language model, characterized in that: The system comprises: An interactive module, used to obtain question text input by the user; A quick question-answering agent is used to call a preset quick question-answering language model to retrieve an answer from a preset vector database according to a question raised by a user, wherein the quick question-answering language model is implemented by a large language model with a small number of parameters, and the vector data in the vector database are real number vectors formed according to text fragments related to digestive specialist knowledge; if an answer is retrieved, the quick 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 output it to the user; A deep reasoning agent is used to call a preset deep reasoning language model to call an execution tool related to the reasoning task corresponding to the current question according to the question raised by the user to perform an online answer search when the quick question and answer agent calls a preset quick question and answer language model and fails to retrieve an answer. The question text and 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 a preset fine-tuning data set is used to fine-tune the selected large language model with a large number of parameters, so that the large model has the ability to digest knowledge questions and answers.

10. A computer device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor; when the computer program is executed by the processor, the steps of the method according to any one of claims 1 to 8 are implemented.

Citation Information

Patent Citations

  • Method for improving response speed of large-scale language model based on similarity retrieval

    CN116910221A

  • Question and answer method and system based on LangChain and large language model

    CN117313859A

  • Question and answer task processing method, device and equipment and readable storage medium

    CN117520514A

  • Large language model hybrid reasoning method and device, electronic equipment and storage medium

    CN117669731A

  • Human-computer interaction method and device, electronic equipment and storage medium

    CN118098217A

Cited By

  • Alimentary canal tumor non-traumatic evaluation system and method based on artificial intelligence technology

    CN120412986A

  • Pre-pregnancy carrier screening genetic counseling system based on large language model

    CN121034403A

  • Modular medical agent construction method and system

    CN121034646A

  • Question and answer method, device and equipment based on large language model and storage medium

    CN121256003A

  • Medical knowledge question-answering system and method based on multi-agent cooperation mechanism

    CN122153010A