Medical dialogue thinking chain data set construction method and system based on forward reasoning
By generating thought chains consistent with clinical logic based on a forward reasoning approach, this approach addresses the issues of insufficient reasoning and data dependence in existing medical dialogue systems, enabling the construction of an efficient medical dialogue system and improving diagnostic accuracy and adaptability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-24
- Publication Date
- 2026-04-10
AI Technical Summary
Existing medical dialogue systems lack reasoning capabilities, generate thought chains that lack authenticity and depth, and rely on doctors' original responses, resulting in high data construction costs and limiting the interpretability and adaptability of the system.
We employ a forward reasoning-based approach, acquiring pending medical dialogue data, generating thought chains using a large language model, conducting quality assessments and iterative optimizations, constructing a structured training dataset, and fine-tuning the target model to generate doctor responses that conform to clinical logic.
It enables the automatic generation of high-quality thought chains consistent with clinical logic, reduces data construction costs, improves the diagnostic accuracy and adaptability of medical dialogue systems to complex scenarios, and enhances the interpretability and practicality of the system.
Smart Images

Figure CN121835937A_ABST
Abstract
Description
[0001] This invention relates to the interdisciplinary field of medical information processing, natural language processing, and artificial intelligence. Specifically, it is a method and system for constructing a clinical thought chain for a medical dialogue system based on positive reasoning. Background Technology
[0002] With the rapid development of large language models, medical dialogue systems have emerged as a potential virtual auxiliary tool, promising to support clinical decision-making processes and encompass key medical tasks such as symptom assessment and disease diagnosis. Current research primarily focuses on constructing high-quality medical dialogue datasets and fine-tuning large language models to simulate doctor-patient interactions.
[0003] However, existing medical dialogue systems and related technologies have significant shortcomings:
[0004] 1. Lack of Reasoning: Most existing methods focus only on clinicians' surface responses (such as symptom descriptions and diagnostic labels), failing to integrate underlying reasoning and decision-making processes to support professional clinical judgment. This leads to models overfitting statistical co-occurrence patterns in the training data. In complex or rare clinical cases, it can only rely on common symptom-disease mapping relationships and cannot simulate the refined and context-sensitive reasoning logic of professional physicians.
[0005] 2. Poor Reasoning Performance: Although thought chains have been applied in the field of medical dialogue to improve the reasoning ability of models, most existing applications adopt a posterior generation paradigm, constructing reasoning chains based on complete dialogue history and known diagnostic results. This method has two drawbacks: First, the reasoning depth is insufficient; the incremental and analytical cognitive processes of the generated thought chains differ significantly from actual clinical scenarios, making it difficult to capture the complexity of actual diagnostic thinking. Second, it lacks realism; constructing thought chains using known results weakens the reliability and generalization ability of simulated reasoning.
[0006] 3. Reliance on raw data: Existing medical dialogue data construction and model training mostly rely on doctors' labeled raw responses, which is not only costly and has a long data collection cycle, but also makes it difficult to generate high-quality data that conforms to real clinical reasoning logic on a large scale, thus limiting the scalability and practicality of medical dialogue systems.
[0007] While existing technologies have made some progress in the generation and knowledge extraction of medical dialogues, how to move away from reliance on doctors' raw responses, construct high-quality thought chains that conform to actual clinical reasoning processes, and improve the diagnostic accuracy, reasoning interpretability, and adaptability to complex scenarios of medical dialogue systems remain unresolved technical challenges. Therefore, developing a technical solution that can simulate doctors' forward clinical reasoning process and automatically generate high-quality thought chains is of great significance for improving the practicality and intelligence of medical dialogue systems. Summary of the Invention
[0008] The purpose of this invention is to provide a method and system for constructing clinical reasoning chains in medical dialogues based on forward reasoning. This method and system can automatically generate high-quality reasoning chains that are consistent with real clinical diagnostic thinking without relying on the doctor's original response. This solves the technical problems of existing medical dialogue systems, such as lack of reasoning process, lack of authenticity of reasoning chains, and high data construction costs, thereby improving the interpretability, diagnostic accuracy, and clinical adaptability of medical dialogue systems.
[0009] To achieve the above objectives, the present invention provides the following solution:
[0010] A method for constructing clinical thought chains in medical dialogues based on positive reasoning, comprising:
[0011] Acquire pending medical dialogue data; medical dialogue data includes records of multiple rounds of doctor-patient interaction, each round of doctor-patient interaction records includes patient statements, and optionally includes corresponding doctor responses, covering multiple medical professional scenarios such as internal medicine, pediatrics, and dentistry;
[0012] Based on a pre-defined forward reasoning module, the system takes as input a sequence of historical medical dialogues consisting of multiple rounds of doctor-patient interaction records, and generates a thought chain containing potential disease hypotheses, diagnostic criteria, and query logic, as well as doctor responses that fit the scenario. The forward reasoning module, with a large language model at its core, first determines whether the current interaction scenario is a professional medical consultation or a general chat scenario using a pre-defined Prompt template, outputs the corresponding identifier, and then uses appropriate prompting strategies to generate content.
[0013] The quality of the initial thought process and the doctor's response is evaluated from two dimensions: key point coverage and contextual coherence, through a pre-set review module. If both assessments meet the criteria, the initial thought process and response are retained; if they do not meet the criteria, the process proceeds to reflection and optimization.
[0014] Based on the pre-set reflection module, optimization suggestions are generated according to the evaluation results of the review module, guiding the positive reasoning module to iteratively adjust the thought chain and doctor's response until the evaluation reaches the standard or the pre-set iteration threshold.
[0015] A structured training dataset was constructed by evaluating all reasoning chains and corresponding medical conversation data collected; the dataset includes a mapping relationship of "medical conversation history - thought chain - doctor's response";
[0016] Based on a structured training dataset, the low-rank adaptive method (LoRA) is used to fine-tune the target large language model, resulting in a medical dialogue model with clinical reasoning capabilities.
[0017] Optionally, based on a preset forward reasoning module, a sequence of historical medical dialogues consisting of multiple rounds of doctor-patient interaction records is input to generate scene identifiers, structured thought chains, and doctor responses, specifically including:
[0018] Input the historical medical dialogue sequence into the forward reasoning module, with GPT-4o as the core model;
[0019] The forward reasoning module uses a pre-defined Prompt template to determine the type of the current interaction scenario, outputting "##1##" to identify a medical consultation scenario and "##2##" to identify a normal chat scenario.
[0020] In the case of a medical consultation, the system analyzes the patient's symptoms, hypothesizes potential diseases, formulates diagnostic query logic, and generates a thought process and doctor's response, in the format of "##Think##: XXX ##Response##: XXX".
[0021] In chat scenarios, the module uses a simplified reasoning process to focus on the patient's current expressive needs, generating natural responses and avoiding topic shifts.
[0022] Optionally, through a pre-built review module, the initial thought chain generated by the forward reasoning module, the doctor's response, and the complete original dialogue are input. The quality is evaluated from two dimensions: key point coverage and contextual coherence. The output is a judgment of whether the key point coverage meets the standard or not, and whether the contextual coherence is qualified or unqualified. Specifically, this includes:
[0023] Construct a key point coverage assessment unit: Extract key information points from doctors' real or standardized medical responses using a large language model, and generate a key information list in structured JSON format; use a pre-trained Natural Language Inference (NLI) model to calculate the semantic matching score between the initial answer and each key information point, and calculate the average of each score; if the average is not lower than a preset threshold, the key point coverage is deemed to meet the standard.
[0024] Construct a context coherence assessment unit: Replace the initial response in the original medical dialogue with the doctor's response to form a complete conversation sequence; evaluate the logical consistency and expressive fluency of the dialogue sequence through a large language model, and output "yes" or "no"; if "yes" is output, the consistency is judged to be qualified.
[0025] If the coverage of key points and the coherence of context meet the standards, the initial thought chain is retained; otherwise, a reflective optimization process will be triggered.
[0026] Optionally, based on a pre-built reflection module, the input review module's key point coverage or contextual coherence assessment results, initial thought chain, doctor's response, and a list of key information points or the doctor's actual response are used to generate targeted optimization suggestions and guide iterative adjustments. The output includes optimized suggestions, adjusted thought chains, and doctor's responses, specifically including:
[0027] If the key points coverage does not meet the standards, the reflection module defines the key information covered and the types of information not covered in the initial response, and generates optimization suggestions that do not disclose the original response.
[0028] If the contextual coherence is not up to standard, the reflection module compares the expression logic of the initial response and the doctor's actual response, and generates optimization suggestions from the perspectives of sentence connection and topic focus;
[0029] The forward reasoning module adjusts the generated content based on optimization suggestions and re-enters the evaluation process;
[0030] Set the iteration threshold to 10 iterations. If the threshold is reached but the condition is still not met, the reflection module lists specific key information points that need to be supplemented.
[0031] Optionally, based on a structured training dataset, and inputting a "medical dialogue history - thought chain - doctor's reply" mapping sample, LoRA parameters, and the target model, a low-rank adaptive method is used to fine-tune the target large language model, outputting a medical dialogue model with clinical reasoning capabilities, specifically including:
[0032] Qwen3-8B was selected as the target large language model.
[0033] Configure low-rank adaptive parameters: rank (r) = 64, scaling factor (α) = 16;
[0034] Fine-tuning and training were performed on a device equipped with an NVIDIA A100 GPU to generate a medical dialogue model with clinical reasoning capabilities.
[0035] A Medical Dialogue Clinical Thinking Chain Construction System Based on Positive Reasoning
[0036] The system includes:
[0037] The data acquisition module is used to collect medical dialogue data to be processed; the medical dialogue data includes records of multiple rounds of doctor-patient interaction, covering multiple medical professional scenarios;
[0038] The forward reasoning module receives a sequence of historical medical dialogues consisting of multiple rounds of doctor-patient interaction records. Through scenario judgment and targeted prompts, it generates scenario identifiers, thought chains and responses in the format of "##Think##: XXX ##Response##: XXX". This module uses GPT-4o as its core model and supports adaptive generation of dual scenarios.
[0039] The evaluation module assesses the quality of the initially generated content. It takes as input the initial thought chain generated by the forward reasoning module, the doctor's response, and the doctor's actual or standardized medical response. The output is a two-dimensional evaluation result: key point coverage meets or fails to meet the standard, and contextual coherence is satisfactory or unsatisfactory. This includes:
[0040] Key point coverage assessment unit: Extracts key information points and calculates semantic matching scores through the NLI model;
[0041] Context coherence assessment unit: verifies the logical consistency and fluency of the replaced dialogue sequence;
[0042] The reflection module generates optimization suggestions based on the evaluation results. It takes the two-dimensional judgment results of the evaluation module, the initial thought chain, the doctor's response and key information points or the doctor's actual response as input, and outputs targeted optimization suggestions and iterative generation results, namely the adjusted thought chain and doctor's response. It guides the positive reasoning module to iteratively adjust, supports precise scene prompts, and presets a threshold of 10 iterations.
[0043] The model training module employs a low-rank adaptive method, taking into input a "medical dialogue history - thought chain - doctor's reply" mapping dataset, LoRA parameters, target model, and hardware environment configuration, and outputting a model with clinical reasoning capabilities. Based on a structured dataset, the target large language model is fine-tuned to output a medical dialogue model with clinical reasoning capabilities.
[0044] An electronic device includes a memory and a processor, the memory storing a computer program and the processor running the computer program, enabling the electronic device to execute the above-described method for constructing a clinical thought chain for medical dialogue based on positive reasoning.
[0045] Optionally, the memory is a readable storage medium, including but not limited to solid-state drives, hard disk drives, flash memory, etc.
[0046] According to specific embodiments of the present invention, the present invention discloses the following technical effects: The method and system for constructing a clinical thought chain for medical dialogue based on forward reasoning provided by the present invention simulates the doctor's real diagnostic thinking process through a forward reasoning module, generating a thought chain consistent with clinical logic, thus filling the technical gap in the reasoning process of existing medical dialogue systems; with the help of a two-dimensional review module and a reflection iteration mechanism, the medical professionalism of the thought chain and the naturalness of the dialogue are guaranteed, eliminating the dependence on the doctor's original response and reducing the construction cost of high-quality medical dialogue data; a low-rank adaptive method is used to fine-tune the target model, taking into account both training efficiency and model performance, so that the optimized medical dialogue model can still maintain accurate diagnosis and smooth interaction in complex clinical scenarios, and has broad engineering application value and clinical assistance potential. Attached Figure Description
[0047] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0048] Figure 1 This is a schematic diagram of the overall structure of the FMT frame provided by the present invention.
[0049] Figure 2 is a schematic diagram of the review module workflow and examples of the present invention.
[0050] Figure 3 is a correlation analysis diagram of the threshold and model performance of the present invention. Specific implementation methods
[0051] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0052] To make the above-mentioned objects, features, and advantages of the present invention more apparent and readily understood, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. The core of the FMT (Forward-Inference framework for Medical Dialogue Systems) framework proposed in this invention is to simulate the clinical reasoning process through an iterative mechanism of "forward reasoning-review-reflection," automatically constructing a medical dialogue thought chain that conforms to real diagnostic and treatment thinking. The related accompanying drawings correspond to the implementation logic of different core components of the framework. Figure 1 The summary diagram shows the overall structure of the framework and the flow sequence of the core modules from 101 to 106; Figure 2 It showcases the workflow and real-world examples of the review module. Figure 3 The correlation analysis between the threshold settings of the review module and model performance is presented.
[0053] Example 1
[0054] Step 101: Obtain the raw data of the medical conversations for the dataset to be constructed; the raw data of the medical conversations includes partial samples from the open medical conversation datasets MedDialog and KaMed.
[0055] In practical applications, all data comes from open medical dialogue datasets. MedDialog covers 29 professional fields, including internal medicine, pediatrics, dentistry, and obstetrics and gynecology, and contains rich clinical scenario dialogues such as single-disease diagnosis and treatment and multi-symptom recognition. KaMed comes from an online medical consultation platform, and its number of ward rounds is significantly more than that of conventional medical dialogue datasets. It can provide complex clinical scenario dialogues such as chronic disease follow-up and multi-round medical history collection. Initial screening of the initially obtained raw medical dialogue data: To avoid excessive dialogue rounds leading to complex logical relationships, samples with three or more dialogue rounds in MedDialog and KaMed should be removed to provide basic input for subsequent modules.
[0056] Step 102: Generate an initial thought chain and doctor's response based on the forward reasoning module. The input is a filtered sequence of historical medical dialogues, and the output is a scene identifier, a structured thought chain, and a doctor's response.
[0057] As an optional implementation, step 102 specifically includes:
[0058] Step 1021: Input the historical medical conversation sequence into the forward inference module to start the scene recognition process with GPT-4o as the core model.
[0059] Use a pre-defined Prompt template to guide the model in determining the type of the current interaction scenario. An example of a Prompt template is shown below:
[0060] "You are an auxiliary judgment assistant. Please identify whether the patient's current expression intent belongs to the following categories: 1) medical consultation 2) chat or meaningless conversation. Please return the sequence number in the format ##X##."
[0061] The model output ##1## identifies a medical consultation scenario, and output ##2## identifies a regular chat scenario.
[0062] Step 1022: Execute the difference generation logic for different scenarios.
[0063] S1: If the scenario is determined to be a medical consultation, the model performs a detailed analysis of the patient's medical history, assumes potential disease types, formulates diagnostic query logic, and generates an initial thought process and doctor's response according to a preset format. The format requirements are as follows:
[0064] "##Think##: [Potential disease hypothesis + diagnostic basis + query design logic] ##Response##: [Doctor's questions or suggestions that conform to clinical diagnosis and treatment logic]"
[0065] Example:
[0066] "##Think##: The patient complains of intermittent sharp pain in the temporal region for one week. Migraine needs to be ruled out. Migraines are often accompanied by nausea and photophobia. Further investigation of related accompanying symptoms is needed. ##Response##: Does the patient experience nausea or light sensitivity during a headache attack?"
[0067] S2: If the scenario is determined to be a typical chat, this model uses a simplified reasoning process to focus on the patient's currently expressed needs, generating a natural response without requiring excessive medical explanation and avoiding topic shifts. The formatting requirements are the same as above. The focus of the thought process is understanding the needs, not diagnosing the disease.
[0068] Example:
[0069] "##Think##: The patient only mentioned headache-related feelings and did not explicitly seek medical advice, so an empathetic response is needed. ##Response##: A headache lasting a week can certainly be uncomfortable. How is your rest routine?"
[0070] Step 1023: Output the initial generated results, including the associated "thought chain + doctor's reply" combination, to provide input data for the subsequent review module.
[0071] Step 103: Improve the definition of downstream tasks and the construction of instruction prompt templates. The input is a complete sequence of multi-round doctor-patient dialogues and corresponding thought chains. The output is a structured daily medical record and instruction prompt templates.
[0072] S3: In order to measure the model’s actual ability to generate clinical scenarios and determine the task of automatically generating daily medical records, the input is a complete sequence of multi-turn doctor-patient dialogues plus the corresponding thought chain, and the output is a structured daily medical record that conforms to medical document standards (including symptom summary, initial diagnosis tendency, and key points of diagnosis and treatment suggestions).
[0073] Step 1032: Construct a set of instruction prompt templates suitable for downstream tasks. The templates should include a task description, placeholders, and examples, as shown below:
[0074] Document Structured Task Template:
[0075] <task>You need to convert unstructured electronic medical record text into structured data, covering core fields such as symptoms, course of disease, past medical history, and test results.
[0076] <format>{"Symptoms": ["Field 1", "Field 2", ...], "Course of Illness": "Description", "Past Medical History": ["Disease 1", "Disease 2", ...], "Examination Results": ["Item 1: Result 1", ...]}
[0077] <example>Input: "The patient developed a sore throat and mild cough 3 days ago, with no fever. There is no history of hypertension, and blood tests showed a normal white blood cell count."
[0078] Output: {"Symptoms": ["Sore throat", "Mild cough"], "Duration of illness": "Onset 3 days ago, no fever", "Past medical history": ["No history of hypertension"], "Test results": ["Complete blood count: normal white blood cell count"]}
[0079] Estimated text content belongs to the relevant field or document task template:
[0080] <task>You need to determine which core field or document type in the electronic medical record the input unstructured medical record text belongs to (optional: symptom description, examination report, diagnosis conclusion, treatment plan, medical record).
[0081] <format>## Belonging Field / Document Type##: XXX
[0082] <example>Input: "Chest CT scan shows increased and thickened lung markings in both lungs, with no obvious nodular shadows."
[0083] Output: ## Field / Document Type##: Inspection Report
[0084] Automatic generation of task templates for daily medical record keeping:
[0085] <task>Based on the history of doctor-patient dialogue and clinical thought process, generate standardized daily medical records, which should include three core parts: symptom summary, preliminary diagnostic tendency, and next treatment suggestions, with concise language that meets the requirements of medical documents.
[0086] <format>Symptom Summary: XXX Preliminary Diagnosis Tendency: XXX Further Treatment Recommendations: XXX
[0087] <example>Input: "Conversation history: The patient complains of intermittent sharp temporal pain for one week, accompanied by nausea and photophobia; Thought chain: The patient's symptoms are consistent with typical migraine presentations, further confirmation of attack frequency and triggers is needed."
[0088] Output: Symptom Summary: The patient has experienced recurrent intermittent sharp pain in the temporal region for the past week, accompanied by nausea and photophobia, but no vomiting. Preliminary Diagnosis Tendency: Migraine? Next Steps: Inquire about the frequency, duration, and triggering factors (such as sleep and diet) of headache attacks.
[0089] Step 104: Complete the initial content quality assessment through the review module.
[0090] As an optional implementation, step 104 specifically includes:
[0091] Step 1041: Construct a key point coverage assessment unit, complete the core information matching verification, input is the doctor's real response or standardized medical response, initial response, output is a list of key information points, average score, and a judgment on whether the key point coverage meets the standard.
[0092] S1: Extract key information points from doctors' actual or standardized medical responses using a large language model, and generate a structured JSON list. A sample Prompt template is shown below:
[0093] <task>As a professional physician, please extract the key information points that directly reflect the core of the diagnosis and treatment from the reference responses. No detailed descriptions are required; keep it concise and clear, and output it in JSON format.
[0094] Example: Suggested response: "Do you experience nausea or light sensitivity during a headache?"
[0095] Output: {"key_points": ["Inquiry about headache accompanied by nausea", "Inquiry about headache accompanied by photophobia"]}
[0096] S2: Using a pre-trained Natural Language Inference (NLI) model, according to the formula Calculate the average score (r is the initial response). (where i is the i-th key information point, and N is the total number of key information points).
[0097] S3: Set a preset threshold x (recommended value is 0.7). If the average score is ≥ x, the coverage of the key points is considered satisfactory; otherwise, it is considered unqualified.
[0098] Step 1042: Construct a context coherence evaluation unit to verify the logical fluency of the dialogue. The input is the original medical dialogue, the initial generated response, and the subsequent patient expression. The output is the coherence qualification.
[0099] S1: Replace the doctor's response in the original medical dialogue with the initially generated response to form a complete dialogue sequence (including historical dialogue + initially generated response + subsequent patient expression).
[0100] S2: Guide the model to evaluate the continuity of the dialogue using a preset Prompt template. An example of a Prompt template is shown below:
[0101] <task>Please determine whether the following dialogue is logically coherent and naturally expressed. Return the result in the format of ##yes## or ##no##.
[0102] {Conversation History}: [The complete dialogue sequence after replacement]
[0103] Example:
[0104] Input: "Patient: I've had temporal headaches for a week, intermittent sharp pain. Generated response: Do you experience nausea or photophobia during headache attacks? Patient: Yes, sometimes nausea, and photophobia."
[0105] Output: ##yes##
[0106] S3: If the model outputs ##yes##, then the contextual coherence is considered satisfactory; otherwise, it is considered unsatisfactory.
[0107] Step 1043: Based on the comprehensive evaluation results, if the key point coverage and contextual coherence are both satisfactory, the initial thought chain and response are retained; if any dimension is unsatisfactory, the reflection and optimization process is triggered.
[0108] Step 105: Iteratively optimize the thought process and responses based on the reflection module.
[0109] As an optional implementation, step 105 specifically includes:
[0110] Step 1051: Classify and analyze cases that fail the review module, and propose targeted optimization suggestions. The inputs are the evaluation results, initial responses, a list of key information points, or the doctor's actual responses, and the output is targeted optimization suggestions.
[0111] S1: If the failure is due to insufficient coverage of key points, the rethinking module uses the NLI scoring results to locate the covered key information and the types of information that are not covered, and generates optimization suggestions without revealing the original response. The Prompt template is as follows:
[0112] "You are a professional doctor and need to guide the model to generate high-quality responses."
[0113] Model's response: {response}
[0114] Covered points: {covered_points}
[0115] Uncovered points: {uncovered_points}
[0116] First, identify the key points covered by the model, and then propose improvements based on the points not covered. Be careful not to reveal the original text to the model.
[0117] S2: If the contextual coherence is insufficient, the reflection module will compare the initial response's logical expression with the doctor's actual response's logical expression, and provide optimization suggestions from the perspectives of sentence connection and topic focus. The Prompt template is as follows:
[0118] "You are a medical professional, and your task is to guide the model to generate high-quality responses."
[0119] Model's response: {response}
[0120] Doctor's answer: {doctor_answer}
[0121] Please compare the above responses and offer suggestions for improvement, being careful not to reveal the original doctor's answers to the model.
[0122] Step 1052: The forward reasoning module receives optimization suggestions, adjusts the generation logic, regenerates the thought chain and replies, and then enters the review process of Step 104 again.
[0123] Step 1053: Set the iteration threshold to 10 iterations. If the number of iterations reaches the threshold but the model still fails the two-dimensional evaluation, the reflection module will clearly list the specific points that need to be supplemented and guide the model to the final generation.
[0124] Step 106: Construct a structured training dataset and fine-tune the target large language model
[0125] As an optional implementation, step 106 specifically includes:
[0126] Step 1061: Integrate the approved generated data to build a structured training dataset. The input is the approved thought chain and medical conversation data, and the output is the structured training dataset.
[0127] By mapping the "medical dialogue history - thought chain - doctor's response" one by one, standardized data samples are formed. The sample format is as follows:
[0128] "history": ["Patient: I've had temporal headaches for a week, intermittent sharp pain.", "Patient: Yes, sometimes nausea, and sensitivity to bright light."],
[0129] "think": "The patient complains of intermittent sharp temporal pain for one week, accompanied by nausea and photophobia. Migraine is highly suspected. Further confirmation of the frequency and duration of attacks is needed to complete the diagnosis."
[0130] Response: How frequently do these headaches occur? How long do they last each time?
[0131] The dataset needs to cover multiple professional scenarios (internal medicine, pediatrics, dentistry, etc.) in MedDialog and KaMed to ensure data diversity.
[0132] Step 1062: Configure the model, adjust parameters and environment, and begin the training process.
[0133] S1:Qwen3-8B was used as the target large language model, and the Low Rank Adaptive (LoRA) method was employed for fine-tuning. The parameters were set as follows: rank (r) = 64, scaling factor (α) = 16.
[0134] S2: Training was conducted in a hardware environment equipped with an NVIDIA A100 GPU. The training data was divided into training, validation, and test sets according to the ratios of 32723 / 3000 / 3000 (MedDialog) and 57754 / 3000 / 3000 (KaMed).
[0135] Step 1063: After training, output a medical dialogue model with clinical reasoning ability, which automatically generates a thought chain and doctor's response that conforms to clinical logic based on the patient's dialogue.
[0136] Figure 2 This section highlights the core operational logic of the review module within the FMT framework. Through a two-dimensional verification mechanism of "key point coverage assessment + contextual coherence assessment," and combined with specific medical dialogue cases, it provides a detailed breakdown of the quality judgment process for the initial generated content (thought chain + doctor's response), offering a clear basis for subsequent reflection, optimization, or result retention. The following are the specific implementation steps of this module:
[0137] As an optional implementation, the quality assessment process of the review module (corresponding to the detailed development of step 104) specifically includes:
[0138] Step 201: Clearly define the evaluation input data (connection) Figure 1 )
[0139] The input data contains two types of core information to ensure the relevance and reference value of the evaluation: the data to be evaluated is... Figure 1 The combination of "initial thought chain + doctor's response" generated in step 102 (used only for quality verification, not generated repeatedly); the reference benchmark data is the doctor's real response in the original medical dialogue or industry-standardized medical response (as the basis for extracting key information and logical verification).
[0140] Step 202: Key point coverage assessment. Inputs are reference baseline data and initial responses. Outputs are a list of key information points, average score, and a determination of whether key point coverage meets the standard.
[0141] The initial response is verified to cover core diagnostic information through a three-level process: "extracting key points → calculating semantic matching scores → threshold judgment." First, a large language model is invoked to extract structured key information points from the reference benchmark data based on a pre-set Prompt template. This information is output in JSON format to ensure that the key points focus on the core diagnostic information without redundancy. An example of the Prompt template is as follows:
[0142] " <task>As a professional clinician, please extract the key information points that directly reflect your diagnostic and treatment intentions from the reference responses. No detailed explanations are required; keep it concise and clear, and strictly adhere to the specified JSON format.
[0143] The case referenced the response, "Do you experience nausea or light sensitivity during a headache?"
[0144] The extraction result is:
[0145] {"key_points": ["Inquire about nausea accompanying headache", "Inquire about photophobia accompanying headache"]};
[0146] Next, a pre-trained Natural Language Inference (NLI) model is used to calculate the semantic association score between the initial response and each key information point (entailment = 1 point, neutral = 0.5 points, contradiction = 0 points), and the score is calculated according to the formula. (where r is the initial doctor's response generated in step 102 of Figure 1,) Calculate the average score for the i-th extracted key information point (where N is the total number of key information points).
[0147] Case Study:
[0148] The initial response, "Do you feel nauseous during a headache?", received NLI scores of 1 and 0 for the two key information points, respectively, with an average score of... Finally, preset evaluation thresholds. (The optimal threshold, verified through experiments, balances professionalism and flexibility), if the average score Then the key point coverage is deemed to meet the standard. If the score is less than 0.7, the case above is deemed to be substandard, indicating that the coverage of the key points is insufficient.
[0149] Step 204: Comprehensive evaluation result determination. The inputs are the key point coverage evaluation result and the context coherence evaluation result. The outputs are the determination of whether the initially generated content needs to be optimized and the subsequent processing path.
[0150] Based on the two-dimensional evaluation results, clarify the subsequent processing path and achieve connection with the overall framework process: if the key point coverage ( If any dimension does not meet the standard (key point coverage does not meet the standard or context coherence outputs "##no##"), then the initially generated content needs to be optimized, triggering the reflection module and entering the iterative optimization process of step 105 in Figure 1.
[0151] Step 205: Iterative Control Mechanism
[0152] To avoid efficiency losses caused by infinite iterations, a preset iteration threshold of 10 times is set (consistent with the iteration limit of the reflection module): when the initially generated content does not meet the standards, it is optimized by the reflection module and then returned to steps 202-204 for a second evaluation until both dimensions meet the standards. If the iteration count reaches 10 times and the two-dimensional evaluation fails, the reflection module will explicitly list the specific key information points that are not covered (such as "additional photophobia symptoms need to be queried"), guiding the forward reasoning module to generate a final time, ensuring a closed-loop evaluation process.
[0153] The FMT (Forward Inference framework for Medical Dialogue Systems) framework of this invention constructs an instruction dataset based on open medical dialogue datasets (such as MeDialog and KaMed). Samples are selected from no more than three rounds of dialogue to ensure the integrity of clinical logic. It covers 29 professional fields, including internal medicine and pediatrics, as well as scenarios such as single-disease diagnosis and treatment and chronic disease follow-up, ensuring the professionalism and complexity of the data. Simultaneously, through a unified template conversion of "medical dialogue history - thought chain - doctor response," it has high scalability and can adapt to clinical consultation scenarios and doctor-patient interaction tasks in different hospitals without requiring major adjustments to the core logic.
[0154] The core of the FMT framework of this invention is an iterative mechanism of "forward reasoning-review-reflection": Forward reasoning, centered on GPT-4o, first defines the scenario (medical consultation outputs "##1##", ordinary chat outputs "##2##"); the review process evaluates from two dimensions: key point coverage (NLI model calculates semantic matching score, ≥0.7 passes) and contextual coherence (assessing conversation fluency, outputting "yes" passes). In the reflection phase, optimization suggestions are proposed based on the results to guide iterative adjustments. Ten iteration thresholds are preset to ensure that the content conforms to clinical standards.
[0155] The FMT framework of this invention defines downstream tasks of medical dialogue (thought chain generation, doctor response generation, and automatic clinical document generation). First, an initial Prompt template is manually compiled, then GPT-4o is used to extend each task to ≥10. The corresponding system functions are implemented through modules such as data acquisition, forward inference, and review. Model training uses the LoRA method to fine-tune Qwen3-8B. In an adaptive electronic device, the template library and data required by the framework are stored in memory, and the processor supports multi-threaded processing and iterative scheduling to ensure stable framework operation.
[0156] Example 2
[0157] This invention provides an electronic device, comprising: a memory and a processor. The memory stores a computer program, which includes a method for constructing a clinical thought chain for medical dialogue based on forward reasoning, as well as module logic codes, a Prompt template library, raw medical dialogue data, a structured training dataset, and model training parameters required for system operation. The processor runs the computer program, enabling the electronic device to execute the method for constructing a clinical thought chain for medical dialogue based on forward reasoning in Embodiment 1, including the entire process of data acquisition and screening, initial thought chain and response generation, quality review, reflective iterative optimization, structured dataset construction, and model fine-tuning training.
[0158] As an optional embodiment, the memory is a readable storage medium, including but not limited to solid-state drives, hard disk drives, flash memory, read-only memory and random access memory, capable of stably storing large-scale medical data and model files, and supporting high-speed data read and write.
[0159] As an optional implementation, the processor can be a CPU or a GPU, with the NVIDIA A100 being the preferred GPU, which has parallel computing capabilities and can efficiently support computationally intensive tasks such as GPT-4o inference, NLI model computation, and Qwen3-8b fine-tuning.
[0160] This document uses specific examples to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. Furthermore, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.< / task> < / task> < / task> < / example> < / format> < / task> < / example> < / format> < / task> < / example> < / format> < / task>
Claims
1. A method for constructing clinical thought chains in a medical dialogue system, characterized in that, include: Medical dialogue data is obtained by screening and collecting data from publicly available medical dialogue datasets such as MedDialog and KaMed or real clinical doctor-patient interaction records. Short dialogues with fewer than three rounds are removed to ensure that the data are valid multi-round interactions. At the same time, the data is de-identified to ensure privacy and security. The medical dialogue data includes dialogue pairs of multi-round patient statements and corresponding doctor responses, and does not rely on the reasoning process records in the original doctor responses. A forward reasoning module is constructed. It takes a sequence of historical dialogues as input and first identifies the dialogue type as either medical consultation or general chat through scene recognition. Then, for different types, it uses appropriate Prompt strategies to generate tuples containing the reasoning process and the doctor's responses. In the medical consultation scenario, it analyzes the patient's symptoms in detail, hypothesizes potential diseases, and formulates subsequent diagnostic and treatment-related interactive content. In the general chat scenario, it uses simplified reasoning to avoid topic shifts. Finally, it outputs the doctor's response generated by the model and submits it to the next module. A review module is constructed, taking into input doctor responses from the forward reasoning module and the complete original dialogue. It evaluates the generated content from two dimensions: key point coverage and contextual coherence. Key point coverage is assessed by extracting key medical information from the doctor's annotations and the original dialogue, semantically matching the generated response with each key point, calculating the average score, and comparing it to a preset threshold to determine if the generated content meets review standards. Contextual coherence assesses the fluency of the generated content within the dialogue. The generated response is replaced with the doctor's response from the original dialogue, and the complete dialogue history, the current round of generated responses, and the next round of patient statements are input. A preset Prompt template guides the evaluation model to output the judgment result, verifying the logical consistency and fluency of the entire dialogue process. The module outputs the evaluation result, scores for each dimension, and specific reasons for failure, providing clear evidence for the reflection module. A reflection module is constructed, which takes as input the evaluation results, reasons, and original medical dialogue from the review module. When the generated response fails the review, targeted optimization suggestions are generated based on the evaluation results. If the key points are insufficiently covered, the coverage and the key points that need to be supplemented are noted. If the contextual coherence is insufficient, the optimization direction is analyzed and expressed, guiding the positive reasoning module to iterate and optimize the output until the generated response passes the review or the preset maximum number of iterations is reached. When the generated response passes the review, the module outputs a medical dialogue containing that response, which includes the corresponding thought chain. This data will be used to train the medical dialogue model to improve its diagnostic reasoning ability and response quality.
2. The method for constructing a clinical thought chain in a medical dialogue system according to claim 1, characterized in that, The forward reasoning module employs a large language model, which is a pre-trained model capable of adapting to medical scenarios. Scene recognition guides the model to determine the patient's intent through preset Prompt templates. The Prompt template for medical consultation scenarios includes task guidelines for symptom analysis, disease hypotheses, diagnostic and treatment interaction design, and a fixed output format. The Prompt template for idle chat scenarios emphasizes fitting the dialogue history and avoiding over-interpreting patient statements, ensuring the professionalism and adaptability of the content generated in different scenarios.
3. The method for constructing a clinical thought chain in a medical dialogue system according to claim 1, characterized in that, When reviewing the key point coverage of the response, a large language model extracts key points from the doctor's replies using a Prompt function. Semantic matching uses a natural language reasoning task model to calculate the implication or contradiction score between the generated response and each key point. Preset thresholds are determined based on medical professional standards and data distribution to ensure the completeness of key point coverage in the generated response. The contextual coherence review guides the evaluation model to output judgment results only through a pre-set Prompt template. During the review process, the complete dialogue history, the current round of generated responses, and the next round of patient statements are required as input to comprehensively verify the adaptability of the generated responses in the dialogue process.
4. The method for constructing clinical thought chains in a medical dialogue system according to claim 1, characterized in that, The preset maximum number of iterations for the reflection module is set according to the needs of the actual application scenario. When the number of iterations reaches the threshold but still fails the review, the reflection module will clearly list the specific points that need to be added in the optimization suggestions. The forward reasoning module directly adds the relevant content according to the suggestions, completes the output optimization, and ensures the efficiency and effectiveness of the thought chain construction.
5. The method for constructing a clinical thought chain in a medical dialogue system according to claim 1, characterized in that, The generated medical dialogue thought chain data includes the reasoning process and doctor's responses for each round of dialogue. The reasoning process needs to fully simulate the incremental analysis and logical reasoning processes in clinical diagnosis. The doctor's responses need to conform to medical professional standards and be highly compatible with the reasoning process. Using the LoRA method, the ensemble thought chain data can be trained on the target medical dialogue model to improve the model's performance in tasks such as symptom query and disease diagnosis.
6. A clinical thought chain construction system in a medical dialogue system, characterized in that, It includes a data acquisition module for acquiring medical dialogue data containing multiple rounds of patient statements and corresponding doctor responses, without relying on the reasoning process records in the original doctor responses; The forward reasoning module is based on a large language model. It takes historical dialogue sequences as input, determines the dialogue type through scene recognition, and uses the corresponding prompt to generate a tuple response containing the reasoning process and the doctor's reaction. The review module evaluates responses from two dimensions: key point coverage and contextual coherence. This evaluation is achieved through key information extraction, semantic matching calculation, and dialogue process verification. The reflection module generates optimization suggestions based on the review results, guiding the forward reasoning module to iteratively optimize the output until the review requirements are met or the preset iteration threshold is reached.
7. An electronic device, characterized in that, The device includes a memory and a processor, the memory being used to store a computer program, and the processor running the computer program to cause the electronic device to perform the clinical thought chain construction method in the medical dialogue system according to any one of claims 1-5.
8. The electronic device according to claim 7, characterized in that, The memory is a readable storage medium, and the processor has parallel computing capabilities, enabling it to support the efficient operation of large language models and multi-module collaborative processing during the construction of thought chains.