Medical dialogue search term rewriting method and device, equipment and storage medium
By using the BERT classification model to detect intent shifts and follow-up questions in medical dialogues, and clearing or triggering pronoun disambiguation and semantic completion functions, the problem of search term rewriting distortion caused by improper context handling in medical dialogue systems is solved, thereby improving retrieval accuracy and efficiency.
Patent Information
- Application Number
- CN202511513904.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-22
- Publication Date
- 2025-11-21
AI Technical Summary
Existing medical dialogue systems lack the ability to understand complex dialogue logic, resulting in unclear pronouns, failure to recognize sudden changes in intent, affecting retrieval accuracy, and failing to generate standardized medical questions.
The system uses a pre-defined BERT classification model to detect whether the current dialogue input is a follow-up question or an intent shift. When an intent shift or non-follow-up question is detected, the historical dialogue context is cleared and output as an independent query. When no intent shift occurs and the input is a follow-up question, the system triggers the referential disambiguation and semantic completion functions to generate a standard medical question.
Dynamically identifying changes in dialogue intent, accurately parsing referential relationships, and generating semantically complete and standardized medical questions avoids interference from old contexts with new topics, thereby improving retrieval accuracy and efficiency and significantly increasing vector recall.
Smart Images

Figure CN120994798A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of natural language processing and human-computer interaction, and in particular to a method, apparatus, device, and storage medium for rewriting medical dialogue search terms. Background Technology
[0002] In current medical dialogue systems, user input is typically sent directly to the retrieval or generation model, lacking the ability to understand complex dialogue logic; some systems use rule matching or simple context concatenation to handle multi-turn dialogues, such as: Combine the previous question with the current input; use keyword expansion for simple completion.
[0003] The existing technology has the following technical problems: Unclear pronouns may lead to misjudgments; attempts to forcibly associate with the context without recognizing the intended change may result in incorrect reasoning; incomplete expression may affect retrieval accuracy; lack of understanding of professional terminology may prevent the generation of standardized medical questions. Summary of the Invention
[0004] The main objective of this invention is to provide a method, apparatus, device, and storage medium for rewriting medical dialogue search terms, aiming to solve the technical problem that existing medical dialogue systems lack the ability to understand complex dialogue logic, cannot dynamically identify it, are prone to erroneous reasoning, and affect detection accuracy.
[0005] In a first aspect, the present invention provides a method for rewriting medical dialogue search terms, the method comprising the following steps: The system uses a pre-defined BERT classification model to detect whether the current dialogue input is a follow-up question or a change in intent. When it is detected that the current dialogue input has a change of intent or is not a follow-up question, the historical dialogue context is cleared and the current input is directly output as an independent query. When it is detected that the current dialogue input has not changed its intent and is a follow-up question, the function of referential disambiguation and semantic completion is triggered to generate a standard medical question.
[0006] Optionally, the step of detecting whether the current dialogue input is a follow-up question or an intent shift using a preset BERT classification model includes: The current dialogue input and historical dialogue context of the current user are analyzed by a preset BERT classification model to determine whether the current dialogue input is a follow-up question or an intention change.
[0007] Optionally, the step of analyzing the current user's current dialogue input and historical dialogue context using a preset BERT classification model to determine whether the current dialogue input is a follow-up question or an intention shift includes: The last question from the historical dialogue is combined with the current dialogue input of the current user using the CLS separator to form a standardized input sequence; The standardized input sequence is input into a preset BERT classification model to obtain the key binary classification result; Based on the key binary classification results, determine whether the current dialogue input is a follow-up question or an intent shift has occurred.
[0008] Optionally, the step of clearing the historical dialogue context and directly outputting the current input as an independent query when the intent of the current dialogue input changes or is not a follow-up question includes: When the dual-task binary classification submodule of the preset BERT classification model detects that the current dialogue input has a change in intent or is not a follow-up question, the historical dialogue context is immediately cleared and the current dialogue input is directly output as an independent query.
[0009] Optionally, when it is detected that the current dialogue input has not undergone an intent shift and is a follow-up question, the function of pronoun disambiguation and semantic completion is triggered to generate a standard medical question, including: When the dual-task binary classification submodule of the preset BERT classification model detects that no intent change has occurred and the current dialogue input is a follow-up question, the function of referential disambiguation and semantic completion is automatically triggered. Standard medical questions are generated based on the triggering of pronoun disambiguation and semantic completion functions.
[0010] Optionally, generating standard medical questions based on the triggered referential disambiguation and semantic completion functions includes: The pronoun referencing object in the current dialogue input is identified based on the pronoun disambiguation function in the triggering pronoun disambiguation and semantic completion functions. Based on the historical context, the semantic completion function in the triggering referential disambiguation and semantic completion functions supplements the correct key medical information. The current dialogue input is processed based on the pronoun referent and the key medical information, and the processed data is formatted to generate a standard medical question.
[0011] Optionally, after detecting that the current dialogue input has not undergone an intent shift and that the current dialogue input is a follow-up question, triggering the referential disambiguation and semantic completion functions to generate a standard medical question, the medical dialogue search term rewriting method further includes: If no intention change is detected in the current dialogue input, and no follow-up question is detected in the current dialogue input, the current input is directly output as the standard question.
[0012] Secondly, to achieve the above objectives, the present invention also proposes a medical dialogue search term rewriting device, the medical dialogue search term rewriting device comprising: The detection module is used to detect whether the current dialogue input is a follow-up question or an intention change has occurred using a preset BERT classification model; The clear module is used to clear the historical dialogue context and output the current input directly as an independent query when it is detected that the current dialogue input has changed its intent or is not a follow-up question; The standard medical question module is used to generate standard medical questions when it is detected that the current dialogue input has not undergone an intent change and the current dialogue input is a follow-up question, triggering the referential disambiguation and semantic completion functions.
[0013] Thirdly, to achieve the above objectives, the present invention also proposes a medical dialogue search term rewriting device, the medical dialogue search term rewriting device comprising: a memory, a processor, and a medical dialogue search term rewriting program stored in the memory and executable on the processor, the medical dialogue search term rewriting program being configured to implement the steps of the medical dialogue search term rewriting method described above.
[0014] Fourthly, to achieve the above objectives, the present invention also proposes a storage medium storing a medical dialogue search term rewriting program, wherein when the medical dialogue search term rewriting program is executed by a processor, it implements the steps of the medical dialogue search term rewriting method described above.
[0015] The medical dialogue search term rewriting method proposed in this invention detects whether the current dialogue input is a follow-up question or an intent shift by using a preset BERT classification model. When an intent shift or non-follow-up question is detected, the historical dialogue context is cleared and the current input is directly output as an independent query. When no intent shift is detected and the current dialogue input is a follow-up question, the function of disambiguation and semantic completion is triggered to generate standard medical questions. This method can dynamically identify changes in dialogue intent, accurately parse referential relationships, and generate standardized medical questions, avoiding interference from old contexts with new topics, accurately standardizing medical terminology, and generating semantically complete and standardized medical questions. It effectively solves the problem of search term rewriting distortion caused by improper context handling in medical dialogues, significantly improves vector recall in scenarios such as clinical decision support and intelligent triage, and improves the speed and efficiency of medical dialogue search term rewriting. Attached Figure Description
[0016] Figure 1 This is a schematic diagram of the device structure of the hardware operating environment involved in the embodiments of the present invention; Figure 2This is a flowchart illustrating the first embodiment of the medical dialogue search term rewriting method of the present invention; Figure 3 This is a flowchart illustrating the second embodiment of the medical dialogue search term rewriting method of the present invention; Figure 4 This is a flowchart illustrating the third embodiment of the medical dialogue search term rewriting method of the present invention; Figure 5 This is a flowchart illustrating the fourth embodiment of the medical dialogue search term rewriting method of the present invention; Figure 6 This is a functional block diagram of the first embodiment of the medical dialogue search term rewriting device of the present invention.
[0017] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0018] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0019] The solution of this invention mainly involves: detecting whether the current dialogue input is a follow-up question or an intent shift by using a preset BERT classification model; when the current dialogue input is detected to have an intent shift or is not a follow-up question, clearing the historical dialogue context and directly outputting the current input as an independent query; when the current dialogue input is detected to have no intent shift and is a follow-up question, triggering the referential disambiguation and semantic completion functions to generate standard medical questions. This can dynamically identify changes in dialogue intent, accurately parse referential relationships, and generate standardized medical questions, avoiding interference from old contexts with new topics, accurately completing the standardization of medical terminology, and generating semantically complete and standardized medical questions. This effectively solves the problem of search term rewriting distortion caused by improper context handling in medical dialogues, significantly improving vector recall in scenarios such as clinical decision support and intelligent triage, increasing the speed and efficiency of medical dialogue search term rewriting, and solving the technical problem in existing medical dialogue systems that lack the ability to understand complex dialogue logic, cannot dynamically identify it, are prone to erroneous reasoning, and affect detection accuracy.
[0020] Reference Figure 1 , Figure 1 This is a schematic diagram of the device structure of the hardware operating environment involved in the embodiments of the present invention.
[0021] like Figure 1As shown, the device may include: a processor 1001, such as a CPU; a communication bus 1002; a user interface 1003; a network interface 1004; and a memory 1005. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen or an input unit such as a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be high-speed RAM or non-volatile memory, such as a disk drive. Optionally, the memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0022] Those skilled in the art will understand that Figure 1 The device structure shown does not constitute a limitation on the device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0023] like Figure 1 As shown, the memory 1005, which serves as a storage medium, may include an operating device, a network communication module, a user interface module, and a medical dialogue search term rewriting program.
[0024] The device of the present invention calls the medical dialogue search term rewriting program stored in the memory 1005 through the processor 1001, and performs the following operations: The system uses a pre-defined BERT classification model to detect whether the current dialogue input is a follow-up question or a change in intent. When it is detected that the current dialogue input has a change of intent or is not a follow-up question, the historical dialogue context is cleared and the current input is directly output as an independent query. When it is detected that the current dialogue input has not changed its intent and is a follow-up question, the function of referential disambiguation and semantic completion is triggered to generate a standard medical question.
[0025] The device of the present invention, through processor 1001 calling the medical dialogue search term rewriting program stored in memory 1005, also performs the following operations: The current dialogue input and historical dialogue context of the current user are analyzed by a preset BERT classification model to determine whether the current dialogue input is a follow-up question or an intention change.
[0026] The device of the present invention, through processor 1001 calling the medical dialogue search term rewriting program stored in memory 1005, also performs the following operations: The last question from the historical dialogue is combined with the current dialogue input of the current user using the CLS separator to form a standardized input sequence; The standardized input sequence is input into a preset BERT classification model to obtain the key binary classification result; Based on the key binary classification results, determine whether the current dialogue input is a follow-up question or an intent shift has occurred.
[0027] The device of the present invention, through processor 1001 calling the medical dialogue search term rewriting program stored in memory 1005, also performs the following operations: When the dual-task binary classification submodule of the preset BERT classification model detects that the current dialogue input has a change in intent or is not a follow-up question, the historical dialogue context is immediately cleared and the current dialogue input is directly output as an independent query.
[0028] The device of the present invention, through processor 1001 calling the medical dialogue search term rewriting program stored in memory 1005, also performs the following operations: When the dual-task binary classification submodule of the preset BERT classification model detects that no intent change has occurred and the current dialogue input is a follow-up question, the function of referential disambiguation and semantic completion is automatically triggered. Standard medical questions are generated based on the triggering of pronoun disambiguation and semantic completion functions.
[0029] The device of the present invention, through processor 1001 calling the medical dialogue search term rewriting program stored in memory 1005, also performs the following operations: The pronoun referencing object in the current dialogue input is identified based on the pronoun disambiguation function in the triggering pronoun disambiguation and semantic completion functions. Based on the historical context, the semantic completion function in the triggering referential disambiguation and semantic completion functions supplements the correct key medical information. The current dialogue input is processed based on the pronoun referent and the key medical information, and the processed data is formatted to generate a standard medical question.
[0030] The device of the present invention, through processor 1001 calling the medical dialogue search term rewriting program stored in memory 1005, also performs the following operations: If no intention change is detected in the current dialogue input, and no follow-up question is detected in the current dialogue input, the current input is directly output as the standard question.
[0031] This embodiment, through the above-described scheme, detects whether the current dialogue input is a follow-up question or an intent shift using a preset BERT classification model. When an intent shift or non-follow-up question is detected, the historical dialogue context is cleared and the current input is directly output as an independent query. When no intent shift is detected and the current dialogue input is a follow-up question, the functions of disambiguation and semantic completion are triggered to generate standard medical questions. This dynamically identifies changes in dialogue intent, accurately parses referential relationships, and generates standardized medical questions, avoiding interference from old contexts with new topics. It accurately standardizes medical terminology and generates semantically complete and standardized medical questions. This effectively solves the problem of search term rewriting distortion caused by improper context handling in medical dialogues, significantly improving vector recall in scenarios such as clinical decision support and intelligent triage, and increasing the speed and efficiency of medical dialogue search term rewriting.
[0032] Based on the above hardware structure, an embodiment of the medical dialogue search term rewriting method of the present invention is proposed.
[0033] Reference Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of the medical dialogue search term rewriting method of the present invention.
[0034] In the first embodiment, the medical dialogue search term rewriting method includes the following steps: Step S10: Detect whether the current dialogue input is a follow-up question or an intent jump occurs using a preset BERT classification model.
[0035] It should be noted that the detection is performed using a lightweight model that identifies multi-turn dialogue intent shifts and follow-up questions. Specifically, it uses a pre-set BERT classification model, namely a pre-set lightweight Bidirectional Transformer Representations from Transformers (BERT) classification model, to analyze in real time whether the current user input is a follow-up question or whether an intent shift has occurred, in order to accurately identify the contextual continuity or abrupt changes in medical dialogues.
[0036] Step S20: When it is detected that the current dialogue input has changed intent or is not a follow-up question, clear the historical dialogue context and output the current input directly as an independent query.
[0037] It should be understood that when a change in intent or a non-follow-up question is detected in the current dialogue input (e.g., a user suddenly switches from discussing diabetes treatment to consulting about lung cancer surgery), the historical dialogue context can be cleared and the current input can be directly output as an independent query. This ensures that the processing of new topics is not interfered with by the old context, thereby improving the accuracy and vector recall of medical searches.
[0038] Step S30: When it is detected that the current dialogue input has not changed its intent and the current dialogue input is a follow-up question, the function of referential disambiguation and semantic completion is triggered to generate a standard medical question.
[0039] Understandably, when it is confirmed that the current input is a follow-up question but no intention change occurs, the functions of referential disambiguation and semantic completion can be automatically triggered, calling the fine-tuned and rewritten large model to generate a standard medical question with complete semantics and standardized terminology.
[0040] This embodiment, through the above-described scheme, detects whether the current dialogue input is a follow-up question or an intent shift using a preset BERT classification model. When an intent shift or non-follow-up question is detected, the historical dialogue context is cleared and the current input is directly output as an independent query. When no intent shift is detected in the current dialogue input, and the current input is a follow-up question, the functions of disambiguation and semantic completion are triggered to generate standard medical questions. This not only accurately identifies contextual dependencies in user dialogues but also, when necessary, invokes a large model to perform deep semantic reconstruction, effectively solving the common problems of ambiguous expression and disambiguation in medical dialogues. Addressing issues such as ambiguity and topic jumps, this system combines lightweight model pre-judgment with large-scale model precise rewriting, balancing accuracy and efficiency. This represents a key technological breakthrough in improving the usability and professionalism of medical RAG systems. It can dynamically identify changes in dialogue intent, accurately parse referential relationships, and generate standardized medical questions, avoiding interference from old contexts with new topics. It accurately standardizes medical terminology, generating semantically complete and standardized medical questions. It effectively solves the problem of search term rewriting distortion caused by improper context handling in medical dialogues, significantly improving vector recall rates in scenarios such as clinical decision support and intelligent triage, and increasing the speed and efficiency of medical dialogue search term rewriting.
[0041] Furthermore, Figure 3 This is a flowchart illustrating the second embodiment of the medical dialogue search term rewriting method of the present invention, as shown below. Figure 3 As shown, based on the first embodiment, a second embodiment of the medical dialogue search term rewriting method of the present invention is proposed. In this embodiment, step S10 specifically includes the following steps: Step S11: Analyze the current dialogue input and historical dialogue context of the current user using a preset BERT classification model to determine whether the current dialogue input is a follow-up question or an intention change.
[0042] It should be noted that by using the preset BERT classification model, namely the preset lightweight bidirectional Transformer Representations from Transformers (BERT) classification model, the historical dialogue and the current dialogue input can be analyzed, and it can be determined whether the current dialogue input is a follow-up question or an intention change has occurred.
[0043] Furthermore, step S11 specifically includes the following steps: The last question from the historical dialogue is combined with the current dialogue input of the current user using the CLS separator to form a standardized input sequence; The standardized input sequence is input into a preset BERT classification model to obtain the key binary classification result; Based on the key binary classification results, determine whether the current dialogue input is a follow-up question or an intent shift has occurred.
[0044] Understandably, the last question from the historical dialogue is combined with the current user input, starting with the [CLS] marker and separated by the [SEP] separator, to form a standardized input sequence: [CLS]historical question [SEP]current input [SEP]. This sequence is then fed into a pre-defined lightweight BERT classification model. This model uses a dual-classification head to simultaneously output binary classification results indicating whether it is a follow-up question (is_follow_up) and whether an intent jump has occurred (has_intent_jump), thereby accurately determining the contextual attributes of the current dialogue input in real time.
[0045] In its specific implementation, the hierarchical search term rewriting architecture of this embodiment includes two core modules: 1. Multi-turn dialogue intent jump and follow-up detection module.
[0046] 2. Coref Resolution & Query ExpansionModule, a module for rewriting disambiguation and semantic completion.
[0047] Module 1: Multi-turn Dialogue Intent Shift and Follow-up Question Recognition (BERT Binary Classification Model) (1) Task definition Construct a dual-task binary classification model to determine two questions: Task A: Is this a follow-up question? Task B: Did an intent jump occur? Example: Q1: What are the adjuvant therapies after gastric cancer surgery? Q2: "What about those with high PD-L1 levels?" → This is a follow-up question, without a jump. Q3: "How should diabetics eat?" → This is not a follow-up question, but a jump.
[0048] (2) Model structure Lightweight BERT models (such as BERT-Tiny and DistilBERT) are suitable for high-concurrency, low-latency scenarios. Input format: [CLS] Last question in the history of the conversation [SEP] Current user input [SEP] Output two independent classification headers: is_follow_up: 0 / 1 (Is this a follow-up question?) has_intent_jump: 0 / 1 (whether a jump is intended) Training data construction (based on large model sample augmentation) Generate large-scale labeled datasets using strong language models (such as GPT-4, Claude 3, etc.): You are a data annotation expert. Please determine whether there is a "follow-up question relationship" and an "intent jump" between the following two sentences, and output the result in JSON format.
[0049] Example 1: What are the first-line treatment options for advanced gastric cancer? Can PD-L121 be used for immunization? Output:{"is follow up": 1,"has intent jump":0} Example 2: Q1: What should I eat after stomach cancer surgery? Q2: Can diabetics drink milk? Output:{"is follow up": 0,"has intent jump":1} Covering multiple medical scenarios: Follow-up questions ("Then...", "If...", "And...") and counter-questions ("Does that mean...").
[0050] Intent shifts (across diseases, across departments, from treatment to cost) are context-independent (independent new questions).
[0051] Ultimately, we constructed over 100,000 high-quality labeled samples for fine-tuning the BERT mini-model.
[0052] This embodiment uses the above-described scheme to analyze the current user's current dialogue input and historical dialogue context using a preset BERT classification model. It determines whether the current dialogue input is a follow-up question or an intent shift, enabling accurate real-time binary judgment of follow-up questions and intent shifts. This provides a reliable decision-making basis for the subsequent search term rewriting process, effectively avoiding rewriting distortion caused by contextual interference, thereby improving the recall rate of medical search vectors in clinical auxiliary decision-making scenarios.
[0053] Furthermore, Figure 4 This is a flowchart illustrating the third embodiment of the medical dialogue search term rewriting method of the present invention, as shown below. Figure 4 As shown, based on the first embodiment, a third embodiment of the medical dialogue search term rewriting method of the present invention is proposed. In this embodiment, step S20 specifically includes the following steps: Step S21: When the dual-task binary classification submodule of the preset BERT classification model detects that the current dialogue input has a change in intent or is not a follow-up question, the historical dialogue context is immediately cleared and the current dialogue input is directly output as an independent query.
[0054] It should be noted that when the dual-task binary classification submodule of the preset BERT classification model (through the has_intent_jump binary classification result) detects that the current dialogue input has a change in intent or is not a follow-up question (for example, the user suddenly switches from discussing "diabetes treatment" to "lung cancer surgery costs" or cross-departmental consultation), it can immediately clear the historical dialogue context and output the current input as an independent query. This effectively eliminates the interference of historical context on new topics and ensures that the medical search system performs accurate matching based on the latest and unrelated queries, thereby significantly improving the vector recall rate in clinical scenarios.
[0055] In the specific implementation, the reasoning logic is as follows: if has_intent_jump: # Intended to redirect, clear history conversation final_query = current_input elif is_follow_up: # This is a follow-up question; preserve the context and proceed to the next step of rewriting. final_query = rewrite_module(current_input, history_last_turn) else: # No follow-up question or jump → This may be a new topic or irrelevant input. final_query = current_input This embodiment, through the above-described scheme, detects a change in intent or a non-follow-up question in the current dialogue input via the dual-task binary classification submodule of the preset BERT classification model. It immediately clears the historical dialogue context and outputs the current dialogue input as an independent query. This effectively eliminates interference from historical context on new topics, ensuring that the medical search system performs accurate matching based on the latest, unrelated queries. This significantly improves vector recall in scenarios such as clinical decision support and intelligent triage.
[0056] Furthermore, Figure 5 This is a flowchart illustrating the fourth embodiment of the medical dialogue search term rewriting method of the present invention, as shown below. Figure 5 As shown, based on the first embodiment, a fourth embodiment of the medical dialogue search term rewriting method of the present invention is proposed. In this embodiment, step S30 specifically includes the following steps: Step S31: When the dual-task binary classification submodule of the preset BERT classification model detects that no intent change has occurred and the current dialogue input is a follow-up question, the function of referential disambiguation and semantic completion is automatically triggered.
[0057] It should be noted that when the dual-task binary classification submodule of the preset BERT classification model does not detect an intent jump (has_intent_jump=0) and the current input is a follow-up question (such as the user inputting "What is the effect of this medicine?" or "If so, what should be done next?"), the proxy disambiguation and semantic completion modules are automatically triggered, and the proxy disambiguation function and semantic completion function are triggered accordingly.
[0058] Step S32: Generate standard medical questions based on the triggering of the referential disambiguation and semantic completion functions.
[0059] Understandably, when a follow-up question is detected, the pronoun disambiguation function can be triggered to accurately identify the pronoun's referent (e.g., "this" refers to "PD-1 inhibitor" explicitly mentioned in the historical dialogue), and the pronoun disambiguation and semantic completion functions can be triggered to supplement the missing medical context information (e.g., treatment line number, disease stage), ultimately generating a standard medical question that is semantically complete, terminologically standardized, and strictly based on the dialogue history (e.g., "How effective are PD-1 inhibitors in second-line treatment of advanced non-small cell lung cancer?").
[0060] Furthermore, step S32 specifically includes the following steps: The pronoun referencing object in the current dialogue input is identified based on the pronoun disambiguation function in the triggering pronoun disambiguation and semantic completion functions. Based on the historical context, the semantic completion function in the triggering referential disambiguation and semantic completion functions supplements the correct key medical information. The current dialogue input is processed based on the pronoun referent and the key medical information, and the processed data is formatted to generate a standard medical question.
[0061] In its implementation, the system accurately identifies the pronouns in the input (e.g., "this" refers to "PD-1 inhibitor" explicitly mentioned in the historical dialogue). Then, it supplements the missing key medical information based on the historical context (e.g., adding the stage and treatment line number for "used as second-line treatment for advanced non-small cell lung cancer"). Finally, the processed question is transformed into a standard question conforming to the "Medical Terminology Standard" (e.g., "What are the efficacy and safety of PD-1 inhibitors in second-line treatment for advanced non-small cell lung cancer?"). This ensures that the output is semantically complete, uses standardized terminology, and is strictly limited to medical entities already mentioned in the dialogue history, preventing the addition of unmentioned information and providing the medical search system with highly recallable and accurate queries.
[0062] Furthermore, after step S30, the medical dialogue search term rewriting method further includes the following steps: If no intention change is detected in the current dialogue input, and no follow-up question is detected in the current dialogue input, the current input is directly output as the standard question.
[0063] It should be noted that when it is confirmed that the current dialogue input has neither changed intent (e.g., the user has not switched from "hypertension management" to "kidney disease treatment" or is not a follow-up question (e.g., the input is an independent question "What are the latest guidelines for chronic obstructive pulmonary disease?" rather than "Is this treatment effective?"), the original user input is directly retained as the standard question output without any semantic modification or contextual processing. This ensures that the medical search system can accurately match the medical knowledge base with minimal latency, while avoiding query distortion caused by excessive intervention. This maintains a high accuracy vector recall effect and meets the stringent real-time requirements of clinical scenarios.
[0064] In the specific implementation, the module for joint rewriting of pronoun disambiguation and semantic completion is as follows: 1) Functional Objectives Fragmented and ambiguous user input is transformed into standard medical questions that are semantically complete, have standardized terminology, and are searchable.
[0065] For example: Type: "Does this medicine have many side effects?" Output: "What is the incidence of adverse reactions to pembrolizumab in patients with HER2-positive gastric cancer?" few?" Enter: "Does HER2-positive individuals need immunization?" Output: "Is PD-1 inhibitor recommended as first-line treatment for patients with HER2-positive advanced gastric cancer?" Type: "Can he still receive chemotherapy?" Output: "This patient developed bone marrow suppression after two lines of treatment. Can they still tolerate a third line of chemotherapy?" Implementation method: Large model fine-tuning + sample augmentation Base model selection: Select large open-source models (such as Qwen-7B, ChatGLM3-6B) for fine-tuning; Training data generation: High-quality instruction fine-tuning datasets are built using more powerful API models (such as GPT-4-Turbo and Claude 3Opus); (3) Prompt for project template (used for sample generation): You are a senior medical AI engineer. Based on the following dialogue history and current user input, please complete three tasks: 1. Perform pronoun disambiguation: clarify the referents of pronouns such as "this," "he," and "that"; 2. Perform semantic completion: supplement missing medical context (such as staging, biomarkers, treatment lines); 3. Output a semantically complete and terminologically correct standard medical question.
[0066] Require: Use formal medical terminology. No information not mentioned in the original text will be added; Keep the original meaning unchanged.
[0067] [Historical Dialogue] Doctor: The patient has HER2-positive advanced gastric cancer and has already received trastuzumab combined with chemotherapy.
[0068] [Current Input] Is this drug highly toxic to the heart? Output: "What are the incidence and monitoring recommendations for cardiotoxicity of trastuzumab in patients with HER2-positive advanced gastric cancer?" (4) Fine-tuning dataset composition Field: input Content: History of conversations + Current input Field: output Content: Standardized complete questions Field: task_type Content: Follow-up questions / continued questions / rewritten / no rewriting required A total of 50,000 high-quality samples were generated, covering: Drug reference disambiguation Patient status restoration ("he" → "the patient") Standardize terminology ("immunotherapy drugs" → "PD-1 / PD-L1 inhibitors") and complete the scenario ("Should we use it?" → "Is it recommended for first-line treatment?"). (5) Deployment method The finely tuned model is deployed as a service (such as vLLM, Triton Inference Server). Input: Current query + previous context; Output: The rewritten standard question.
[0069] Taking a gastric cancer question-and-answer system as an example: Scenario 1: Disambiguation of pronouns + follow-up questions Q1: "How effective is nivolumab in patients with high PD-L1 expression?" Q2: "What about the heart side effects?" Processing flow: 1. Intent model judgment: is_follow_up=1, has_intent_jump=0; 2. Trigger the rewrite module → Output: "What is the incidence of cardiovascular adverse reactions in patients with nivolumab-overexpressing gastric cancer?" 3. Submit to Milvus search → Returns CheckMate-649 security data Scenario 2: Intent shift Q1: "What dietary precautions should be taken after stomach cancer surgery?" Q2: "Can diabetics eat fruit?" Procedure: 1. Intent model judgment: has_intent_jump=1; 2. Clear history → Search directly using "Can diabetics eat fruit?"
[0070] 3. Avoid incorrect association with the "post-gastric cancer surgery" background.
[0071] Scenario 3: No rewriting required Q1: "Do the NCCN guidelines recommend first-line treatment for HER2-positive gastric cancer?" Q2: "What is the level of evidence?" Rewrite the output: "What is the level of evidence for the first-line treatment recommendation for HER2-positive gastric cancer in the NCCN guidelines?" Maintain the original meaning, only complete the subject.
[0072] This embodiment employs a three-tiered linkage mechanism of intent jump recognition, referential disambiguation, and semantic completion. This mechanism not only accurately identifies contextual dependencies in user dialogues but also invokes a large model to perform deep semantic reconstruction when necessary. This effectively solves common problems in medical dialogues such as ambiguous expressions, unclear referentials, and topic jumps. By combining lightweight model pre-judgment with precise rewriting of the large model, it balances accuracy and efficiency, representing a key technological breakthrough in improving the usability and professionalism of medical RAG systems.
[0073] This embodiment, through the above-described scheme, detects whether the current dialogue input is a follow-up question or an intent shift using a preset BERT classification model. When an intent shift or non-follow-up question is detected, the historical dialogue context is cleared and the current input is directly output as an independent query. When no intent shift is detected and the current dialogue input is a follow-up question, the functions of disambiguation and semantic completion are triggered to generate standard medical questions. This dynamically identifies changes in dialogue intent, accurately parses referential relationships, and generates standardized medical questions, avoiding interference from old contexts with new topics. It accurately standardizes medical terminology and generates semantically complete and standardized medical questions. This effectively solves the problem of search term rewriting distortion caused by improper context handling in medical dialogues, significantly improving vector recall in scenarios such as clinical decision support and intelligent triage, and increasing the speed and efficiency of medical dialogue search term rewriting.
[0074] Accordingly, the present invention further provides a medical dialogue search term rewriting device.
[0075] Reference Figure 6 , Figure 6 This is a functional block diagram of the first embodiment of the medical dialogue search term rewriting device of the present invention.
[0076] In a first embodiment of the medical dialogue search term rewriting device of the present invention, the medical dialogue search term rewriting device includes: The detection module 10 is used to detect whether the current dialogue input is a follow-up question or an intention change has occurred through a preset BERT classification model.
[0077] The clearing module 20 is used to clear the historical dialogue context and output the current input as an independent query when it is detected that the current dialogue input has a change of intent or is not a follow-up question. The standard medical question module 30 is used to trigger the referential disambiguation and semantic completion functions to generate a standard medical question when it is detected that the current dialogue input has not undergone an intent jump and the current dialogue input is a follow-up question.
[0078] The detection module 10 is also used to analyze the current dialogue input and historical dialogue context of the current user through a preset BERT classification model to determine whether the current dialogue input is a follow-up question or an intention change.
[0079] The detection module 10 is further configured to combine the last round question of the historical dialogue with the current dialogue input of the current user using the CLS separator to form a standardized input sequence; input the standardized input sequence into a preset BERT classification model to obtain a key binary classification result; and determine whether the current dialogue input is a follow-up question or an intent jump based on the key binary classification result.
[0080] The clearing module 20 is also used to immediately clear the historical dialogue context and output the current dialogue input as an independent query when the dual-task binary classification submodule of the preset BERT classification model detects that the current dialogue input has a change in intent or is not a follow-up question.
[0081] The standard medical question module 30 is also used to automatically trigger the referential disambiguation and semantic completion functions when the dual-task binary classification submodule of the preset BERT classification model detects that no intention change has occurred and the current dialogue input is a follow-up question; and to generate a standard medical question based on the triggered referential disambiguation and semantic completion functions.
[0082] The standard medical question module 30 is further configured to identify the pronoun referent in the current dialogue input based on the pronoun disambiguation function in the triggering pronoun disambiguation and semantic completion function; supplement the correct medical key information based on the historical context based on the semantic completion function in the triggering pronoun disambiguation and semantic completion function; process the current dialogue input based on the pronoun referent and the medical key information; convert the format of the processed data; and generate a standard medical question.
[0083] The standard medical question module 30 is also used to directly output the current input as a standard question when no intention change is detected in the current dialogue input and no follow-up question is detected in the current dialogue input.
[0084] The steps for implementing each functional module of the medical dialogue search term rewriting device can be referred to in the various embodiments of the medical dialogue search term rewriting method of the present invention, and will not be repeated here.
[0085] Furthermore, embodiments of the present invention also propose a storage medium storing a medical dialogue search term rewriting program, which, when executed by a processor, performs the following operations: The system uses a pre-defined BERT classification model to detect whether the current dialogue input is a follow-up question or a change in intent. When it is detected that the current dialogue input has a change of intent or is not a follow-up question, the historical dialogue context is cleared and the current input is directly output as an independent query. When it is detected that the current dialogue input has not changed its intent and is a follow-up question, the function of referential disambiguation and semantic completion is triggered to generate a standard medical question.
[0086] Furthermore, when the medical dialogue search term rewriting program is executed by the processor, it also performs the following operations: The current dialogue input and historical dialogue context of the current user are analyzed by a preset BERT classification model to determine whether the current dialogue input is a follow-up question or an intention change.
[0087] Furthermore, when the medical dialogue search term rewriting program is executed by the processor, it also performs the following operations: The last question from the historical dialogue is combined with the current dialogue input of the current user using the CLS separator to form a standardized input sequence; The standardized input sequence is input into a preset BERT classification model to obtain the key binary classification result; Based on the key binary classification results, determine whether the current dialogue input is a follow-up question or an intent shift has occurred.
[0088] Furthermore, when the medical dialogue search term rewriting program is executed by the processor, it also performs the following operations: When the dual-task binary classification submodule of the preset BERT classification model detects that the current dialogue input has a change in intent or is not a follow-up question, the historical dialogue context is immediately cleared and the current dialogue input is directly output as an independent query.
[0089] Furthermore, when the medical dialogue search term rewriting program is executed by the processor, it also performs the following operations: When the dual-task binary classification submodule of the preset BERT classification model detects that no intent change has occurred and the current dialogue input is a follow-up question, the function of referential disambiguation and semantic completion is automatically triggered. Standard medical questions are generated based on the triggering of pronoun disambiguation and semantic completion functions.
[0090] Furthermore, when the medical dialogue search term rewriting program is executed by the processor, it also performs the following operations: The pronoun referencing object in the current dialogue input is identified based on the pronoun disambiguation function in the triggering pronoun disambiguation and semantic completion functions. Based on the historical context, the semantic completion function in the triggering referential disambiguation and semantic completion functions supplements the correct key medical information. The current dialogue input is processed based on the pronoun referent and the key medical information, and the processed data is formatted to generate a standard medical question.
[0091] Furthermore, when the medical dialogue search term rewriting program is executed by the processor, it also performs the following operations: If no intention change is detected in the current dialogue input, and no follow-up question is detected in the current dialogue input, the current input is directly output as the standard question.
[0092] Those skilled in the art will understand that all or part of the steps in the methods described above can be implemented by a program instructing related hardware. The program is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium is a computer-readable storage medium, including: USB flash drive, mobile hard drive, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk, and other media that can store program code.
[0093] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0094] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0095] The above are merely preferred embodiments of the present invention and do not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A method for rewriting medical dialogue search terms, characterized in that, The method for rewriting medical dialogue search terms includes: The system uses a pre-defined BERT classification model to detect whether the current dialogue input is a follow-up question or a change in intent. When it is detected that the current dialogue input has a change of intent or is not a follow-up question, the historical dialogue context is cleared and the current input is directly output as an independent query. When it is detected that the current dialogue input has not changed its intent and is a follow-up question, the function of referential disambiguation and semantic completion is triggered to generate a standard medical question.
2. The medical dialogue search term rewriting method as described in claim 1, characterized in that, The step of detecting whether the current dialogue input is a follow-up question or an intention shift using a preset BERT classification model includes: The current dialogue input and historical dialogue context of the current user are analyzed by a preset BERT classification model to determine whether the current dialogue input is a follow-up question or an intention change.
3. The medical dialogue search term rewriting method as described in claim 2, characterized in that, The step of analyzing the current user's current dialogue input and historical dialogue context using a pre-set BERT classification model to determine whether the current dialogue input is a follow-up question or an intention shift includes: The last question from the historical dialogue is combined with the current dialogue input of the current user using the CLS separator to form a standardized input sequence; The standardized input sequence is input into a preset BERT classification model to obtain the key binary classification result; Based on the key binary classification results, determine whether the current dialogue input is a follow-up question or an intent shift has occurred.
4. The medical dialogue search term rewriting method as described in claim 1, characterized in that, The step of clearing the historical dialogue context and directly outputting the current input as an independent query when the intent of the current dialogue input changes or is not a follow-up question includes: When the dual-task binary classification submodule of the preset BERT classification model detects that the current dialogue input has a change in intent or is not a follow-up question, the historical dialogue context is immediately cleared and the current dialogue input is directly output as an independent query.
5. The medical dialogue search term rewriting method as described in claim 1, characterized in that, When it is detected that the current dialogue input has not undergone an intent shift and is a follow-up question, the function of referential disambiguation and semantic completion is triggered to generate a standard medical question, including: When the dual-task binary classification submodule of the preset BERT classification model detects that no intent change has occurred and the current dialogue input is a follow-up question, the function of referential disambiguation and semantic completion is automatically triggered. Standard medical questions are generated based on the triggering of pronoun disambiguation and semantic completion functions.
6. The medical dialogue search term rewriting method as described in claim 5, characterized in that, The generation of standard medical questions based on the triggered referential disambiguation and semantic completion functions includes: The pronoun referencing object in the current dialogue input is identified based on the pronoun disambiguation function in the triggering pronoun disambiguation and semantic completion functions. Based on the historical context, the semantic completion function in the triggering referential disambiguation and semantic completion functions supplements the correct key medical information. The current dialogue input is processed based on the pronoun referent and the key medical information, and the processed data is formatted to generate a standard medical question.
7. The method for rewriting medical dialogue search terms as described in claim 1, characterized in that, The method for rewriting medical dialogue search terms further includes the following: After detecting that the current dialogue input does not involve an intent shift and is a follow-up question, triggering the referential disambiguation and semantic completion functions to generate a standard medical question, the method also includes: If no intention change is detected in the current dialogue input, and no follow-up question is detected in the current dialogue input, the current input is directly output as the standard question.
8. A medical dialogue search term rewriting device, characterized in that, The medical dialogue search term rewriting device includes: The detection module is used to detect whether the current dialogue input is a follow-up question or an intention change has occurred using a preset BERT classification model; The clear module is used to clear the historical dialogue context and output the current input directly as an independent query when it is detected that the current dialogue input has changed its intent or is not a follow-up question; The standard medical question module is used to generate standard medical questions when it is detected that the current dialogue input has not undergone an intent change and the current dialogue input is a follow-up question, triggering the functions of referential disambiguation and semantic completion.
9. A medical dialogue search term rewriting device, characterized in that, The medical dialogue search term rewriting device includes: a memory, a processor, and a medical dialogue search term rewriting program stored in the memory and executable on the processor, the medical dialogue search term rewriting program being configured to implement the steps of the medical dialogue search term rewriting method as described in any one of claims 1 to 7.
10. A storage medium, characterized in that, The storage medium stores a medical dialogue search term rewriting program, which, when executed by a processor, implements the steps of the medical dialogue search term rewriting method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Question and answer method and device based on large model
CN118885579A
Multi-round dialogue model training method and device, electronic equipment and storage medium
CN119128105A
Input rewriting method and device of intelligent question answering system and computer equipment
CN119782485A
Multi-round dialogue generation method and device based on RAG and medium
CN120407737A
Response method and device based on deep learning, equipment and medium
CN120632026A
Cited By
Medical question and answer service method and system based on artificial intelligence
CN122087068A
Medical dialogue method and system based on intention jump recognition and semantic completion
CN122112211A
A medical conversation method and system based on intention jump recognition and semantic completion
CN122112211B