Elderly disease health question and answer method based on multi-agent and knowledge graph
Through multi-agent architecture and knowledge graph technology, combined with the large language model Geriatrics-MedLLM, the problems of insufficient context dependence and high hallucination risks in elderly disease diagnosis are solved, and an efficient and interpretable medical consultation system is realized, suitable for telehealth management and medical resource optimization of elderly patients.
Patent Information
- Application Number
- CN202510687021.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-27
- Publication Date
- 2025-08-26
AI Technical Summary
The prior art has problems such as insufficient multi-round dialogue context dependence, high risk of hallucination and poor interpretability in professional scenarios in elderly disease consultation, leading to the risk of misdiagnosis and misleading of information.
Multi-agent architecture and knowledge graph technology are used to acquire structured data through crawlers to build a multi-modal knowledge graph, combined with the large language model Geriatrics-MedLLM, to realize transparent medical decision-making and dynamic summary management, and dynamic routing to the knowledge graph or large model for decision-making.
It improves the coherence and accuracy of multiple rounds of dialogue, reduces hallucination risks, enhances the interpretability and professional credibility of decisions, reduces the risk of misdiagnosis, and is suitable for medical resource optimization and telehealth management.
Smart Images

Figure CN120542573A_ABST
Abstract
Description
Technical Field
[0001] This invention lies at the intersection of artificial intelligence and medical information technology, specifically relating to a medical consultation system for geriatric diseases based on a multi-agent architecture, a knowledge graph, and a large language model. Through multi-agent collaborative decision-making, dynamic knowledge graph reasoning, and pre-trained and fine-tuned large language models in the medical field, this system implements an interpretable intelligent consultation service for geriatric diseases. It provides preliminary symptom analysis, health advice, and medical decision-making support for elderly patients and primary care institutions. The system is suitable for optimizing medical resources, remote health management, and improving the efficiency of doctor-patient communication. Background Art
[0002] As the global aging population accelerates, the number and proportion of elderly people continues to rise. The quality of online medical information varies widely, making it difficult for non-professionals to distinguish authenticity, which can easily lead to misdiagnosis and anxiety. In this context, there is an urgent need for efficient, reliable, and accessible intelligent consultation tools to provide elderly patients with timely health consultation and disease management advice.
[0003] In recent years, artificial intelligence (AI) has provided innovative solutions for the medical field. Knowledge graphs, through their "entity-relationship-entity" triple structure, can accurately represent the complex relationships between diseases, symptoms, and medications, supporting medical reasoning tasks. For example, Google Health leverages knowledge graphs to build a diagnosis and treatment assistance system covering over 100,000 disease relationships. Large language models (LLMs), leveraging semantic understanding acquired through training on massive amounts of text, significantly improve the fluency of natural language interactions. However, existing technologies still have significant limitations: Traditional knowledge graph question answering (KGQA) systems are often limited to single-turn, independent questions and cannot handle the contextual dependencies of multi-turn conversations. General-purpose large language models are prone to "hallucinatory" responses in specialized medical scenarios and lack interpretability. Studies have shown that LLMs not optimized for the medical field have an error rate as high as 32% in question answering on geriatric diseases, severely limiting their clinical application value.
[0004] To address these challenges, this design implements an intelligent medical consultation system based on a multi-agent architecture and knowledge graph technology. Using an agent framework, the system distributes medical decision-making across multiple agents. Each agent focuses on a specific type of question and gradually seeks the optimal solution through clear decision-making and execution strategies, making the questions and answers highly interpretable and transparent. By pre-training and fine-tuning a large model using LoRa, a large-scale model for geriatric disease question answering, Geriatrics-MedLLM, was proposed. Furthermore, a summary buffer memory module systematically summarizes key content after each round of dialogue, enabling the system to dynamically adjust and optimize the conversation content to ensure consistency and accuracy. At the societal level, this system can alleviate the shortage of medical resources in remote areas, reduce the average annual cost of medical care for elderly patients, and mitigate the impact of misleading online information through standardized responses, providing technical support for intelligent health management. Summary of the Invention
[0005] The technical problems solved by this invention are: improving the contextual coherence and reasoning accuracy of complex medical conversations, enhancing the interpretability and professional credibility of the system's decision-making process, reducing the risk of hallucinations in large language models in the field of geriatric diseases, and achieving efficient dynamic matching of clinical knowledge and user needs.
[0006] The technical solution of the present invention is as follows: The present invention proposes a medical consultation system for elderly diseases based on the fusion of a multi-agent architecture, a knowledge graph and a large language model. This method first obtains structured data on elderly diseases (including disease descriptions, drugs, complications, etc.) from an authoritative medical platform through crawler technology to construct a multimodal knowledge graph; performs two-stage training based on the Qwen2-1.5B base model, and uses LoRA low-rank adaptive technology for supervised fine-tuning to generate a domain-specific model Geriatrics-MedLLM; designs a multi-agent collaboration mechanism to dynamically route to a knowledge graph agent (knowledge graph retrieval), a complex reasoning agent (large model generation) or a general agent (plug-in knowledge base query) based on the entity confidence threshold to achieve transparent medical decision-making; manages multi-round dialogue contexts through a dynamic summary compression algorithm to construct an intelligent consultation model with high interpretability and low hallucination probability. The specific steps are as follows:
[0007] Step 1: Obtain structured data and unstructured text on geriatric diseases through a medical vertical website crawling system. After standardization, the structured data is used to establish a disease association network. The unstructured text is analyzed using a semantic parsing module to extract question-answer pairs and disease entities.
[0008] Step 2: A two-stage large language model training architecture is used. In the pre-training stage, domain knowledge transfer is achieved by injecting medical domain text. In the fine-tuning stage, low-rank adaptive technology is used to optimize model parameters to build a geriatric language model.
[0009] Step 3: Build a multimodal knowledge storage system, implement topological storage of disease knowledge networks through graph databases, combine with vector databases to implement semantic retrieval of diagnosis and treatment guidelines, and use dynamic window segmentation strategies to process long texts;
[0010] Step 4: Deploy an intelligent collaborative decision-making system to dynamically activate the knowledge graph query agent, literature retrieval agent, or generative dialogue agent based on input semantic features to achieve multimodal medical knowledge fusion response;
[0011] Step 5: Build a conversation history management mechanism to generate summaries through a large language model and independently store the original conversation records.
[0012] The specific technical links are:
[0013] Knowledge storage and retrieval layer: Construct a multimodal knowledge graph (based on Neo4j) that includes the relationships between diseases, symptoms, drugs, and complications, and use a graph traversal algorithm to mine symptom association paths; an external vectorized knowledge base (Chroma) stores unstructured diagnosis and treatment guidelines, and a hybrid retrieval strategy is used to achieve the joint recall of semantic and structured data.
[0014] Model computing layer: Using Qwen2-1.5B as the base model, a domain-specific model Geriatrics-MedLLM is generated through two-stage training (pre-training + supervised fine-tuning). LoRA low-rank adaptive technology is used to reduce the number of fine-tuning parameters and solve the hallucination problem of general large models.
[0015] Dynamic decision-making layer: Design a multi-agent collaborative mechanism to dynamically select knowledge graph agents (graph database retrieval), complex reasoning agents (large model generation) or knowledge base agents (additional knowledge base query) based on entity confidence to achieve transparent reasoning of the consultation path.
[0016] Furthermore, the process of step 1 is as follows:
[0017] Step 1: Data collection and storage:
[0018] The present invention constructs a knowledge base for elderly health management through multi-source heterogeneous data fusion technology. The specific data collection and storage methods are as follows: Based on crawling, it directionally captures the disease diagnosis and treatment specifications on Dingxiang Doctor Network (http: / / www.dxy.com) and the doctor-patient conversation records on Xunyiwenyao Network (http: / / www.xywy.com) in the past five years. Among them, the structured data (including 9 types of medical entities such as disease-symptom association tables and drug contraindication relationships and 12 types of relationship chains) is stored in a standardized CSV format, and each piece of data contains entity types and attribute fields; for the unstructured data, first, privacy data desensitization is performed through regular expression matching, and then a content structuring method combining rules and deep learning is adopted. For the health consultation dialogue text, the question-and-answer pairs are extracted using the <question>.*?< / question><answer>.*?< / answer> tag pattern and encapsulated into a JSON object (including semantic role annotation); for the long text of medical encyclopedias, entities such as diseases and symptoms are recognized through named entity recognition, and knowledge entry JSONs are generated (see the example in the following table), forming a structured corpus that can be directly used for large model training.
[0019] Among them, examples of each data node are shown in Table 1, and examples of node relationships are shown in Table 2.
[0020] Table 1 Structured Data Nodes
[0021]
[0022] Table 2 Node Relationship Data Nodes
[0023]
[0024] Table 3 Unstructured Data Knowledge Entries
[0025]
[0026] Step 2: Model pre-training and fine-tuning, specifically including:
[0027] Step 2.1: Model pre-training stage
[0028] Based on the Qwen2-1.5B base model, inject the previously constructed knowledge base for elderly diseases (including 27,000 pieces of structured medical description texts), and perform domain adaptation training using the full parameter update strategy. By setting the gradient accumulation step to 4, accelerating the calculation with BF16 mixed precision, setting the batch size per device to 8, and the equivalent global batch size to 32, use the DeepSpeedZeRO-2 video memory optimization strategy to reduce GPU memory occupancy. The learning rate scheduling strictly follows the cosine decay rule, setting the initial learning rate to 0.0001 and the total training cycle to 3. Its mathematical expression is:
[0029]
[0030] The maximum learning rate , total training cycle , save the model checkpoint every 500 steps and draw the loss curve in real time to monitor the convergence status.
[0031] Step 2.2: LoRA fine-tuning stage
[0032] Based on the pre-trained model, we loaded the general instruction dataset and medical-specific data (a total of 10 million samples) and used low-rank adaptive technology to efficiently fine-tune the parameters. The core formula is:
[0033]
[0034] The rank factorization dimension r was set to 8, the scaling factor α was set to 16, the dropout rate p was set to 0.05, and adapters were injected into all linear layers. Dynamic sequence packing was disabled during training to preserve the characteristics of the medical question-answering format. The Flash Attention 2.0 mechanism (flash_attn=auto) was used. This mechanism reduces the attention layer's memory usage by 70% through block computation and recomputation strategies, achieving a 13.5x speedup for sequence lengths of 2048, thus supporting the processing of medical text with longer contexts.
[0035] Block calculation: Split the Q, K, V matrices into blocks (block_size=64 / 128) and implement it through loop unrolling:
[0036]
[0037] in, Represents block index to avoid one-time storage matrix
[0038] Recalculation: Do not save intermediate matrices during forward propagation and , change the video memory usage from down to
[0039] The maximum sequence length L was set to 2048 to ensure the integrity of long text pathology descriptions, and ultimately a throughput of 18,000 samples per hour was achieved on an 8-card A100 cluster, generating a Geriatrics-MedLLM model with domain expertise.
[0040] Step 3: Knowledge system establishment
[0041] A triple knowledge network was constructed based on the Neo4j graph database. The "entity-relationship-entity" model was used to define node attributes and edge weights, and a full-text search index was established for the symptom description field.
[0042] The automated construction of the external medical knowledge base is achieved through a modular data processing process. The specific method is as follows:
[0043] First, a multi-format document parser was configured. CSVLoader was used to extract tabular data from CSV files, PyMuPDFLoader was used to extract text and graphics from PDF documents, and TextLoader was used to directly read TXT text. A recursive character text segmenter was uniformly used for semantic coherence processing. A sliding window strategy with a text block length of 300 characters and a 50-character overlap between adjacent blocks was set to ensure the integrity of key medical descriptions (such as medication dosage instructions and symptom description paragraphs). The loaded document collection was mapped into a high-dimensional vector, and finally, the Chroma vector database was used for batch vectorized storage, forming a structured knowledge base that supports similarity retrieval. This technical solution supports the unified encoding of multimodal medical data through a standardized interface, enabling subsequent consultation systems to quickly match relevant case knowledge through cosine similarity calculations (the specific formula is as follows), providing real-time knowledge enhancement for diagnostic recommendation generation.
[0044]
[0045] Among them, A and B are the vector representations of two text fragments in the knowledge base, the numerator is the vector dot product, and the denominator is the product of the two vector moduli (for normalization).
[0046] Step 4: Agent creation
[0047] Accurate decision-making for medical question answering is achieved through a modular agent-based architecture. The specific construction method is as follows:
[0048] A multi-tool collaborative agent system was developed based on the LangChain framework. During initialization, the Chroma vector database was loaded and associated with a pre-trained text embedding model. When a user enters a medical consultation question, the system executes the following core processing steps:
[0049] (1) Tool dynamic routing mechanism
[0050] The system has three built-in functional tools:
[0051] a. Knowledge Retrieval Tool (Retrival_Func): Calculates the cosine similarity between the input question and the vector library, selects the top-5 medical document fragments with a similarity greater than 0.7, and generates diagnostic suggestions using the prompt word template RETRIVAL_PROMPT_TPL.
[0052] b. Knowledge Graph Tool (Graph_Func): Uses a structured output parser to identify entities such as diseases, symptoms, and medications, constructs a Cypher query statement (for example: MATCH (d:Disease)-[:HAS_SYMPTOM]->(s) WHEREs.name IN ['headache'] RETURN d.treatment), searches the Neo4j knowledge graph, and uses the FAISS vector library to select the three most relevant medical question templates.
[0053] c. Large Language Model Tool (GeriatricMedLLM-Func): When named entity recognition resolves to an empty list of entities such as diseases, symptoms, and drugs, and the document similarity scores returned by the knowledge retrieval tool are all ≤0.7, and the question involves non-diagnostic content such as health advice and psychological counseling, and the question contains phrases such as "how to prevent" and "how to regulate" that require complex generative reasoning, the system automatically routes to the complex question-answering tool to call GeriatricsMedLLM to generate a response. When complex question-answering is triggered, the domain knowledge prefix is automatically injected.
[0054] (2) Tool selection and implementation
[0055] a. Tool description concatenation: Tool descriptions (e.g., "Graph_Func: used to answer medical questions about diseases, symptoms, medications, etc.") are concatenated into prompts and fed into the large language model. The model output then selects the most suitable tool. This is implemented using LLMChain chain processing, where the output matches the tool name using a regular expression to activate the corresponding tool function.
[0056] b. Intelligent tool selection for the medical question-answering system is achieved through structured tool description concatenation and dynamic routing. The specific implementation steps are as follows: First, the names and functional descriptions of three predefined tools (Retrival_Func, Graph_Func, and GeriatricMedLLM-Func) are concatenated into a tool knowledge base according to a fixed format. GeriatricMedLLM-Func is used to generate general answers when simple medical information is missing, Retrival_Func is responsible for searching the medical knowledge base, and Graph_Func handles the association of medical entities such as disease symptoms and medications. This concatenation process is achieved by traversing the tool list and formatting the string. The resulting standard tool description text serves as the system's knowledge base.
[0057] c. Upon receiving a user query, the system automatically injects the tool description text and the user's question into the preset PARSE_TOOLS_PROMPT_TPL prompt template. This template contains strict output formatting instructions, requiring the large language model to return only the tool name without any additional explanation. After LLMChain chain processing, the model output is then used to extract the tool identifier through string matching, ultimately activating the corresponding tool execution module. Regular expressions are used throughout the entire process to ensure reliable output parsing. Medical specialty questions are preferentially routed to the Graph_Func and GeriatricMedLLM-Func processing strategies.
[0058] The prompt word template is designed as follows:
[0059] Table 4 Tool description text + user question co-injection prompt word template design
[0060]
[0061] Step 5: Build a conversation history management mechanism
[0062] In a multi-agent-based medical consultation system for elderly diseases, the historical question-and-answer information mechanism is a key module for ensuring the coherence of multi-round conversations and improving contextual understanding. This mechanism dynamically compresses, stores, and retrieves historical conversation information, enabling the system to maintain accurate medical reasoning during long conversations.
[0063] (1) Dynamic capture of conversation history
[0064] Monitor the number of interactions between users and the system in real time. When the cumulative number of conversation rounds exceeds a preset threshold (e.g., 5 rounds), the content of the most recent N rounds (N ≥ 1) of conversations will be automatically retained, effectively controlling the complexity of context processing.
[0065] (2) Structured text reorganization
[0066] The intercepted conversation records are converted into a standardized text format and semantically aligned using the question:{user input}, answer:{system response} template to generate continuous and parseable conversation text blocks.
[0067] (3) Abstract generation
[0068] Based on the predefined medical field prompt template, the reorganized dialogue text and the current user question are input into a large language model enhanced with knowledge of geriatric diseases to generate a natural language summary containing core medical entities.
[0069] The advantages of the present invention compared with the prior art are:
[0070] 1. Significantly improve the coherence and accuracy of multi-round medical conversations
[0071] Traditional knowledge graph-based question answering (KBQA) systems typically only handle single-turn, independent questions and struggle to capture the temporal dependencies across multiple rounds of conversation, leading to fragmented or logically inconsistent answers. This new approach dynamically compresses and stores key information from historical conversations, extracting core medical entities such as symptoms, diseases, and medications. This ensures the system maintains contextual coherence even during extended conversations.
[0072] 2. Enhance the explainability and professional credibility of medical decision-making
[0073] Existing large-scale medical language models suffer from the "black box" problem, lacking a traceable path for generated answers, which undermines doctor-patient trust. This invention innovatively introduces a multi-agent collaborative architecture. Through dynamic routing and interpretation agents, it generates a three-hop reasoning chain (e.g., "symptoms → pathological mechanism → treatment plan") based on a knowledge graph and visualizes the decision logic. Furthermore, the domain-specific model, Geriatrics-MedLLM, utilizes LoRA fine-tuning technology to ensure that outputs strictly adhere to geriatric medical knowledge, significantly reducing the risk of hallucinations.
[0074] 3. Have the ability to continuously update and realize the dynamic update of medical knowledge
[0075] Traditional medical question-and-answer systems suffer from lagging knowledge updates, often requiring manual maintenance of the knowledge base, resulting in long and costly update cycles. This invention achieves continuous knowledge updates through an innovative architecture combining an external knowledge base with a dynamic learning mechanism. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] The present invention will be better understood from the following detailed description of the embodiments of the present invention in conjunction with the accompanying drawings. Figure 1 It is a flow chart of the overall steps of the present invention. DETAILED DESCRIPTION
[0077] The present invention comprises the following steps:
[0078] 1. Multi-source medical data fusion and knowledge graph construction
[0079] 1) Heterogeneous data collection and structured processing
[0080] We used targeted crawling technology to obtain disease diagnosis and treatment standard texts and doctor-patient conversation records from Haodaifu.com and Xunyiwenyao.com. We used regular expressions to clean and process the data to generate structured medical entity datasets and unstructured medical consultation datasets. We defined nine core medical entities (diseases, symptoms, medications, etc.) and 12 association relationships (companions, contraindications, treatment plans, etc.) and stored them as structured CSV files. We defined the storage format for doctor-patient conversation records and medical information text as JSON files, with the data formats being {"question": "…", "answer":"…"}, {"text": "…"} respectively.
[0081] 2) Storage and retrieval methods for unstructured diagnosis and treatment guidelines
[0082] This system realizes the automated construction of an external medical knowledge base through a modular data processing flow. During the specific implementation, a recursive character text segmenter is configured to perform semantic segmentation on multi-format documents: a sliding window strategy is adopted to set the text block length to 300 characters, and adjacent blocks overlap by 50 characters. CSVLoader, PyMuPDFLoader and TextLoader are used to parse structured medical data, diagnosis and treatment guide PDFs and unstructured case texts respectively; the segmented text is input into a pre-trained embedding model to generate a 768-dimensional semantic vector, and the HNSW indexing algorithm based on the Chroma vector database is used to achieve efficient storage, ultimately resulting in a dynamically updated medical knowledge base.
[0083] 2. Pre-training and fine-tuning of large domain models
[0084] 1) Pre-training stage
[0085] In the pre-training phase, medical field adaptive training is implemented based on the Qwen2-1.5B base model. The specific process is as follows:
[0086] a) Domain Data Injection: 27,000 specialized texts on geriatric diseases were extracted from a structured medical knowledge base, covering disease descriptions (such as pathological mechanisms and typical symptoms), drug instructions (indications and contraindications), and key sections of diagnosis and treatment guidelines to construct a pre-training corpus. Domain knowledge was injected using a full parameter update strategy, with a gradient accumulation step count of 4 and a global batch size of 32. BF16 mixed-precision training was used to reduce graphics memory usage.
[0087] b) Learning rate optimization: Apply the cosine decay scheduling strategy, set the initial learning rate to 0.0001, and the total training cycle to 3. Its mathematical expression is:
[0088]
[0089] Save checkpoints every 500 steps and monitor the loss curve. When the validation set loss drops by less than 0.1%, terminate the training early.
[0090] 2) Fine-tuning stage
[0091] During the fine-tuning phase, LoRA low-rank adaptive technology is used to optimize the model's instruction following and reasoning capabilities:
[0092] Efficient parameter fine-tuning: We constructed a medical Q&A dataset of 1 million questions (including patient consultation conversations and doctor diagnosis records) and injected a low-rank adapter into the Qwen2-1.5B pre-trained model. The parameter update formula is:
[0093]
[0094] in, is the original parameter matrix of the pre-trained model; is the low-rank parameter update amount; is the left matrix of the low-rank adapter; is the right matrix of the low-rank adapter; r is the rank factorization dimension, set to 8; α is the scaling factor that controls the contribution of ΔW to the final parameters, set to 16; d and k are the input and output dimensions, respectively. By inserting the adapter only in the Q and V projection matrices of the attention layer, the number of fine-tuned parameters is reduced to only 0.3% of the original model.
[0095] 3. Knowledge system construction
[0096] The Neo4j graph database construction implementation begins with establishing a knowledge network based on a triplet structure. This implementation involves three key steps: defining node attributes, assigning clinical characteristics to various medical entities, including core medical attributes like disease names and drug classifications; and setting edge weights, setting strength parameters for medical relationships like drug interactions. Data loading utilizes the CSVLoader tool to directly read standardized CSV files, enabling efficient batch import through native interfaces.
[0097] The implementation process utilizes a modular processing flow: A dedicated parser group is deployed for multi-format document processing, supporting standardized conversion of medical documents in various formats, such as TXT and CSV. Semantic processing ensures the consistency of medical terminology and clinical descriptions. Vectorized storage converts processed text into high-dimensional vector representations. Knowledge retrieval utilizes an improved similarity calculation method, incorporating medical feature constraints beyond traditional cosine similarity to ensure the clinical relevance of returned results.
[0098] 4. Multi-agent dynamic decision-making mechanism
[0099] 1) Dynamic routing decision mechanism
[0100] a) Entity recognition and confidence determination
[0101] After the question is entered, it is processed by the medical entity recognition model to extract entities such as diseases, symptoms, and drugs (corresponding to file fields such as Disease.csv and Symptom.csv)
[0102] The entity confidence calculation adopts the rules described in the patent document: when ≥2 medical entities are detected and the entity type falls within the scope of the knowledge graph definition, the knowledge graph agent (Graph_Func) is triggered.
[0103] b) Routing rules
[0104] Specialist agent activation conditions: Disease / symptom / drug entities are identified, and the entity association path has a predefined relationship in the Neo4j knowledge graph (such as DISEASE_SYMPTOM, DISEASE_DRUG)
[0105] General agent activation conditions: The question involves non-diagnosis and treatment consultation (such as health advice), and directly calls the plug-in knowledge base (Chroma vector library)
[0106] Complex reasoning agent activation conditions: The question contains phrases such as "conditioning", "indicators", "risk reduction" that require generative reasoning, or the entity confidence is lower than the graph retrieval threshold
[0107] 2) Agent execution logic
[0108] a) Knowledge Graph Agent (Graph_Func)
[0109] Cypher query generation: Automatically build query statements based on the relational structure defined in files such as DISEASE_SYMPTOM.csv
[0110] [MATCH (d:Disease)-[r:DISEASE_DRUG]->(m:Drug)
[0111] WHERE d.name IN ['hypertension']
[0112] RETURN m.name, r.dosage ]
[0113] Result verification: Only return the drug regimens that match the treatment method (cureway field) in Disease.csv
[0114] b) General Agent (Retrieval_Func)
[0115] Search scope: limited to the Chroma vector library of the external knowledge base described in the patent document, which independently stores the segmented unstructured text blocks
[0116] c) Complex Reasoning Agent (Geriatrics-MedLLM)
[0117] When encountering complex questions that the first two agents cannot answer, the complex reasoning agent model will be called to output the answer to the question.
[0118] 5. Summary of Historical Dialogue
[0119] The conversation history management module implements context maintenance through the following steps:
[0120] a. History capture: Real-time monitoring of conversation rounds. When the length of the history exceeds a preset threshold, the most recent five rounds of conversation content are automatically retained.
[0121] b. Text concatenation: Concatenate the intercepted conversation into a continuous string in the format of question:{user input}, answer:{system output};
[0122] c. Inject the concatenated text and the current user question into the predefined prompt template (SUMMARY_PROMPT_TPL), and call the large language model to generate a natural language summary;
[0123] d. Original data storage: The original, unmodified conversation records are completely preserved through an independent storage module to ensure data traceability.
[0124] The embodiments of the present invention are described in detail above. Specific implementation methods are used herein to illustrate the present invention. The description of the above embodiments is only used to help understand the method of the present invention. At the same time, for those skilled in the art, according to the ideas of the present invention, there may be changes in the specific implementation methods and application scopes. In summary, the contents of this specification should not be understood as limiting the present invention.
Claims
1. A health question-answering method for elderly diseases based on multi-agent and knowledge graph, characterized by: It includes the following steps: Step 1: Obtain structured data and unstructured text of geriatric diseases through a medical vertical website crawling system. After the structured data is standardized, a disease association relationship network is established. The unstructured text extracts question-and-answer pairs and disease entities through a semantic parsing module; Step 2: Adopt a two-stage large language model training architecture. In the pre-training stage, domain knowledge transfer is achieved through medical domain text injection. In the fine-tuning stage, low-rank adaptation technology is used to optimize model parameters to construct a dedicated language model for geriatrics; Step 3: Construct a multi-modal knowledge storage system. The topological storage of the disease knowledge network is realized through a graph database, the semantic retrieval of clinical practice guidelines is combined with a vector database, and a dynamic window segmentation strategy is adopted to process long texts; Step 4: Deploy an intelligent agent collaborative decision-making system. Based on the input semantic features, a knowledge graph query agent, a literature retrieval agent, or a generative dialogue agent is dynamically activated to achieve a multi-modal medical knowledge fusion response; Step 5: Construct a dialogue history management mechanism. Generate a summary through a large language model and independently store the original dialogue records.
2. The multi-agent and knowledge graph-based health question-answering method for elderly diseases according to claim 1 is characterized in that: The said Step 1 includes: Step 1.1: Structured data defines disease entities and association relationships; transforms medical knowledge into a computable knowledge graph network structure to achieve intelligent associations between disease characteristics and treatment plans, drug taboos, and dietary suggestions; The structured data includes: Node entity types: Define disease entities, examination item entities, treatment method entities, drug entities, department entities, recipe entities, and taboo entities; Disease association relationship chains: Define disease-treatment method relationships, disease-drug relationships, disease-examination item relationships, define disease-recommended recipe relationships, and define disease-taboo recipes; Step 1.2: The unstructured data processing uses the <question>.*?< / question><answer>.*?< / answer> tag pattern to extract doctor-patient conversations; maintains the semantic integrity of the original conversations and provides high-quality training data for the intelligent question-and-answer system.
3. The multi-agent and knowledge graph-based health question-answering method for elderly diseases according to claim 1 is characterized in that: The said Step 2 includes: Step 2.1: Pre-training stage; The learning rate scheduling formula is: The maximum learning rate =0.0001, total training cycle =3; Step 2.2: Fine-tuning stage; LoRA fine-tuning uses the formula LoRA fine-tuning uses the formula , set the rank decomposition dimension r = 8, the scaling factor α = 16, the Dropout rate p = 0.05, and enable the Flash Attention 2.0 block calculation mechanism; where, is the original parameter matrix of the pre-trained model; is the low-rank parameter update amount; is the left matrix of the low-rank adapter; is the right matrix of the low-rank adapter; r is the rank decomposition dimension, set to 8; α is the scaling factor, controlling The contribution strength to the final parameter is set to 16; d and k are the input dimension and output dimension respectively.
4. The multi-agent and knowledge graph-based health question-answering method for elderly diseases according to claim 1 is characterized in that: The said Step 3 includes: Step 3.1: Construct a knowledge graph based on structured data. The entity types of the knowledge graph include disease entities, symptom entities, and drug entities, and the relationship chains include disease-symptom relationships and disease-drug relationships; Step 3.2: Store external knowledge information in a vector database and use the HNSW index of Chroma to achieve cosine similarity retrieval. The formula is: Among them, A and B are the vector representations of two text fragments in the knowledge base, the numerator is the vector dot product, and the denominator is the product of the two vector moduli.
5. The multi-agent and knowledge graph-based health question-answering method for elderly diseases according to claim 1 is characterized in that: The said Step 4 includes: Step 4.1: The knowledge graph agent executes Cypher query statements in the format of: [MATCH(d:Disease)-[r:DISEASE_DRUG]->(m:Drug) WHERE d.name IN['Hypertension'] RETURN m.name, r.dosage] Step 4.2: The tool routing mechanism injects tool description text through a prompt template and outputs a regular matching result after being processed by the LLMChain chain.
6. The multi-agent and knowledge graph-based health question-answering method for elderly diseases according to claim 1 is characterized in that: The said Step 5 includes: Step 5.1: Monitor the conversation rounds in real time. When the history record length exceeds 5 rounds, automatically capture the content of the last 5 rounds of conversation. Step 5.2: Concatenate the intercepted conversation into continuous text blocks in the format of question:{user input}, answer:{system response}; Step 5.3: Inject the current question and historical text through the predefined prompt template, and call Geriatrics-MedLLM to generate a natural language summary.
Citation Information
Cited By
Medical information processing method, information processing method, equipment, storage medium and program product
CN120727264A
Multi-agent collaborative data question-answering system and method based on large model
CN121119169A
Medical question and answer method and system based on knowledge graph and intelligent agent
CN121122680A
Medical question and answer method and system based on knowledge graph and agent
CN121122680B
Question and answer method based on large model and data agent
CN121413751A