Dynamic user state and real-time knowledge constrained multi-round health conversation method and system
By constructing a medical and health vector knowledge base and a multi-agent collaborative framework, the problems of insufficient knowledge and weak interpretability in existing medical and health large language models are solved, and stronger medical and health dialogue capabilities and controllability of consultation are achieved.
Patent Information
- Application Number
- CN202510170127.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-17
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2045-02-17
AI Technical Summary
Existing medical and health big language models have shortcomings such as insufficient medical and health knowledge, weak interpretability, and weak controllability of consultation, and there is no suitable solution yet.
A medical and health vector knowledge base and a corresponding vector retrieval device are constructed. A medical and health big language model is used to construct an intelligent agent for summarizing historical health status, an intelligent agent for updating user health status, an intelligent agent for deciding system response type, and an intelligent agent for responding to multi-turn health dialogues. Multi-turn health dialogues are realized through a multi-agent collaborative framework.
It enhances the model's multi-turn health dialogue capabilities, improves the model's interpretability and controllability of the consultation process, solves the problem of insufficient medical and health knowledge, and achieves superior medical and health dialogue capabilities.
Smart Images

Figure CN119886359B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of artificial intelligence, in particular to a multi-round health dialogue method and system with dynamic user state and real-time knowledge constraints, and applies to the field of medical interaction. BACKGROUND
[0002] At present, the medical resources are in short supply, and an artificial intelligence method or system capable of assuming the role of "family doctor" is urgently needed to realize various medical and health interaction tasks including but not limited to medical and health knowledge consultation, multi-round medical and health inquiry, etc., so as to solve various medical and health needs of the general public. In recent years, the rise of large language models has brought new hope to the field of artificial intelligence and medical interaction technology. At present, there are mainly the following research directions in the field of artificial intelligence and medical interaction technology: medical and health large language models based on training, medical and health large language models based on agents.
[0003] Among them, the medical and health large language models based on training can be divided into medical and health large language models based on continued pre-training, medical and health large language models based on fine-tuning, medical and health large language models based on reinforcement learning, and medical and health large language models based on hybrid training. These medical and health large language models based on training are usually used to inject medical knowledge, or to align the reply style to the needs of the doctor-patient communication scene. However, these methods are not only criticized for lacking explainability and good inquiry controllability, but also limited by limited data, so although many researchers have paid attention to medical and health knowledge consultation and multi-round medical and health inquiry tasks, there is still no good solution.
[0004] Medical and health large language models based on agents refer to the implementation of medical and health large language models as agents, and flexible application in different medical and health field tasks. This kind of method generally does not need to be trained, and the focus and implementation are complex and diverse. At present, many methods focus on multi-department joint diagnosis, which improves the explainability and comprehensiveness of diagnosis to some extent. However, this method sacrifices the reply speed of the model, and also cannot perform tasks other than diagnosis; a small part of methods pay attention to other medical and health interaction tasks, or doctor assistant tasks, etc.; only a few methods pay attention to medical and health interaction tasks such as inquiry and knowledge consultation.
[0005] In summary, the current medical and health large language models have the shortcomings of insufficient medical and health knowledge, weak explainability, weak inquiry controllability, etc., and there is still no suitable solution. SUMMARY
[0006] The present application aims to provide a multi-round health dialogue method and system with dynamic user state and real-time knowledge constraints to solve the problems existing in the prior art.
[0007] The dynamic user state and real-time knowledge constraint multi-round health conversation method comprises the following steps:
[0008] S1. Construct a medical health vector knowledge base and a corresponding vector retriever;
[0009] S2. Based on distributed storage and SSL / TLS encryption, use cloud database technology to build a user health archive;
[0010] S3. Use a medical health large language model to build a historical health state summary agent, a user health state update agent, a system reply type decision agent, and a multi-round health conversation reply agent;
[0011] S4. Build a multi-agent collaborative framework to realize multi-round health conversation.
[0012] The dynamic user state and real-time knowledge constraint multi-round health conversation system uses the method to complete the multi-round health conversation task.
[0013] The dynamic user state and real-time knowledge constraint multi-round health conversation method and system has the advantages that a multi-agent collaborative framework based on dynamic user health state and real-time knowledge constraint is built by using a medical health large language model to simulate the behavior mode of a doctor during an inquiry, further improve the multi-round health conversation ability of the model, enhance the explainability and inquiry controllability, and supplement the lacking medical health knowledge. BRIEF DESCRIPTION OF DRAWINGS
[0014] Figure 1 is a flowchart of the multi-round health conversation method.
[0015] Figure 2 is a structural diagram of the historical health state summary agent.
[0016] Figure 3 is a structural diagram of the user health state update agent.
[0017] Figure 4 is a structural diagram of the system reply type decision agent.
[0018] Figure 5 is a structural diagram of the multi-round health conversation reply agent. DETAILED DESCRIPTION
[0019] As Figures 1 to 5 shown, the dynamic user state and real-time knowledge constraint multi-round health conversation method comprises the following steps:
[0020] S1. Constructing a medical health vector knowledge base and a corresponding vector retriever.
[0021] Including the following sub-steps:
[0022] S11. Collecting several drug instruction documents and several disease introduction documents in the medical field, and dividing all the collected documents into several text blocks according to subheadings.
[0023] Each drug instruction document contains the shape, pharmacology and toxicology, indications, usage and dosage, adverse reactions, contraindications, interactions, specifications, precautions, etc. of the drug, and each disease introduction document contains the department, disease definition, cause, symptoms, diagnosis, drug treatment, daily care, etc.
[0024] S12. Using a dense vector retrieval tool library and a text embedding model to construct all the text blocks into a searchable medical health vector knowledge base. The dense vector retrieval tool library is FAISS.
[0025] The text embedding model is trained by a neural network and has the feature of encoding text blocks of any length into fixed-dimensional embedding vectors.
[0026] S13. Using the text embedding model and the similarity retrieval function in the dense vector retrieval tool library to construct a vector retriever.
[0027] The vector retriever has an input x query and an output y kn . The input x query is a query text input, which belongs to the text type. The output y kn is the retrieved relevant knowledge, which also belongs to the text type.
[0028] The input-output relationship of the vector retriever Retriever is:
[0029] y kn = Retriever(x query ) = Cvt tl2t (SimSearch(Embedding(x query ), 10));
[0030] Where Embedding(·) is a text embedding model, Retriever(·) is a vector retriever, and SimSearch(·) is a similarity retrieval function. The SimSearch function receives two inputs, query vector and top-k, and returns the top-k text blocks most similar to the query vector in the form of a list. Cvt tl2t (·) is a conversion function that converts a text list into a specified format text.
[0031] S2. Use cloud database technology to build a user health record database, and ensure patient information security through distributed storage and SSL / TLS encryption technology.
[0032] In the user health profile database, each user's health profile is stored separately as a JSON object and indexed using a unique user identifier. This unique identifier is a string of several digits generated using a classic auto-incrementing ID method. It is automatically generated and distributed based on internal parameters upon successful user registration, and once generated, it is uniquely bound to that user and cannot be modified subsequently.
[0033] The user's health record contains two key-value pairs: basic user information and the user's complete health history data. The basic user information includes three key-value pairs: the user's name, date of birth, and gender. These three key-value pairs are filled in by the user during registration and are stored as strings. The user's complete health history data contains several key-value pairs, each with a date as the key and the user's health status on that date as the value. The user's health status on that date consists of five key-value pairs: chief complaint, present illness, past medical history, personal history, and family history.
[0034] S3. Utilize the medical and health big language model to construct four intelligent agents: a historical health status summary intelligent agent, a user health status update intelligent agent, a system response type decision intelligent agent, and a multi-turn health dialogue response intelligent agent.
[0035] Includes the following sub-steps:
[0036] S31. Construct an intelligent agent to summarize historical health status.
[0037] The historical health status summary agent SumAgent(·) is as follows: Figure 2 As shown, there is an input x sum An output y sum Output y sum It's a summary of historical health status, a JSON object containing five key-value pairs: chief complaint, present illness, past medical history, personal history, and family history. Input x sum It is the user's complete historical health status data, which corresponds to the user's complete historical health status data in step S2.
[0038] The input-output relationship of the historical health status summary agent SumAgent(·) is as follows:
[0039] y sum =SumAgent(x sum ) = Std hs(MedLLM([Sys sum ;Cvt sum2t (x sum Usr sum ]));
[0040] Among them, MedLLM(·) is a large language model for healthcare, characterized by returning text-type outputs given a text-type input. sum This is the system prompt for the historical health status summary agent, containing three parts: a description of the historical health status summary task, an explanation of the meaning of each part of the health status, and a few examples of the historical health status summary task. Usr sum This refers to the user prompts for the historical health status summary agent, specifically the generation format requirements for the historical health status summary task. [Sys sum ;Cvt sum2t (x sum Usr sum [] indicates concatenating three parts of text. Std hs (·) is the health status normalization function, which normalizes and transforms the content generated by MedLLM into a state similar to y. sum Same format. Cvt sum2t (·) is related to x sum A conversion function that converts JSON objects with the same structure into unformatted text.
[0041] S32. Construct an intelligent agent for updating user health status.
[0042] The user health status update agent UpdAgent(·) is as follows: Figure 3 As shown, there are three inputs. and One output y upd Output y upd This is the user's latest health status, a JSON object containing five key-value pairs: chief complaint, present illness, past medical history, personal history, and family history. Input It represents the user's health status for the day, and is also a JSON object, and is related to the output y. upd They have the same key-value pair structure. Input This is a list of conversation history elements, which are a series of JSON object elements. Each element contains a key-value pair of "role" and "content". Input This is the current user input, which is a text type.
[0043] The input-output relationship of the user health status update agent UpdAgent(·) is as follows:
[0044]
[0045] wherein, Sys upd is the system prompt word of the user health status update agent, which contains three parts: the description of the user health status update task, the explanation of the meanings of each part of the health status, and a small number of examples of the user health status update task. Usr upd is the user prompt word of the user health status update agent, which specifically refers to the generation format requirement of the user health status update task. represents the splicing of five parts of text. Cvt hs2t (·) is a conversion function for converting a JSON object with the same structure as to a format-free text. Cvt ch2t (·) is a conversion function for converting a JSON object with the same structure as to a format-free text.
[0046] S33. Construct a system reply type decision-making agent.
[0047] The system reply type decision-making agent DcsAgent(·) as shown in Figure 4 has four inputs and an output y dcs . The output y dcs is the system reply type, which belongs to the text type and is one of the 17 reply types. The 17 reply types are: “explain”, “ask”, “diagnose”, “suggest”, “explain and ask”, “ask and explain”, “diagnose and explain”, “explain and diagnose”, “suggest and explain”, “explain and suggest”, “diagnose and ask”, “ask and diagnose”, “suggest and ask”, “ask and suggest”, “diagnose and suggest”, “suggest and diagnose”, and “courtesy reply”. The input is a series of relevant knowledge retrieved, which belongs to the text type. The input is the latest user health status, which is a JSON object and has the same key-value pair structure as the input . The input is a list of dialogue history, which has the same structure as the input . The input is the current user input, which belongs to the text type.
[0048] The relationship of the input and output of the system reply type decision-making agent DcsAgent(·) is:
[0049]
[0050] wherein, Sys dcsUsr dcs is the system prompt word of the system reply type decision agent, which contains three parts: the description of the system reply type decision task, the explanation of the meaning of each reply type, and a small number of examples of the system reply type decision task. Cvt hs2t The (·) function and Cvt ch2t The (·) function and the two functions with the same name in sub-step S32 are exactly the same.
[0051] S34. Construct a multi-round health dialogue reply agent.
[0052] The multi-round health dialogue reply agent ResAgent(·) as shown in Figure 5 has five inputs and one output y res . The output y res is the final system reply, which is of text type. The input is the system reply type, which is of text type and has the same features as the output y dcs . The input is a series of relevant knowledge retrieved, which is of text type. The input is the latest user health status, which is a JSON object and has the same key-value pair structure as the input . The input is a list of dialogue history, which has the same structure as the input . The input is the current user input, which is of text type.
[0053] The relationship between the input and output of the multi-round health dialogue reply agent ResAgent is:
[0054]
[0055] where Sys res (·) is the system prompt word function of the multi-round health dialogue reply agent, which selects and obtains the system prompt word of the specified reply type from the system prompt word pool with as the condition. The system prompt word pool has 17 different system prompt words, corresponding to 17 different reply types, and each system prompt word contains two parts: the description of the multi-round health dialogue reply task of the specified reply type and a small number of examples of the multi-round health dialogue reply task of the specified reply type. Usr resIt is a user prompt word of a multi-turn health dialogue reply intelligent agent, in particular to the generation format requirement of a multi-turn health dialogue reply task.
[0056] It indicates that six parts of text are spliced. Cvt hs2t (·) functions and Cvt ch2t (·) functions are exactly the same as the two functions with the same name in sub-step S32.
[0057] S4. Build a multi-agent collaborative framework to realize multi-turn health dialogue.
[0058] It includes the following sub-steps:
[0059] S41. According to the current date and the unique identification code of the current user, search the user health archive database to see if there is a user health status of the current user on the current date, if there is, assign it to the historical user health status, if not, use the historical health status summary intelligent agent to summarize the user's full historical health status data of the current user in the user health archive database, generate a historical health status summary, and upload it to the user health archive database as the user's health status on the current date. Specifically, a key-value pair is created in the current user's full historical health status data, with the current date as the key and the historical health status summary as the value, and then assigned to the historical user health status.
[0060] S42. Use the user health status update intelligent agent to generate the latest user health status with the dialogue history list, current user input, and historical user health status as input.
[0061] S43. Use the function Cvt hs2t (·) to convert the latest user health status into unformatted text, and use the vector retriever to input the obtained unformatted text as query text to query and obtain a series of related knowledge.
[0062] S44. Use the system reply type decision intelligent agent to generate the system reply type with the obtained series of related knowledge, the latest user health status, the dialogue history list, and the current user input as input.
[0063] S45. Use the multi-turn health dialogue reply intelligent agent to generate the final system reply with the obtained system reply type, series of related knowledge, latest user health status, dialogue history list, and current user input as input.
[0064] S46. When the user continues the dialogue, repeat sub-steps S41 to S45 to realize multi-turn health dialogue.
[0065] The dynamic user state and real-time knowledge constraint multi-round health dialogue system described in the application completes the multi-round health dialogue task by using the method.
[0066] The technical scheme provided by the application not only supplements the knowledge deficiency problem of the current medical health big model, but also improves the explainability and controllability of the model. Specifically, it can actively ask questions at the right time and obtain relevant information based on the user's health status. It also shows that the timing of the inquiry is explainable, and the content of the inquiry is explainable. In addition, the application also builds a user health archive, which avoids exceeding the context length limit, and solves the problem that the current medical dialogue method is prone to errors or omissions in remembering the user's health status under long context or cross-date conditions. It can obtain stronger ability to understand and remember the user's health status and more superior multi-round dialogue ability.
[0067] For those skilled in the art, various corresponding changes and modifications can be made to the above-described technical solutions and concepts, and all such changes and modifications should be within the scope of protection of the claims of the application.
Claims
1. A multi-turn health dialogue method based on dynamic user status and real-time knowledge constraints, characterized in that, Includes the following steps: S1. Construct a medical and health vector knowledge base and a corresponding vector retrieval tool; S2. Based on distributed storage and SSL / TLS encryption, a user health record database is built using cloud database technology; S3. Utilize the medical and health big language model to construct an intelligent agent for summarizing historical health status, an intelligent agent for updating user health status, an intelligent agent for deciding system response type, and an intelligent agent for responding to multi-round health dialogues; S4. Construct a multi-agent collaborative framework to achieve multi-round health dialogue; Step S1 includes the following sub-steps: S11. Collect several drug instruction manuals and several disease description documents, and divide all the collected documents into several text blocks according to subheadings; S12. Utilize a dense vector retrieval toolkit and a text embedding model to construct a searchable medical and health vector knowledge base from all text blocks; The text embedding model is trained by a neural network and is used to encode text blocks of arbitrary length into fixed-dimensional embedding vectors. S13. Construct a vector retrieval tool using the text embedding model and the similarity retrieval function in the dense vector retrieval tool library; the vector retrieval tool has an input x. query An output y kn Input x query The input is a text query, which is of text type; the output is y. kn The retrieved relevant knowledge also belongs to the text type; y kn =Retriever(x query )=Cvt tl2t (SimSearch(Embedding(x query ),10)); Here, Embedding(·) is the text embedding model, Retriever(·) is the vector retrieval function, and SimSearch(·) is the similarity retrieval function; the SimSearch function takes a query vector and top-k as inputs, and returns the top-k text blocks most similar to the query vector in list form; Cvt tl2t (·) is a conversion function that converts a list of text into text of a specified format; In sub-step S11, the drug instruction manual document includes the drug's shape, pharmacology and toxicology, indications, dosage and administration, adverse reactions, contraindications, interactions, specifications, and precautions; the disease introduction document includes the relevant department, disease definition, etiology, symptoms, diagnosis, drug treatment, and daily care; the dense vector retrieval tool library is FAISS; In step S2, each user's health profile in the user health profile database is stored separately as a JSON object and indexed using a unique user identifier. The unique user identifier is a string of numbers with several digits, generated using the classic table ID auto-incrementing method. When a user successfully registers, the unique identifier is automatically generated based on internal parameters and distributed and bound. The user health record contains two key-value pairs: basic user information and the user's full historical health status data. The basic user information contains three key-value pairs: the user's name, date of birth, and gender. The user's full historical health status data contains several key-value pairs, each with a date as the key and the user's health status on the corresponding date as the value. The user's health status on the corresponding date consists of five key-value pairs: chief complaint, present illness, past medical history, personal history, and family history. In step S3, the historical health status summary agent is represented as SumAgent(·); it has an input x sum An output y sum Output y sum It is a summary of historical health status, including five key-value pairs: chief complaint, present illness, past medical history, personal history, and family history; input x sum It refers to the user's full historical health status data mentioned in step S2; The input and output satisfy the following relationship: y sum N SumAgent ( x sum )mStd hs (MedLLM([Sys sum Cvt sum2t (x sum )Usr sum ])) Among them, MedLLM(·) is a large language model for healthcare, characterized by returning text-type outputs given text-type input; Sys sum It is a system prompt word for the agent summarizing historical health status; Usr sum It is a user prompt word for the intelligent agent summarizing historical health status; [Sys sum ;Cvt sum2t (x sum Usr sum [] indicates concatenating three parts of text; Std hs (·) is the health status normalization function, which normalizes and transforms the content generated by MedLLM(·) into a state similar to y. sum Same format; Cvt sum2t (·) is related to x sum A function to convert JSON objects with the same structure into unformatted text; In step S3, the user health status update agent is represented as UpdAgent(·); it has three inputs. and One output y upd Output y upd This is the latest user health status; enter... It represents the user's health status for the day, and the output y upd Having the same key-value pair structure; input This is the chat history list; enter... This is the current user input, and it is a text type. The input and output satisfy the following relationship: Among them, Sys upd It is a system prompt word for the AI agent to update the user's health status; Usr upd It is a user prompt word from the intelligent agent that updates the user's health status; This indicates concatenating five parts of text; Cvt hs2t (·) is to be with A conversion function that converts JSON objects with the same structure into unformatted text; Cvt ch2t (·) is to be with A function to convert JSON objects with the same structure into unformatted text; In step S3, the system response type decision agent is represented as DcsAgent(·); it has four inputs. and One output y dcs Output y dcs This is a system reply type, belonging to the text type; input The retrieved relevant knowledge is text-based; input... It is the latest user health status, which is a JSON object, and is related to the input. Having the same key-value pair structure; input It is a list of conversation history, related to the input. They have the same structure; input This is the current user input, and it is a text type. The input and output satisfy the following relationship: Among them, Sys dcs It is a system prompt word for the system response type decision agent; Use dcs These are user prompts for the system's response type decision-making intelligent agent; This indicates that the six parts of text will be concatenated; In step S3, the multi-turn health dialogue response agent is represented as ResAgent(·); it has five inputs. and One output y res Output y res This is the final system reply, and it is a text type; input It is a system response type, belonging to the text type, and is related to the output y. dcs They have the same characteristics; input x reskn The retrieved relevant knowledge is text-based; input... It is the latest user health status, a JSON object, and is consistent with the input. Having the same key-value pair structure; input It is a list of conversation history, related to the input. They have the same structure; input This is the current user input, and it is a text type. The input and output satisfy the following relationship: Among them, Sys res (·) is the system prompt word function for a multi-turn health dialogue response agent; User res These are user prompts for the AI agent in multi-turn health dialogue responses; This indicates that the six parts of the text will be concatenated.
2. The multi-turn health dialogue method based on dynamic user state and real-time knowledge constraints according to claim 1, characterized in that, Step S4 includes the following sub-steps: S41. Based on the current date and the current user's unique identifier, search the user health archive for the current user's health status for the current date. If it exists, assign it to the historical user health status. If it does not exist, use the historical health status summary agent to summarize the current user's full historical health status data in the user health archive, generate a historical health status summary, and upload it to the user health archive as the current user's health status for the current date. S42. Update the agent using the user's health status, taking the dialogue history list, current user input, and historical user health status as input, to generate the latest user health status; S43. Convert the latest user health status into unformatted text, and use a vector search engine to perform a query with the obtained unformatted text as the query text input to obtain relevant knowledge; S44. Utilize the system response type decision-making agent, taking the obtained relevant knowledge, the latest user health status, the dialogue history list, and the current user input as input, to generate the system response type; S45. Utilize a multi-turn health dialogue response agent, taking the obtained system response type, relevant knowledge, latest user health status, dialogue history list, and current user input as input, to generate the final system response; S46. While the user continues the conversation, repeat sub-steps S41 to S45 to achieve a multi-round healthy conversation.
3. A multi-turn health dialogue system with dynamic user status and real-time knowledge constraints, characterized in that: The multi-turn health dialogue task is completed using the multi-turn health dialogue method as described in any one of claims 1-2.
Citation Information
Patent Citations
Chinese multi-round dialogue medical system and device based on Prompt language model and storage medium
CN117577305A
Government affair intelligent response device and method based on intention recognition and large language model
CN118035419A