Doctor diagnosis and treatment risk detection method and device for doctor-patient conversation text

CN122950100APending Publication Date: 2026-10-20ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610985796.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-02
Publication Date
2026-10-20

Smart Images

  • Figure FT_1
    Figure FT_1
  • Figure FT_2
    Figure FT_2
  • Figure FT_3
    Figure FT_3
Patent Text Reader

Abstract

This specification provides a method and apparatus for detecting physician diagnosis and treatment risks based on doctor-patient dialogue text. The method includes: using a large language model to perform semantic extraction processing on the doctor-patient dialogue text to generate several atomized medical statements; each atomized medical statement expresses a physician's claim under a single medical fact, and the atomized medical statements are semantically independent; inputting any atomized medical statement into the large language model for initial risk assessment to obtain an initial assessment result; if the initial assessment result belongs to the deterministic category, it is determined as the risk assessment conclusion of the atomized medical statement; if the initial assessment result belongs to the uncertain category, a retrieval-enhanced reasoning process is triggered; including using the large language model to generate structured retrieval instructions, retrieving several knowledge fragments from a medical knowledge base based on the structured retrieval instructions, and combining the several knowledge fragments with the large language model to obtain the risk assessment conclusion and reasoning basis of the atomized medical statement.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification relates to one or more embodiments in the field of medical information technology and artificial intelligence-assisted diagnosis and treatment, and in particular to a method and apparatus for detecting physician diagnosis and treatment risks based on doctor-patient dialogue text. Background Technology

[0002] With the widespread adoption of telemedicine services, text-based dialogues between doctors and patients have become an important form of clinical diagnosis and treatment. To ensure patient safety, real-time risk monitoring of doctors' diagnostic and treatment behaviors during these dialogues (such as identifying medication contraindications, dosage errors, and inappropriate diagnoses) is particularly crucial.

[0003] Current risk detection technologies, often based on Large Language Models (LLMs), still face significant technical bottlenecks when dealing with real-world telemedicine scenarios. Firstly, they struggle to effectively handle lengthy, highly dependent, and complex clinical dialogues. Telemedicine dialogues are typically multi-turn, unstructured, and crucial diagnostic information (such as specific medication recommendations and diagnostic criteria) is often scattered throughout the long dialogue history, heavily relying on contextual information such as "this medication," "this symptom," and "that dosage." When processing such long texts, existing LLMs are prone to extracting incorrect entities when the dialogue length exceeds the model's effective attention range or when pronoun referential relationships are complex. This makes the model susceptible to irrelevant noise in the dialogue, hindering its ability to accurately identify potential diagnostic risks within complex logical chains. Secondly, existing risk assessment processes lack transparency and interpretability, making it difficult to gain clinical trust. Medical risk monitoring not only requires accurate conclusions but also clear reasoning for physician review. However, existing large language models typically output "risky" or "no risk" conclusions directly, lacking interpretability. Doctors cannot confirm whether the model is producing "hallucinations" (i.e., fabricating non-existent medical facts).

[0004] Therefore, there is a need to provide an improved approach to accurately identify potential diagnostic and treatment risks and to make the risk detection results interpretable. Summary of the Invention

[0005] This specification describes one or more embodiments of a method and apparatus for detecting medical risks in doctor-patient dialogue text, which can accurately identify potential medical risks and make the risk detection results interpretable.

[0006] Firstly, a method for detecting physician diagnosis and treatment risks based on doctor-patient dialogue texts is provided, including:

[0007] A large language model is used to extract semantics from doctor-patient dialogue texts to generate several atomized medical statements; each atomized medical statement expresses a doctor's claim under a single medical fact, and the atomized medical statements are semantically independent.

[0008] Input any of the aforementioned atomic medicine statements into the large language model for initial risk assessment to obtain initial assessment results; wherein, the initial assessment results include multiple risk assessment categories, and the multiple risk assessment categories include at least a deterministic category and an uncertain category;

[0009] If the initial assessment result belongs to the deterministic category, then the initial assessment result is determined as the risk assessment conclusion of the atomized medicine statement;

[0010] If the initial assessment result belongs to the uncertainty category, the retrieval enhancement reasoning process is triggered. The retrieval enhancement reasoning process includes generating a structured retrieval instruction using the large language model, recalling several knowledge fragments from the medical knowledge base based on the structured retrieval instruction, and combining the several knowledge fragments with the large language model to obtain the risk assessment conclusion and reasoning basis of the atomized medical statement.

[0011] In one possible implementation, the semantic extraction processing of the doctor-patient dialogue text using a large language model to generate several atomized medical statements includes:

[0012] Input the first prompt word and the doctor-patient dialogue text into the big language model, instructing the big language model to extract multiple treatment suggestions from the doctor's utterance as multiple initial atomic expressions;

[0013] Input the second prompt word and the doctor-patient dialogue text into the big language model, instructing the big language model to extract the patient's objective profile information;

[0014] The third prompt word, the doctor-patient dialogue text, the objective profile information, and the multiple initial atomic expressions are input into the large language model, and the large language model is instructed to use the objective profile information to perform semantic completion and rewrite of the initial atomic expressions to generate multiple candidate statements of the doctor-patient dialogue text without context.

[0015] The fourth prompt word, the doctor-patient dialogue text, and the multiple candidate statements are input into the large language model, which is then instructed to filter out candidate statements of a preset type that are not suitable for risk identification, and to treat each remaining candidate statement as an atomic medical statement.

[0016] Furthermore, the first, second, third, or fourth prompt word includes role definition, task boundaries, input content specifications, and output format constraints.

[0017] In one possible implementation, the structured retrieval instruction is structured data containing the following fields:

[0018] The query keyword field is used to store medical entity names and their extended names;

[0019] The target knowledge domain field is used to identify the type of target database to be retrieved, including drug databases or disease databases.

[0020] The metadata field is used to specify the information dimensions that need to be focused on after the search.

[0021] Furthermore, the retrieval of several knowledge fragments from a preset medical knowledge base based on the structured retrieval instructions includes:

[0022] The target knowledge domain field in the structured search instruction is parsed to determine whether the target database for the search is a drug database or a disease database.

[0023] Using the medical entity names and their extended names in the query keyword field, an index retrieval based on term matching is performed in the target database to recall the top K relevant knowledge fragments.

[0024] Furthermore, the risk assessment conclusion and reasoning basis for obtaining the atomized medicine statement by combining the aforementioned knowledge fragments and utilizing the large language model include:

[0025] The knowledge fragments, the atomic medicine statement, and the retrieval metadata field in the structured retrieval instruction are input into the large language model. The large language model is used to determine the relevance between the knowledge fragments and the atomic medicine statement. Based on the information dimensions specified by the retrieval metadata field, several pieces of evidence are extracted from the relevant knowledge fragments.

[0026] The aforementioned evidence and the atomized medicine statement are input into the large language model, and the risk assessment conclusion and reasoning basis of the atomized medicine statement are obtained using the large language model.

[0027] Furthermore, the risk assessment conclusions and reasoning basis for obtaining the atomized medical statement using the large language model include:

[0028] The large language model is used to evaluate whether the evidence is sufficient to support a definitive risk assessment.

[0029] If the evidence is deemed insufficient, the query keyword field or retrieval metadata field in the structured retrieval instruction is corrected using the large language model, and steps are performed to retrieve knowledge fragments from the preset medical knowledge base, extract evidence, and assess the sufficiency of the evidence.

[0030] If the evidence is deemed sufficient, the large language model is used to generate the reasoning basis and risk assessment conclusion.

[0031] In one possible implementation, the large language model is a policy model obtained through reinforcement learning training; the reinforcement learning training process includes:

[0032] Obtain several pre-generated training sample pairs; wherein each training sample pair includes a risk-free sample and a risky sample, the risky sample being generated by perturbing at least one information dimension of the risk-free sample;

[0033] The grouping relative strategy optimization algorithm is used to calculate the advantage function value based on the total reward value of multiple outputs corresponding to the same group of inputs, and the parameters of the large language model are updated according to the advantage function value; wherein, the reward value of each output is determined comprehensively based on the format compliance of the output content and the accuracy of the risk assessment conclusion.

[0034] Furthermore, the reward value for each output is determined in the following manner:

[0035] The output of the large language model is checked. If the output does not conform to the predefined format, a first negative reward value is given.

[0036] If the output conforms to the predefined format, the risk assessment conclusion output by the large language model will be compared with the risk labels of the training samples.

[0037] If the comparison results match, a positive reward value or a zero reward value will be given; if the comparison results do not match, a second negative reward value will be given.

[0038] Furthermore, the predefined format includes:

[0039] The output of the risk assessment conclusion is required to include a preset start identifier and an end identifier, and the content between the start identifier and the end identifier is one of a number of preset level symbols;

[0040] The output of structured search commands must be in a predefined structured data format and contain a non-empty query string and predefined domain enumeration values.

[0041] The output of evidence should include a string-type summary content field and an array-type evidence source field.

[0042] In one possible implementation, the medical knowledge base includes a disease database and a drug database; the disease database stores entries related to disease names, and the drug database stores entries related to drug names.

[0043] Secondly, a doctor's diagnosis and treatment risk detection device based on doctor-patient dialogue text is provided, including:

[0044] The semantic extraction unit is used to perform semantic extraction processing on the doctor-patient dialogue text using a large language model to generate several atomized medical statements; wherein, each atomized medical statement expresses the doctor's claim under a single medical fact, and the atomized medical statements are semantically independent.

[0045] An initial assessment unit is used to input any of the atomic medical statements obtained by the semantic extraction unit into the large language model for initial risk assessment, and obtain an initial assessment result; wherein, the initial assessment result includes multiple risk assessment categories, and the multiple risk assessment categories include at least a deterministic category and an uncertain category;

[0046] A determining unit is configured to determine the initial assessment result as the risk assessment conclusion of the atomized medicine statement if the initial assessment result obtained by the initial assessment unit belongs to the deterministic category.

[0047] An enhanced reasoning unit is used to trigger a retrieval enhanced reasoning process if the initial assessment result obtained by the initial assessment unit belongs to the uncertainty category. The retrieval enhanced reasoning process includes generating a structured retrieval instruction using the large language model, recalling several knowledge fragments from the medical knowledge base based on the structured retrieval instruction, and combining the several knowledge fragments with the large language model to obtain the risk assessment conclusion and reasoning basis of the atomized medical statement.

[0048] Thirdly, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the method of the first aspect.

[0049] Fourthly, a computing device is provided, including a memory and a processor, wherein the memory stores executable code, and the processor executes the executable code to implement the method of the first aspect.

[0050] The methods and apparatus provided in the embodiments of this specification utilize a large language model to reconstruct lengthy and context-dependent complex doctor-patient dialogues into semantically independent and clearly defined atomized medical statements, eliminating risk omissions and misjudgments caused by attention distraction and unclear pronoun references in long texts from the source. Furthermore, a confidence-based dynamic routing mechanism is introduced, triggering the retrieval enhancement reasoning process only for statements with uncertain knowledge within the model. Structured retrieval instructions are generated using an external authoritative knowledge base, and knowledge fragments are recalled. This effectively overcomes the "overconfidence bias" and "illusion" problems of large models, while avoiding the inefficiency and noise interference caused by full retrieval. Finally, by outputting the reasoning basis generated based on the retrieved knowledge fragments, a transformation from "black-box judgment" to "white-box verification" is achieved, thereby accurately identifying potential diagnostic and treatment risks and making the risk detection results interpretable. Attached Figure Description

[0051] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. 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.

[0052] Figure 1 This is a schematic diagram illustrating an implementation scenario of one embodiment disclosed in this specification;

[0053] Figure 2 A flowchart of a physician diagnosis risk detection method for doctor-patient dialogue text is shown according to one embodiment;

[0054] Figure 3 A flowchart of a retrieval-enhanced reasoning method according to one embodiment is shown;

[0055] Figure 4 This diagram illustrates a reinforcement learning optimization process according to one embodiment.

[0056] Figure 5 A schematic block diagram of a physician diagnosis risk detection device based on a doctor-patient dialogue text, according to one embodiment, is shown. Detailed Implementation

[0057] The solution provided in this specification will now be described with reference to the accompanying drawings.

[0058] Figure 1 This is a schematic diagram illustrating an implementation scenario of one embodiment disclosed in this specification. This implementation scenario involves physician risk detection based on doctor-patient dialogue text; specifically, the doctor-patient dialogue text can be a multi-turn text conversation between a doctor and a patient. (Refer to...) Figure 1The aforementioned risk detection for physician diagnosis and treatment can be applied to scenarios such as telemedicine consultations. In these scenarios, doctors and patients typically engage in multi-round interactions via text or voice-to-text, generating a large amount of unstructured dialogue data. To ensure medical safety, it is necessary to monitor telemedicine consultations and proactively flag risks in diagnoses, prescriptions, and other clinical dialogues. For example, whether there are potential risks in the diagnostic suggestions and medication instructions given by doctors (such as drug interactions, contraindication conflicts, dosage errors, etc.). However, directly using large language models for risk detection faces significant technical obstacles, mainly due to the strong contextual dependence of long texts, ambiguous pronoun references, and a lack of interpretability in the reasoning process.

[0059] Figure 1 illustrates a typical online consultation interface and a multi-turn dialogue process. In this scenario, the doctor initially presents a complex dialogue text containing a disease diagnosis ("infectious rash") and two treatment options ("oral cetirizine drops" and "topical calamine lotion"). Subsequently, in subsequent rounds of questioning, the patient does not repeat specific drug names but instead uses numerous context-dependent pronouns or colloquial expressions. For ease of description, [the text is incomplete and requires further context to translate accurately]. Figure 1 The long text of the doctor-patient dialogue is divided in chronological order, referred to as the first round of dialogue, the second round of dialogue, and so on up to the sixth round of dialogue.

[0060] In the third round of dialogue shown in Figure 1, the doctor suggested "continuing to take the oral medication." Here, "oral medication" is a typical implicit reference, specifically referring to "cetirizine drops" in the first round of dialogue. If this referential relationship cannot be accurately traced and analyzed across the long dialogue history, the specific object of verification cannot be identified, and therefore it's impossible to determine whether the medication interacts with other medications the patient is taking (such as "other liquids" the patient might mention), leading to missed risks. Similarly, in the fourth round of dialogue, the patient asked, "Can I apply the ointment to my face?" The term "ointment" used by the patient is colloquial, actually referring to the "calamine lotion" (usually a suspension rather than a paste) previously prescribed by the doctor. Without semantic alignment capabilities, directly searching or judging using "ointment" as a keyword may match incorrect drug knowledge base entries, resulting in misjudgment. Furthermore, in the sixth round of dialogue, "drops" again refers to "cetirizine drops." This phenomenon of key information being scattered across multiple rounds of dialogue makes it difficult for traditional single-scan processing to fully extract risk elements.

[0061] Faced with the complex referentiality and scattered information mentioned above, the detection results of large language models are often inaccurate.

[0062] Based on this, the embodiments of this specification propose corresponding solutions for doctor diagnosis and treatment risk detection in doctor-patient dialogue texts, so as to accurately identify potential diagnosis and treatment risks and make the risk detection results interpretable.

[0063] It should be noted that the doctor-patient dialogue text in the embodiments of this specification is not limited to text information directly input by the user via keyboard or touchscreen. In practical applications, the aforementioned doctor-patient dialogue text can also originate from voice data. Specifically, the system can integrate or connect to an Automatic Speech Recognition (ASR) module. When a doctor or patient inputs voice commands or engages in voice dialogue through the microphone of the terminal device, the ASR module first converts the voice signal into a text sequence in real time, and then inputs the converted text as the doctor-patient dialogue text into a large language model for subsequent risk detection. This processing method can adapt to diverse telemedicine scenarios such as telephone consultations and voicemail.

[0064] Figure 2 This diagram illustrates a method for detecting physician diagnosis and treatment risks based on doctor-patient dialogue text according to one embodiment. The method can be based on... Figure 1 The implementation scenario is shown. For example... Figure 2 As shown, the doctor's diagnosis and treatment risk detection method for doctor-patient dialogue text in this embodiment includes the following steps: Step 21, using a large language model to perform semantic extraction processing on the doctor-patient dialogue text to generate several atomized medical statements; wherein, a single atomized medical statement expresses a doctor's claim under a single medical fact, and the semantics between each atomized medical statement are independent; Step 22, inputting any atomized medical statement into the large language model for initial risk assessment to obtain an initial assessment result; wherein, the initial assessment result includes multiple risk assessment categories, and the multiple risk assessment categories include at least a deterministic category and an uncertain category; Step 23, if the initial assessment result belongs to the deterministic category, then the initial assessment result is determined as the risk assessment conclusion of the atomized medical statement; Step 24, if the initial assessment result belongs to the uncertain category, then a retrieval enhancement reasoning process is triggered; the retrieval enhancement reasoning process includes, using the large language model to generate structured retrieval instructions, recalling several knowledge fragments from the medical knowledge base based on the structured retrieval instructions, and combining the several knowledge fragments with the large language model to obtain the risk assessment conclusion and reasoning basis of the atomized medical statement. The specific execution method of each of the above steps is described below.

[0065] First, in step 21, a large language model is used to perform semantic extraction on the doctor-patient dialogue text, generating several atomized medical statements. Each atomized medical statement expresses a doctor's claim based on a single medical fact, and the atomized medical statements are semantically independent. Understandably, reconstructing unstructured, highly dependent multi-turn dialogues into several semantically independent atomized medical statements each containing only a single medical fact allows for subsequent risk detection of each statement individually, thereby eliminating the problem of low detection accuracy caused by contextual ambiguity at the source.

[0066] In the embodiments of this specification, an "atomic medical statement" refers to the smallest unit of medical assertion extracted from doctor-patient dialogue that can be independently reviewed. This statement originates from the doctor's diagnostic, treatment, or medication recommendations in the dialogue, rather than a new medical judgment generated independently of the original dialogue content by a large language model. Optionally, an atomized medical statement meets the following conditions: traceable origin, i.e., it can correspond to the doctor's original discourse in the doctor-patient dialogue; semantically atomized, i.e., it expresses only the doctor's assertion under a single medical fact, without mixing multiple diagnoses, medications, and follow-up recommendations; independently verifiable, i.e., it contains the necessary patient background information required for risk review, allowing it to be independently verified by a medical knowledge base or rules even after being removed from the original dialogue context; and structured and processable, i.e., it can be bound to statement type, search results, evidence summaries, and risk tags to support subsequent search-enhanced reasoning.

[0067] For example, in the original dialogue, the doctor states, "You can drink more water and get some rest. If the cough is severe, you can use ambroxol oral solution to stop the cough and clear phlegm." Combined with the patient's background, "A 5-year-old child with a cough for 3 days, more pronounced at night, no fever," the following atomized medical statements can be generated: "For a 5-year-old child with a cough for 3 days and no fever, it is recommended to increase water intake and get some rest"; "For a 5-year-old child with a cough for 3 days and no fever, it is recommended to use ambroxol oral solution to stop the cough and clear phlegm." Each statement expresses only one independently verifiable medical claim. In contrast, generalized statements like "take care of your health," statements relying on external materials like "the picture you sent looks like an infection," and simple descriptions of patient symptoms like "severe cough" are not considered suitable atomized medical statements for risk identification.

[0068] For example, the doctor-patient dialogue text is a long text. After the above semantic extraction processing, n atomic medical claims are generated, which are denoted as Claim1, Claim2, ... Claimn.

[0069] In one example, the semantic extraction processing of doctor-patient dialogue text using a large language model generates several atomized medical statements, including:

[0070] Input the first prompt word and the doctor-patient dialogue text into the big language model, instructing the big language model to extract multiple treatment suggestions from the doctor's utterance as multiple initial atomic expressions;

[0071] Input the second prompt word and the doctor-patient dialogue text into the big language model, instructing the big language model to extract the patient's objective profile information;

[0072] The third prompt word, the doctor-patient dialogue text, the objective profile information, and the multiple initial atomic expressions are input into the large language model, and the large language model is instructed to use the objective profile information to perform semantic completion and rewrite of the initial atomic expressions to generate multiple candidate statements of the doctor-patient dialogue text without context.

[0073] The fourth prompt word, the doctor-patient dialogue text, and the multiple candidate statements are input into the large language model, which is then instructed to filter out candidate statements of a preset type that are not suitable for risk identification, and to treat each remaining candidate statement as an atomic medical statement.

[0074] In this example, a precise conversion from unstructured long conversations to atomic medical statements was achieved by building a four-step serial workflow based on cue word orchestration. First, the first and second prompts are used to pinpoint "doctor's claims" and "patient profiles" respectively, establishing the factual basis and contextual boundaries for risk assessment. Then, the third prompt instructs the large language model to rewrite the initial atomized statements without context, explicitly mapping context-dependent pronouns (such as "oral medication" and "ointment") into independent statements containing specific entities (such as "cetirizine drops" and "calamine lotion") and patient limitations (such as "5-year-old child" and "penicillin allergy"), completely eliminating referential ambiguity and information fragmentation in long texts. Finally, a fourth prompt filters out invalid noise such as reliance on external materials, simple symptom repetitions, and general suggestions, ensuring that the generated atomized medical statements are traceable, semantically singular, and independently identifiable. This processing mechanism not only solves the problem of mismatched search keywords and missed risk detection caused by unclear referencing at the source, but also decomposes complex dialogue logic into atomized medical statements that can be precisely verified one by one, significantly improving the accuracy, recall, and interpretability of subsequent risk identification.

[0075] Furthermore, the first, second, third, or fourth prompt word includes role definition, task boundaries, input content specifications, and output format constraints.

[0076] In this example, deterministic control and standardized arrangement of the behavior of the general large language model are achieved by pre-setting role definitions, task boundaries, input content specifications and output format constraints in the first to fourth prompt words. Among them, "role definition" and "task boundary" clearly define the specific responsibilities of the model at different processing nodes (such as information extractor, profile analyst, rewriter, and quality inspector), effectively suppressing the illusion generation and out-of-bounds divergence that are common in long text processing, ensuring that it focuses only on core tasks such as extracting doctor claims and building patient profiles; "input content standardization" ensures the integrity and consistency of data transmission in multi-round workflows, enabling subsequent steps to accurately obtain the structured output of previous steps; and "output format constraints" force the model to respond with machine-readable structured data (such as JSON arrays and specific tag pairs), which not only eliminates the ambiguity of natural language output, but also provides a unified interface for automated parsing, verification, and cross-module flow; this engineered design of prompt words allows the general large language model to be transformed into a dedicated medical risk detection agent with high robustness, high controllability, and process-oriented collaboration capabilities without retraining the model, significantly improving the accuracy of atomic claim generation and overall operational stability.

[0077] Then, in step 22, any atomized medicine statement is input into the large language model for initial risk assessment, yielding an initial assessment result. This initial assessment result includes multiple risk assessment categories, which at least include a deterministic category and an uncertain category. It is understood that in this step, the large language model does not directly output a final conclusion, but rather acts as a preliminary classifier, rapidly scanning and judging the confidence level of the atomized medicine statement based on its internal parameter knowledge. A deterministic category corresponds to a higher confidence level for the statement, while an uncertain category corresponds to a lower confidence level.

[0078] In one example, the initial evaluation result can be set to three categories of labels, where no risk and high risk are deterministic categories that can be directly output, and low risk is an uncertain category that triggers retrieval-enhanced reasoning.

[0079] It should be noted that the specific label names for the initial assessment results are not limiting. As long as it is possible to distinguish between trustworthy categories (i.e., deterministic categories) and untrustworthy categories (i.e., uncertain categories) that require further external knowledge for confirmation, the embodiments in this specification can be applied. For example, the above categories can be implemented as "no risk, uncertain, high risk", "low concern, pending confirmation, high concern", or other equivalent classification methods.

[0080] For example, if a statement clearly conforms to common medical knowledge or standard medical practice (such as "drink more water"), the model classifies it as "no risk"; if a statement contains obvious contraindications, dosage errors, or logical contradictions (such as "amoxicillin for patients allergic to penicillin"), the model classifies it as "high risk"; and for complex situations that fall into a gray area, where the model's internal knowledge is insufficient to confirm the claim, or where there is potential uncertainty (such as medication use in special populations or rare interactions), the model classifies them as "low risk" (i.e., low confidence or uncertainty). The core of this three-level classification strategy lies in identifying the model's "cognitive boundaries," separating certain issues from uncertain issues, and preventing the model from blindly and confidently giving incorrect conclusions in areas of knowledge blind spots.

[0081] Next, in step 23, if the initial assessment result falls into the deterministic category, then the initial assessment result is determined as the risk assessment conclusion for the atomized medicine statement. Understandably, step 23 executes a rapid termination mechanism for the high-confidence path, designed to handle extreme cases where the model's internal knowledge is sufficient to make a definitive judgment.

[0082] For example, when the initial assessment result is "no risk," it indicates that the medical statement conforms to basic medical common sense or routine treatment guidelines (e.g., "recommend more rest"), and there are no potential treatment risks. When the initial assessment result is "high risk," it indicates that the medical statement violates a clear and serious medical contraindication or contains a significant logical fallacy (e.g., "prescribing amoxicillin to a patient allergic to penicillin"), and its risk characteristics are already highly certain in the model's pre-trained knowledge. In this case, the time-consuming external retrieval and complex reasoning steps are skipped, and the initial assessment result is directly locked as the final conclusion. This strategy not only significantly reduces response latency and computational costs but also effectively avoids the possibility of introducing irrelevant noise information due to forced retrieval, thereby interfering with the clear judgment, demonstrating an efficient ability to handle deterministic problems.

[0083] This specification's embodiments construct a hierarchical risk response system, achieving a balance between detection efficiency and safety. By intercepting and rapidly processing samples at both ends (obviously safe and obviously dangerous), it cleverly avoids the common drawback of "over-searching" in large language models, preventing resource waste caused by redundant operations even with conclusive evidence. Simultaneously, it ensures that obvious serious medical errors can be identified and blocked immediately without waiting for external knowledge base verification, thereby significantly improving the overall system throughput and real-time performance while ensuring medical safety.

[0084] Finally, in step 24, if the initial assessment result belongs to the uncertainty category, the retrieval enhancement reasoning process is triggered. This process includes generating structured retrieval instructions using a large language model, retrieving several knowledge fragments from the medical knowledge base based on these instructions, and combining these knowledge fragments with the large language model to obtain the risk assessment conclusion and reasoning basis for the atomized medical statement. It is understandable that the core of step 24 lies in constructing a dynamic calibration and closed-loop reasoning mechanism for the model's "cognitive uncertainty," specifically designed to address the "illusion" and "overaffirmation bias" problems of large language models in complex medical scenarios.

[0085] The risk assessment conclusion can include "Risk" and "No Risk".

[0086] In this embodiment, when the initial assessment result is "low risk" (i.e., the model has low confidence or is in a knowledge gray area), the model no longer relies on its internal parameter memory. Instead, it triggers a Retrieval-Augmented Generation (RAG) process, combining retrieval and generation to improve model performance. First, a large language model is used to transform ambiguous medical claims into structured retrieval instructions, recalling highly relevant knowledge fragments from authoritative medical knowledge bases. Then, the model combines this external factual evidence for secondary reasoning, generating a risk assessment conclusion and interpretable reasoning basis. This process is based on factual verification, effectively overcoming the defect of models blindly and confidently outputting erroneous conclusions due to a lack of up-to-date guidelines or domain-specific knowledge.

[0087] In one example, the medical knowledge base includes a disease database and a drug database; the disease database stores entries related to disease names, and the drug database stores entries related to drug names.

[0088] In this example, a dedicated medical knowledge base architecture (disease database and drug database) with sharded storage and categorized indexes was constructed, achieving precise isolation and efficient targeted retrieval of external knowledge sources. Physically or logically separating disease diagnostic criteria and treatment principles from drug ingredients, usage and dosage, contraindications, and interactions allows for direct routing to the corresponding dedicated databases based on structured retrieval. This effectively avoids retrieval noise and evidence mismatch caused by semantic overlap between disease and drug names (e.g., certain drugs named after diseases or vice versa) in mixed retrieval. This domain-specific data organization significantly improves recall accuracy and precision, ensuring that the retrieved knowledge fragments are highly relevant to the current atomized medical statement (whether it is a diagnostic or medication statement).

[0089] In one example, the structured search instruction is structured data containing the following fields:

[0090] The query keyword field is used to store medical entity names and their extended names;

[0091] The target knowledge domain field is used to identify the type of target database to be retrieved, including drug databases or disease databases.

[0092] The metadata field is used to specify the information dimensions that need to be focused on after the search.

[0093] This example demonstrates a paradigm shift from "fuzzy natural language query" to "precise targeted fact-checking" by constructing a structured retrieval instruction containing three-dimensional fields: query keywords, target knowledge domain, and retrieval metadata. Specifically, the "query keyword field" automatically expands medical entities with synonyms, generic names, and brand names (e.g., mapping "ointment" to "calamine lotion"), completely eliminating retrieval mismatches caused by the mismatch between colloquial expressions used by doctors and patients and professional terminology. The "target knowledge domain field" acts as an intelligent routing switch, directly distributing retrieval requests to drug or disease databases based on the claim type, effectively avoiding noise interference and evidence mismatch caused by cross-database mixed retrieval. The "retrieval metadata field" serves as an attention guidance mechanism, explicitly specifying the specific information dimensions the model should focus on (e.g., "contraindications," "dosage," or "interactions"), forcing the retrieval engine and subsequent large language model to focus on the core evidence most relevant to risk assessment, discarding irrelevant background information. This multi-dimensional structured constraint not only significantly improves the precision and relevance of external knowledge retrieval but also provides accurate and complete factual support for generating highly credible and interpretable risk assessment conclusions.

[0094] Furthermore, the retrieval of several knowledge fragments from a preset medical knowledge base based on the structured retrieval instructions includes:

[0095] The target knowledge domain field in the structured search instruction is parsed to determine whether the target database for the search is a drug database or a disease database.

[0096] Using the medical entity names and their extended names in the query keyword field, an index retrieval based on term matching is performed in the target database to recall the top K relevant knowledge fragments.

[0097] In this example, by implementing a three-tiered precision retrieval strategy of "domain routing + term expansion + term matching," the recall and precision of medical evidence retrieval were significantly improved. First, parsing the "target knowledge domain field" enabled intelligent routing of the retrieval path, ensuring that query requests only entered the corresponding drug or disease-specific database, physically isolating cross-domain noise interference. Second, using "medical entity names and their extended names" for retrieval effectively overcame the semantic gap between colloquial expressions used by doctors and patients (such as "anti-inflammatory drugs") and professional medical terminology (such as "antibiotics"), avoiding missed detection of key evidence due to word mismatch. Finally, performing term matching-based index retrieval within the limited domain and recalling the top K knowledge fragments ensured low latency and high determinism in the retrieval process.

[0098] Furthermore, the risk assessment conclusion and reasoning basis for obtaining the atomized medicine statement by combining the aforementioned knowledge fragments and utilizing the large language model include:

[0099] The knowledge fragments, the atomic medicine statement, and the retrieval metadata field in the structured retrieval instruction are input into the large language model. The large language model is used to determine the relevance between the knowledge fragments and the atomic medicine statement. Based on the information dimensions specified by the retrieval metadata field, several pieces of evidence are extracted from the relevant knowledge fragments.

[0100] The aforementioned evidence and the atomized medicine statement are input into the large language model, and the risk assessment conclusion and reasoning basis of the atomized medicine statement are obtained using the large language model.

[0101] In this example, a two-stage refined processing mechanism of "relevance filtering - dimension extraction - evidence reasoning" significantly improves the accuracy and interpretability of risk detection conclusions. First, by using the "retrieval metadata field" as an attention-guided anchor, the large language model performs semantic relevance discrimination and targeted evidence extraction in a massive amount of recalled fragments. This effectively eliminates noise information that is retrieved but irrelevant to the current risk point (such as focusing only on drug contraindications while ignoring irrelevant pharmacological descriptions), ensuring that the evidence input to the reasoning stage has a high degree of relevance and purity. Subsequently, based on the extracted core evidence, secondary reasoning is performed to generate conclusions and justifications, transforming the originally black-box model judgment into a white-box verification process based on a clear chain of facts. This not only overcomes the logical confusion caused by excessively long contexts or redundant information in the model, but also ensures that the output risk assessment results have solid evidence support that is traceable and verifiable, thereby greatly enhancing clinicians' trust in and acceptance rate of the test results.

[0102] Furthermore, the risk assessment conclusions and reasoning basis for obtaining the atomized medical statement using the large language model include:

[0103] The large language model is used to evaluate whether the evidence is sufficient to support a definitive risk assessment.

[0104] If the evidence is deemed insufficient, the query keyword field or retrieval metadata field in the structured retrieval instruction is corrected using the large language model, and steps are performed to retrieve knowledge fragments from the preset medical knowledge base, extract evidence, and assess the sufficiency of the evidence.

[0105] If the evidence is deemed sufficient, the large language model is used to generate the reasoning basis and risk assessment conclusion.

[0106] In this example, by introducing an adaptive iterative closed-loop mechanism based on the sufficiency of evidence, the risk detection system is endowed with crucial self-correction and dynamic optimization capabilities. When the large language model determines that the evidence retrieved in the initial recall is insufficient to support a definitive judgment (such as not finding contraindications for medication in a specific population), a feedback loop is automatically triggered. The model's own reasoning ability is used to intelligently correct the keywords or focus dimensions in the structured search instructions (for example, refining the broad term "ointment" to specific ingredients, or shifting the focus from "usage" to "adverse reactions"), and multiple rounds of re-searching and re-evaluation are performed. This iterative process of "evaluation-correction-re-searching" ensures that when facing complex, rare, or ambiguous medical scenarios, it can proactively overcome the biases and omissions of the initial search until a sufficient and high-quality chain of evidence is obtained before outputting a conclusion. This significantly reduces the misjudgment rate and the risk of illusion caused by lack of evidence, and greatly improves the robustness and credibility of decisions in extreme cases.

[0107] In one example, the large language model is a policy model trained through reinforcement learning; the reinforcement learning training process includes:

[0108] Obtain several pre-generated training sample pairs; wherein each training sample pair includes a risk-free sample and a risky sample, the risky sample being generated by perturbing at least one information dimension of the risk-free sample;

[0109] The grouping relative strategy optimization algorithm is used to calculate the advantage function value based on the total reward value of multiple outputs corresponding to the same group of inputs, and the parameters of the large language model are updated according to the advantage function value; wherein, the reward value of each output is determined comprehensively based on the format compliance of the output content and the accuracy of the risk assessment conclusion.

[0110] In this example, by constructing a reinforcement learning training paradigm based on paired perturbation samples and grouped relative policy optimization, the discriminative sensitivity, output standardization, and policy stability of the large language model in the medical risk detection scenario are significantly improved. First, training pairs are constructed using "risk-free samples" and "risk samples" generated by perturbation in a specific dimension. This forces the model to focus on identifying subtle differences in medical facts (such as dosage changes and the addition of contraindications) during fine-tuning, thereby greatly enhancing the model's signal-to-noise ratio sensitivity to high-risk features and effectively suppressing "overaffirmation bias." Second, the advantage function value is calculated based on multiple sampled outputs of the same set of inputs, enabling efficient policy updates without relying on an independent critic model. This significantly reduces training memory overhead and improves convergence speed. Finally, the dual indicators of "format compliance" and "conclusion accuracy" are incorporated into the reward function, ensuring that the model can not only make accurate risk judgments logically but also strictly follow the preset structured output specifications (such as atomic declaration formats and retrieval instruction fields). This creates a dedicated medical risk detection strategy model that combines high accuracy, strong robustness, and engineering feasibility.

[0111] Furthermore, the reward value for each output is determined in the following manner:

[0112] The output of the large language model is checked. If the output does not conform to the predefined format, a first negative reward value is given.

[0113] If the output conforms to the predefined format, the risk assessment conclusion output by the large language model will be compared with the risk labels of the training samples.

[0114] If the comparison results match, a positive reward value or a zero reward value will be given; if the comparison results do not match, a second negative reward value will be given.

[0115] In this example, a tiered reward mechanism prioritizing format compliance and ensuring accuracy of conclusions is constructed to achieve a dual alignment of engineering usability and logical correctness for large language models in medical risk detection tasks. First, a "first negative reward value" is established as a hard threshold for format constraints, forcing the model to strictly adhere to pre-defined structured output specifications (such as atomic declaration formats and retrieval instruction fields), effectively curbing the arbitrariness of generated content and parsing errors, and ensuring the stability of the automated processing flow. Second, based on format compliance, "positive or zero reward" and "second negative reward" are used to finely calibrate the risk assessment conclusions, guiding the model to converge towards the standard labels of the training samples, significantly improving the accuracy and consistency of the model's risk judgment in complex medical scenarios. This reward strategy, which decouples formal specifications from substantive content and quantifies them separately, not only accelerates policy convergence in the reinforcement learning process but also fundamentally solves the common problems of "format drift" and "illusionary misjudgment" in the application of general-purpose large models in vertical medical fields.

[0116] Furthermore, the predefined format includes:

[0117] The output of the risk assessment conclusion is required to include a preset start identifier and an end identifier, and the content between the start identifier and the end identifier is one of a number of preset level symbols;

[0118] The output of structured search commands must be in a predefined structured data format and contain a non-empty query string and predefined domain enumeration values.

[0119] The output of evidence should include a string-type summary content field and an array-type evidence source field.

[0120] In this example, by defining strongly constrained, fine-grained structured output specifications, a standardized transition from "unstructured natural language" to "machine-executable instructions" generated by the large language model was achieved. Specifically, setting start and end identifiers and level symbol enumerations for risk assessment conclusions ensures that risk judgment results can be accurately captured and unambiguously parsed by downstream systems using regular expressions, completely eliminating the logical ambiguity caused by free text. For structured search instructions, mandatory non-empty query strings and domain enumeration values ​​not only prevent invalid search requests at the syntactic level but also guarantee the determinism of search routes and the availability of keywords, preventing search process interruptions due to format errors. Furthermore, specifying specific types for the summary field and source array in the evidence output constructs a complete evidence tracing chain, ensuring that each inference basis can be traced back to a specific knowledge base entry. This rigorous format design directly transforms the output of the large language model into standard input for a programmable interface, significantly improving robustness, interoperability, and engineering implementation efficiency in automated workflows, laying a solid data interaction foundation for building a highly reliable closed-loop medical risk detection system.

[0121] The method provided in the embodiments of this specification utilizes a large language model to reconstruct lengthy and context-dependent complex doctor-patient dialogues into semantically independent and clearly defined atomic medical statements, eliminating risk omissions and misjudgments caused by attention distraction and unclear pronoun references in long texts from the source. Furthermore, a confidence-based dynamic routing mechanism is introduced, triggering the retrieval enhancement reasoning process only for statements with uncertain knowledge within the model. Structured retrieval instructions are generated using an external authoritative knowledge base, and knowledge fragments are recalled. This effectively overcomes the "overconfidence bias" and "illusion" problems of large models, while avoiding the inefficiency and noise interference caused by full retrieval. Finally, by outputting the reasoning basis generated based on the retrieved knowledge fragments, a transformation from "black-box judgment" to "white-box verification" is achieved, thereby accurately identifying potential diagnostic and treatment risks and making the risk detection results interpretable.

[0122] Figure 3 This diagram illustrates a retrieval-enhanced reasoning method according to one embodiment, which can correspond to... Figure 2 The retrieval enhancement reasoning process in step 24. For example... Figure 3As shown, the retrieval-enhanced reasoning method in this embodiment includes the following steps: Step 31, inputting the atomized medical statement into a large language model to generate a structured retrieval instruction; Step 32, retrieving several knowledge fragments from a medical knowledge base based on the structured retrieval instruction; Step 33, extracting several pieces of evidence from the several knowledge fragments according to the retrieval metadata fields of the structured retrieval instruction; Step 34, using the large language model to evaluate whether the evidence is sufficient to support a definite risk judgment; if the evidence is insufficient, proceed to step 31; if the evidence is sufficient, proceed to step 35; Step 35, based on the evidence, using the large language model to generate the reasoning basis and risk assessment conclusion corresponding to the atomized medical statement. The specific execution method of each of the above steps is described below.

[0123] First, in step 31, the atomized medicine claim is input into the large language model to generate structured search instructions. Understandably, the initial assessment of this atomized medicine claim is low-risk, triggering the search-enhanced reasoning process.

[0124] This embodiment of the specification obtains an atomized medical claim (e.g., "For a 5-year-old child with a penicillin allergy, oral amoxicillin granules are recommended") and feeds it as input into a large language model. This model is configured to act as a "retrieval planner," whose task is not to directly assess risk, but to automatically generate a structured retrieval instruction based on the claim content. This instruction contains three core fields: a query keyword field, used to store the medical entity name and its semantic extensions (e.g., "amoxicillin" → "penicillin antibiotics," "β-lactams"); a target knowledge domain field, used to identify the type of database to be retrieved (e.g., "drug database" or "disease database"); and a retrieval metadata field, used to specify the information dimensions to focus on (e.g., "contraindications," "pediatric dosage," "interactions"). Through this step, the ambiguous natural language claim is transformed into a standardized query request that is machine-parseable, routeable, and precisely matched, laying the foundation for subsequent efficient retrieval.

[0125] The search command format can be I i =(query i meta i ,domain i ); where i is used to identify atomized medicine statements, query i Represents the query keyword field, meta i Represents the retrieval of metadata fields, domain i Represents the target knowledge domain field.

[0126] Then, in step 32, several knowledge fragments are retrieved from the medical knowledge base based on structured search instructions. It is understandable that structured search instructions include query keyword fields, target knowledge domain fields, and search metadata fields, which helps improve the accuracy of the search.

[0127] In this embodiment of the specification, the medical knowledge base includes a drug database and a disease database, storing structured entries such as drug instructions, clinical guidelines, and authoritative literature. First, the "target knowledge domain field" in the instruction is parsed to determine the retrieval path (e.g., accessing only the drug database). Then, using the main term and expanded terms in the "query keyword field," an index retrieval based on term matching (e.g., the BM25 algorithm) is performed in the corresponding database to recall the top K most relevant knowledge fragments (K can be a dynamic value, such as 5–10). This step ensures that the retrieval process has domain isolation and complete terminology coverage, effectively avoiding missed detections caused by cross-domain noise interference and colloquial expressions, thereby obtaining a highly relevant candidate evidence set.

[0128] Among them, the above-mentioned knowledge fragments can be E i =(e i1 ,e i2 ,…,e ik ); where i is used to identify atomized medicine statements, e i1 Represents the first relevant knowledge fragment, e i2 Represents the second related knowledge fragment, ..., e ik This represents the k-th related knowledge fragment.

[0129] Next, in step 33, several pieces of evidence are extracted from several knowledge fragments based on the retrieval metadata fields of the structured retrieval instructions. It can be understood that several pieces of evidence are obtained by filtering and refining the knowledge fragments.

[0130] In this embodiment of the specification, the large language model is invoked again, and its input includes the original atomic declaration, the set of knowledge fragments recalled in step 32, and the "retrieval metadata field" generated in step 31. Based on the focus dimensions specified in the metadata (such as "only contraindication-related content needs to be extracted"), the model performs semantic analysis on each knowledge fragment, identifying and extracting sentences or paragraphs directly related to the current risk point, forming a concise evidence list. For example, if the metadata requires "pediatric dosage," the model will locate and extract key statements such as "This product is suitable for children over 2 years old, with a maximum daily dose not exceeding XX mg / kg" from the lengthy instruction manual. This step achieves the transformation from "massive text" to "precise evidence," significantly reducing the context length and information redundancy in subsequent reasoning stages, and improving judgment efficiency and accuracy.

[0131] Among them, the aforementioned pieces of evidence can be Where 'i' is used to identify atomized medicine statements, This represents the first relevant piece of evidence. This represents the second relevant piece of evidence, ... This represents the m-th relevant piece of evidence.

[0132] In step 34, a large language model is used to evaluate whether the evidence is sufficient to support a definitive risk assessment. If the evidence is deemed insufficient, step 31 is executed; if the evidence is deemed sufficient, step 35 is executed. It is understood that executing step 31 again will improve the structured search instructions, and steps 32 to 34 will be executed based on the improved structured search instructions until the evidence is deemed sufficient.

[0133] In this embodiment of the specification, the large language model acts as an "evidence quality inspector," tasked with evaluating whether the evidence list extracted in step 33 is sufficient in quantity, quality, and relevance to support a definitive risk conclusion. Evaluation criteria include, but are not limited to: whether the evidence source is authoritative, whether the content is clear and unambiguous, whether it covers all necessary dimensions (such as population, dosage, and contraindications), and whether there is contradictory information. If the model determines "insufficient evidence" (e.g., no contraindications were found for this population group), a feedback loop is triggered—returning to step 31, and the model automatically corrects the keywords or metadata fields in the original structured search instruction (e.g., refining "amoxicillin" to "amoxicillin clavulanate potassium," or shifting the focus from "usage" to "adverse reactions"), re-executing the search and extraction until the sufficiency condition is met. If "sufficient evidence" is determined, the process proceeds to step 35. This mechanism endows the system with self-correction and dynamic optimization capabilities, avoiding misjudgments due to single search biases.

[0134] Finally, in step 35, based on several pieces of evidence, a large language model is used to generate the reasoning basis and risk assessment conclusion corresponding to the atomized medicine statement. It is understood that the aforementioned reasoning basis may include the reasoning process, which is presented in natural language so that clinicians can understand the reasoning process.

[0135] In this embodiment of the specification, the large language model, based on the sufficient evidence list extracted in step 33, combines the original atomized medical statement to perform logical reasoning and comprehensive judgment. The output includes two parts: a risk assessment conclusion, i.e., a clear level label (e.g., risky or no risk); and the reasoning basis, i.e., a complete chain of arguments presented in natural language, clearly listing the specific evidence items cited and how they support the conclusion (e.g., "Because the patient has a history of penicillin allergy, and amoxicillin is a penicillin-type drug, according to Article X of the 'Guidelines for Clinical Application of Antibacterial Drugs,' this type of drug is prohibited; therefore, it is determined to be risky"). This step not only produces results but also provides traceable and verifiable explanations, completely solving the "black box" problem of traditional AI medical systems and enhancing clinicians' trust in and willingness to adopt test results.

[0136] The above steps together constitute a closed-loop, intelligent, and interpretable retrieval-enhanced reasoning engine, which not only overcomes the illusion of large models and the defects of knowledge lag, but also achieves efficient, accurate, and reliable automated detection of medical risks, and has significant industrial application value.

[0137] Figure 4 The diagram illustrates a reinforcement learning optimization process according to one embodiment, which can be used to train a policy model, namely the aforementioned large language model. Figure 4 As shown, the training process begins with the agent's perception of the current environmental state. Multiple different training sample states are input, denoted as... (For example: doctor-patient dialogue fragments of varying complexity and their corresponding atomized medical statements). For each input state s i The strategy model, acting as the executor, invokes internal parameters and external tools (such as retrieval interfaces and formatting validators) to execute corresponding decision actions. This action is specifically manifested in generating response text for that state. These outputs can specifically include structured risk assessment conclusions (such as "at risk"), chains of reasoning, and standardized retrieval instructions. To evaluate the diversity and stability of the strategy, the strategy model typically samples and generates multiple candidate outputs for the same input state.

[0138] The generated output is then sent to the reward module for quantitative evaluation. This module employs a composite reward mechanism, scoring the output quality from different dimensions to generate corresponding reward scores. Specifically, the reward calculation includes the following two core sub-items: output format reward, which first checks whether the output content conforms to predefined strict format constraints (e.g., whether it contains specified start or end identifiers, whether it is a valid JSON structure, and whether the fields are complete). If the format is compliant, a positive incentive is given; if the format is incorrect and causes downstream programs to be unable to parse it, a larger negative penalty is given. This mechanism ensures that the model learns to "speak a language that machines can understand." Rule-based reward, based on format compliance, compares the risk assessment conclusions output by the model with preset standard labels or authoritative medical rules. If the conclusion is accurate and the reasoning logic conforms to medical common sense, a positive reward is given; if factual illusions, missed high-risk detections, or logical contradictions occur, a negative reward is given.

[0139] After obtaining the reward values ​​for each output, the group calculation phase begins, which can employ the Group Relative Policy Optimization (GRPO) algorithm. Instead of relying on independent Critic Models to estimate the value baseline, it directly utilizes the reward distribution of multiple outputs generated under the same set of input states to calculate the advantage function value, as shown in the figure. The specific calculation method is as follows: for a certain output... Its advantage value Equal to the reward value of this output Subtract the mean of all output reward values ​​in this group Divide by the standard deviation This process enables the model to clearly identify which actions (outputs) are better than the average level (positive advantage value) and which are worse (negative advantage value).

[0140] Finally, the calculated advantage value is used. A loss function is constructed, and the parameters of the policy model are updated through backpropagation using the gradient descent algorithm. Through this iterative optimization, the model gradually tends to generate action sequences that yield higher "output format rewards" and "rule-based rewards," thereby learning output patterns that conform to medical industry standards and significantly improving its risk identification accuracy and system robustness in complex diagnostic and treatment scenarios.

[0141] This specification's embodiments introduce a group-based computation mechanism to replace the traditional independent evaluation model. This not only significantly reduces the memory usage and computational cost of reinforcement learning training but also effectively alleviates the problem of sparse reward signals by comparing relative merits within groups. Simultaneously, by explicitly incorporating the output format reward into the optimization objective, it solves the format drift problem commonly found in general-purpose large models in vertical domain applications. This ensures that the generated risk detection report can be directly parsed and executed by automated systems, demonstrating extremely high engineering practical value.

[0142] For example, the following reward mechanism could be adopted.

[0143] Format Reward: Ensures that the output format conforms to the predefined JSON format.

[0144]

[0145] Rule-based Outcome Reward: Rewards are calculated based on the final risk identification results.

[0146]

[0147] The total reward R is determined by both the format reward and the outcome reward.

[0148]

[0149] For example, policy optimization uses the GRPO estimator to optimize the policy.

[0150]

[0151] This formula defines the objective function of the GRPO algorithm, used to optimize policy model parameters during reinforcement learning. Its core idea is to calculate the relative advantage value by analyzing the reward distribution of multiple sampled outputs under the same input, rather than relying on an independent evaluation model, thereby guiding policy updates. This method significantly reduces training costs while improving policy stability and convergence efficiency.

[0152] In an optional embodiment, the knowledge base is logically divided into two independent but collaborative sub-bases: a Disease Database and a Drug Database, to achieve precise isolated storage and targeted retrieval of different medical entities.

[0153] The disease database focuses on storing structured entries related to clinical diagnosis. Its data fields include at least the disease name, associated symptom characteristics, and recommended treatment options. In one example of this embodiment, the disease database contains approximately 16,500 high-quality disease-related records, covering the diagnostic and treatment guidelines for common and rare diseases, ensuring a comprehensive mapping of patient condition descriptions.

[0154] The parallel drug database focuses on pharmaceutical knowledge, with data fields covering drug name, standard usage (including dosage, frequency, and route of administration), and key interaction information (such as contraindications and food-drug interactions). This drug database is much larger in scale, storing approximately 187,700 drug-related records in this embodiment. It not only includes the package insert information for marketed drugs but also integrates the latest clinical drug use guidelines, providing a detailed data benchmark for identifying potential medication risks.

[0155] During the inference phase, the aforementioned dual-database architecture is used to dynamically construct the evidence chain. When an atomized medical statement to be evaluated is received, the inference engine first intelligently routes the search to the corresponding sub-database based on the entity type in the statement (whether it is a disease description or medication advice). Subsequently, key facts are extracted from the recalled knowledge fragments to form either a set of disease evidences or a set of drug evidences. These pieces of evidence are not isolated but are linked together into a complete evidence chain according to temporal or causal logic, and directly input into the inference layer of the large language model. Finally, based on this evidence chain composed of authoritative data, the model performs conclusion inference and generates a risk assessment result with clear evidence. This mechanism of "segmented storage, targeted recall, and chain inference" effectively avoids semantic noise caused by mixed retrieval, significantly improves the accuracy and interpretability of risk judgment, and ensures that every detection conclusion is verifiable.

[0156] In one optional embodiment, a benchmark construction scheme is provided to address the problem that existing medical AI evaluation data is limited in scope and lacks sufficient scenario coverage, leading to the failure of model generalization capability verification. The construction of this evaluation set follows the dual principles of "multi-specialty coverage" and "multi-source data fusion" to ensure comprehensive and rigorous stress testing of the risk detection system.

[0157] First, at the specialty level, it breaks through the limitations of single diseases and constructs subset datasets spanning six core clinical departments, specifically: Pediatrics, focusing on medication dosage conversion for children and risks related to growth and development; Obstetrics, focusing on contraindications to medication during pregnancy and maternal and infant safety risks; Respiratory Medicine, covering the rational use of antibiotics and guidelines for the diagnosis and treatment of respiratory diseases; Endocrinology, addressing the management of hormonal drugs and the risks of complications from metabolic diseases; Psychiatry, involving the interaction and dependence risk assessment of psychotropic drugs; and Surgery, focusing on perioperative medication and postoperative management risks. This multi-specialty layout ensures that the model maintains stable risk identification capabilities when faced with specific knowledge from different medical fields.

[0158] Secondly, in terms of data sources, this embodiment integrates three heterogeneous data sources to simulate the complexity of the real world. Drug instruction manual and label data, extracted from official documents released by authoritative drug regulatory authorities, serves as the "gold standard" for judging drug compliance and is primarily used to assess the model's understanding of explicit contraindications and dosage restrictions. Clinical medical record data, sourced from anonymized hospital information systems, contains complex patient profiles, medical histories, and comorbidities, used to test the model's comprehensive reasoning and risk assessment capabilities in complex clinical scenarios. Telemedicine dialogue data, collected from real internet consultation platforms, is characterized by strong colloquialism, ambiguous referencing, and high context dependence, specifically used to evaluate the model's semantic understanding ability and noise robustness in unstructured natural language interactions.

[0159] By combining the above multi-dimensional approaches and testing the trained strategy model using this evaluation set, we can accurately pinpoint the model's shortcomings in specific departments or data types, thereby guiding subsequent targeted optimizations and ensuring that the final deployed system has broad clinical applicability and high reliability.

[0160] In one optional embodiment, a clinical assessment system based on real-world telemedicine dialogues was constructed to verify the effectiveness and safety of the risk detection system in practical application scenarios. This assessment dataset contains 604 real doctor-patient dialogue samples, with dialogue lengths covering multi-turn interaction scenarios ranging from 4 to 36 rounds, fully simulating the complexity of gradual information disclosure and dynamic changes during clinical consultations. A risk warning report is automatically generated for each dialogue, and a panel of 126 licensed physicians from 10 different clinical departments conducts multi-dimensional blind human review of the reports. This large-scale, multi-specialty human review mechanism ensures that the assessment results objectively reflect the system's actual performance in diverse clinical environments, avoiding assessment biases that may arise from relying solely on automated indicators.

[0161] Regarding evaluation metrics, this embodiment establishes core security dimensions encompassing factual accuracy, error reduction rate, and legal and ethical safety, focusing on whether the system accurately identifies risks without misleading hallucinations. Simultaneously, it introduces performance dimensions such as time compression, information gain, and communication readiness to quantify the system's auxiliary role in improving physician diagnostic efficiency. Finally, an overall usability score is derived. This multi-dimensional evaluation framework not only verifies the technical effectiveness of the solution in reducing medical errors but also demonstrates the system's significant industrial application value and feasibility for widespread adoption from the perspective of integrating legal compliance with clinical workflows.

[0162] Below are some examples of risky and risk-free samples in reinforcement learning.

[0163] First, extract medical knowledge, then rewrite it into risk-free samples. Next, perturb key conditions to generate corresponding risk samples. In this way, each piece of medical knowledge can form a set of control samples. For example, the extracted medical knowledge might be, "Children with fever can use acetaminophen under the guidance of a doctor according to their weight, but should avoid taking multiple compound cold medicines containing the same ingredient." Rewrite the medical knowledge into risk-free samples, for example, "For children with fever, doctors recommend using acetaminophen to reduce fever according to the population and remind them to avoid taking multiple medications containing the same ingredient." Perturb the drugs, population, dosage, contraindications, or treatment conditions to obtain risk samples, for example, "For children with fever, doctors recommend taking multiple cold medicines containing acetaminophen simultaneously for rapid fever reduction."

[0164] During training, risk-free samples are labeled as no_risk, and risky samples are labeled as risky. The model needs to learn to identify the medication or treatment risks introduced by perturbations. These samples are not a batch of risk sentences randomly written by humans. They are anchored to the same medical knowledge, and risk points are created through perturbations, allowing the training process to more clearly distinguish between "medically valid advice" and "risky advice that has been modified".

[0165] According to another embodiment, a physician diagnosis risk detection device for doctor-patient dialogue text is also provided, which is used to perform the method provided in the embodiments of this specification. Figure 5 A schematic block diagram of a doctor's diagnosis and treatment risk detection device based on a doctor-patient dialogue text, according to one embodiment, is shown. Figure 5 As shown, the device 500 includes:

[0166] Semantic extraction unit 51 is used to perform semantic extraction processing on doctor-patient dialogue text using a large language model to generate several atomized medical statements; wherein, each atomized medical statement expresses a doctor's claim under a single medical fact, and the atomized medical statements are semantically independent.

[0167] The initial assessment unit 52 is used to input any of the atomic medical statements obtained by the semantic extraction unit 51 into the large language model for initial risk assessment and obtain an initial assessment result; wherein, the initial assessment result includes multiple risk assessment categories, and the multiple risk assessment categories include at least a deterministic category and an uncertain category;

[0168] The determining unit 53 is configured to determine the initial assessment result as the risk assessment conclusion of the atomized medicine statement if the initial assessment result obtained by the initial assessment unit 52 belongs to the deterministic category.

[0169] The enhanced reasoning unit 54 is used to trigger the enhanced retrieval reasoning process if the initial assessment result obtained by the initial assessment unit 52 belongs to the uncertainty category. The enhanced retrieval reasoning process includes generating a structured retrieval instruction using the large language model, recalling several knowledge fragments from the medical knowledge base based on the structured retrieval instruction, and combining the several knowledge fragments with the large language model to obtain the risk assessment conclusion and reasoning basis of the atomized medical statement.

[0170] Optionally, as an embodiment, the semantic extraction unit 51 includes:

[0171] The first extraction subunit is used to input the first prompt word and the doctor-patient dialogue text into the big language model, and instruct the big language model to extract multiple treatment suggestions from the doctor's utterance as multiple initial atomic expressions.

[0172] The second extraction subunit is used to input the second prompt word and the doctor-patient dialogue text into the big language model, instructing the big language model to extract the patient's objective profile information;

[0173] The third extraction subunit is used to input the third prompt word, the doctor-patient dialogue text, the objective profile information obtained by the second extraction subunit, and the multiple initial atomic expressions obtained by the first extraction subunit into the large language model, and instruct the large language model to use the objective profile information to perform semantic completion and rewriting of the initial atomic expressions, and generate multiple candidate statements of the doctor-patient dialogue text without context.

[0174] The fourth extraction subunit is used to input the fourth prompt word, the doctor-patient dialogue text, and multiple candidate statements obtained by the third extraction subunit into the large language model, instructing the large language model to filter out candidate statements of a preset type that are not suitable for risk identification, and to treat each remaining candidate statement as an atomic medical statement.

[0175] Furthermore, the first, second, third, or fourth prompt word includes role definition, task boundaries, input content specifications, and output format constraints.

[0176] Optionally, as an embodiment, the structured retrieval instruction is structured data containing the following fields:

[0177] The query keyword field is used to store medical entity names and their extended names;

[0178] The target knowledge domain field is used to identify the type of target database to be retrieved, including drug databases or disease databases.

[0179] The metadata field is used to specify the information dimensions that need to be focused on after the search.

[0180] Furthermore, the enhanced reasoning unit 54 includes:

[0181] The parsing subunit is used to parse the target knowledge domain field in the structured retrieval instruction and determine whether the target database to be retrieved is a drug database or a disease database.

[0182] The retrieval subunit is used to perform a term-matching-based index retrieval in the target database obtained by the parsing subunit using the medical entity names and their extended names in the query keyword field, and to recall the top K relevant knowledge fragments.

[0183] Furthermore, the enhanced reasoning unit 54 includes:

[0184] The extraction subunit is used to input the several knowledge fragments, the atomic medicine statement, and the retrieval metadata field in the structured retrieval instruction into the large language model, use the large language model to determine the relevance between the several knowledge fragments and the atomic medicine statement, and extract several pieces of evidence from the relevant knowledge fragments according to the information dimensions specified by the retrieval metadata field.

[0185] The reasoning subunit is used to input the evidence obtained by the extraction subunit and the atomized medicine statement into the large language model, and use the large language model to obtain the risk assessment conclusion and reasoning basis of the atomized medicine statement.

[0186] Furthermore, the reasoning subunit includes:

[0187] The judgment module is used to evaluate, using the large language model, whether the evidence is sufficient to support a definite risk judgment.

[0188] The iterative module is used to modify the query keyword field or retrieval metadata field in the structured retrieval instruction using the large language model if the judgment module determines that the evidence is insufficient, and to perform the steps of recalling knowledge fragments from the preset medical knowledge base, extracting evidence, and evaluating the sufficiency of evidence.

[0189] The generation module is used to generate reasoning basis and risk assessment conclusions using the large language model if the judgment module determines that the evidence is sufficient.

[0190] Optionally, as an embodiment, the large language model is a policy model obtained through reinforcement learning training; the reinforcement learning training process includes:

[0191] Obtain several pre-generated training sample pairs; wherein each training sample pair includes a risk-free sample and a risky sample, the risky sample being generated by perturbing at least one information dimension of the risk-free sample;

[0192] The grouping relative strategy optimization algorithm is used to calculate the advantage function value based on the total reward value of multiple outputs corresponding to the same group of inputs, and the parameters of the large language model are updated according to the advantage function value; wherein, the reward value of each output is determined comprehensively based on the format compliance of the output content and the accuracy of the risk assessment conclusion.

[0193] Furthermore, the reward value for each output is determined in the following manner:

[0194] The output of the large language model is checked. If the output does not conform to the predefined format, a first negative reward value is given.

[0195] If the output conforms to the predefined format, the risk assessment conclusion output by the large language model will be compared with the risk labels of the training samples.

[0196] If the comparison results match, a positive reward value or a zero reward value will be given; if the comparison results do not match, a second negative reward value will be given.

[0197] Furthermore, the predefined format includes:

[0198] The output of the risk assessment conclusion is required to include a preset start identifier and an end identifier, and the content between the start identifier and the end identifier is one of a number of preset level symbols;

[0199] The output of structured search commands must be in a predefined structured data format and contain a non-empty query string and predefined domain enumeration values.

[0200] The output of evidence should include a string-type summary content field and an array-type evidence source field.

[0201] Optionally, as an embodiment, the medical knowledge base includes: a disease database and a drug database; the disease database stores entries related to disease names, and the drug database stores entries related to drug names.

[0202] Using the apparatus provided in the embodiments of this specification, the semantic extraction unit 51 reconstructs lengthy and context-dependent complex doctor-patient dialogues into semantically independent and clearly referential atomized medical statements using a large language model. This eliminates the risk omissions and misjudgments caused by distraction due to long texts and unclear pronoun references at the source. Furthermore, a dynamic routing mechanism based on confidence is introduced, and the enhanced reasoning unit 54 triggers the retrieval and enhanced reasoning process only for statements with uncertain knowledge within the model. It uses an external authoritative knowledge base to generate structured retrieval instructions and recall knowledge fragments, effectively overcoming the problems of "overconfidence bias" and "illusion" in large models, while avoiding the inefficiency and noise interference caused by full retrieval. Finally, by outputting the reasoning basis generated based on the retrieved knowledge fragments, the transformation from "black box judgment" to "white box verification" is realized, thereby accurately identifying potential diagnostic and treatment risks and making the risk detection results interpretable.

[0203] According to another embodiment, a computer-readable storage medium is also provided, on which a computer program is stored, which, when executed in a computer, causes the computer to perform a combination Figure 2 or Figure 3 The method described.

[0204] According to another embodiment, a computing device is also provided, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, it implements a combination... Figure 2 or Figure 3 The method described.

[0205] Those skilled in the art will recognize that, in one or more of the examples above, the functions described in this invention can be implemented using hardware, software, firmware, or any combination thereof. When implemented in software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or code on a computer-readable medium.

[0206] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made on the basis of the technical solution of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for detecting physician diagnosis and treatment risks based on doctor-patient dialogue text, comprising: A large language model is used to extract semantics from doctor-patient dialogue texts to generate several atomized medical statements; each atomized medical statement expresses a doctor's claim under a single medical fact, and the atomized medical statements are semantically independent. Input any of the aforementioned atomic medicine statements into the large language model for initial risk assessment to obtain initial assessment results; wherein, the initial assessment results include multiple risk assessment categories, and the multiple risk assessment categories include at least a deterministic category and an uncertain category; If the initial assessment result belongs to the deterministic category, then the initial assessment result is determined as the risk assessment conclusion of the atomized medicine statement; If the initial assessment result belongs to the uncertainty category, the retrieval enhancement reasoning process is triggered. The retrieval enhancement reasoning process includes generating a structured retrieval instruction using the large language model, recalling several knowledge fragments from the medical knowledge base based on the structured retrieval instruction, and combining the several knowledge fragments with the large language model to obtain the risk assessment conclusion and reasoning basis of the atomized medical statement.

2. The method of claim 1, wherein, The process of semantic extraction from doctor-patient dialogue text using a large language model generates several atomized medical statements, including: Input the first prompt word and the doctor-patient dialogue text into the big language model, instructing the big language model to extract multiple treatment suggestions from the doctor's utterance as multiple initial atomic expressions; Input the second prompt word and the doctor-patient dialogue text into the big language model, instructing the big language model to extract the patient's objective profile information; The third prompt word, the doctor-patient dialogue text, the objective profile information, and the multiple initial atomic expressions are input into the large language model, and the large language model is instructed to use the objective profile information to perform semantic completion and rewrite of the initial atomic expressions to generate multiple candidate statements of the doctor-patient dialogue text without context. The fourth prompt word, the doctor-patient dialogue text, and the multiple candidate statements are input into the large language model, which is then instructed to filter out candidate statements of a preset type that are not suitable for risk identification, and to treat each remaining candidate statement as an atomic medical statement.

3. The method as described in claim 2, wherein, The first, second, third, or fourth prompt word includes role definition, task boundaries, input content specifications, and output format constraints.

4. The method of claim 1, wherein, The structured search command is structured data containing the following fields: The query keyword field is used to store medical entity names and their extended names; The target knowledge domain field is used to identify the type of target database to be retrieved, including drug databases or disease databases. The metadata field is used to specify the information dimensions that need to be focused on after the search.

5. The method of claim 4, wherein, The process of retrieving several knowledge fragments from a preset medical knowledge base based on the structured search instructions includes: The target knowledge domain field in the structured search instruction is parsed to determine whether the target database for the search is a drug database or a disease database. Using the medical entity names and their extended names in the query keyword field, an index retrieval based on term matching is performed in the target database to recall the top K relevant knowledge fragments.

6. The method of claim 4, wherein, The risk assessment conclusions and reasoning basis for obtaining the atomized medicine statement by combining the aforementioned knowledge fragments and utilizing the large language model include: The knowledge fragments, the atomic medicine statement, and the retrieval metadata field in the structured retrieval instruction are input into the large language model. The large language model is used to determine the relevance between the knowledge fragments and the atomic medicine statement. Based on the information dimensions specified by the retrieval metadata field, several pieces of evidence are extracted from the relevant knowledge fragments. The aforementioned evidence and the atomized medicine statement are input into the large language model, and the risk assessment conclusion and reasoning basis of the atomized medicine statement are obtained using the large language model.

7. The method of claim 6, wherein, The risk assessment conclusions and reasoning basis for obtaining the atomized medicine statement using the large language model include: The large language model is used to evaluate whether the evidence is sufficient to support a definitive risk assessment. If the evidence is deemed insufficient, the query keyword field or retrieval metadata field in the structured retrieval instruction is corrected using the large language model, and steps are performed to retrieve knowledge fragments from the preset medical knowledge base, extract evidence, and assess the sufficiency of the evidence. If the evidence is deemed sufficient, the large language model is used to generate the reasoning basis and risk assessment conclusion.

8. The method of claim 1, wherein, The large language model is a policy model obtained through reinforcement learning training; The reinforcement learning training process includes: Obtain several pre-generated training sample pairs; wherein each training sample pair includes a risk-free sample and a risky sample, the risky sample being generated by perturbing at least one information dimension of the risk-free sample; The grouping relative strategy optimization algorithm is used to calculate the advantage function value based on the total reward value of multiple outputs corresponding to the same group of inputs, and the parameters of the large language model are updated according to the advantage function value; wherein, the reward value of each output is determined comprehensively based on the format compliance of the output content and the accuracy of the risk assessment conclusion.

9. The method of claim 8, wherein, The reward value for each output is determined in the following manner: The output of the large language model is checked. If the output does not conform to the predefined format, a first negative reward value is given. If the output conforms to the predefined format, the risk assessment conclusion output by the large language model will be compared with the risk labels of the training samples. If the comparison results match, a positive reward value or a zero reward value will be given; if the comparison results do not match, a second negative reward value will be given.

10. The method of claim 9, wherein, The predefined format includes: The output of the risk assessment conclusion is required to include a preset start identifier and an end identifier, and the content between the start identifier and the end identifier is one of a number of preset level symbols; The output of structured search commands must be in a predefined structured data format and contain a non-empty query string and predefined domain enumeration values. The output of evidence should include a string-type summary content field and an array-type evidence source field.

11. The method of claim 1, wherein, The medical knowledge base includes a disease database and a drug database; the disease database stores entries related to disease names, and the drug database stores entries related to drug names.

12. A doctor's diagnosis and treatment risk detection device based on doctor-patient dialogue text, comprising: The semantic extraction unit is used to perform semantic extraction processing on the doctor-patient dialogue text using a large language model to generate several atomized medical statements; wherein, each atomized medical statement expresses the doctor's claim under a single medical fact, and the atomized medical statements are semantically independent. An initial assessment unit is used to input any of the atomic medical statements obtained by the semantic extraction unit into the large language model for initial risk assessment, and obtain an initial assessment result; wherein, the initial assessment result includes multiple risk assessment categories, and the multiple risk assessment categories include at least a deterministic category and an uncertain category; A determining unit is configured to determine the initial assessment result as the risk assessment conclusion of the atomized medicine statement if the initial assessment result obtained by the initial assessment unit belongs to the deterministic category. An enhanced reasoning unit is used to trigger a retrieval enhanced reasoning process if the initial assessment result obtained by the initial assessment unit belongs to the uncertainty category. The retrieval enhanced reasoning process includes generating a structured retrieval instruction using the large language model, recalling several knowledge fragments from the medical knowledge base based on the structured retrieval instruction, and combining the several knowledge fragments with the large language model to obtain the risk assessment conclusion and reasoning basis of the atomized medical statement.

13. A computing device comprising a memory and a processor, wherein the memory stores executable code, and the processor, when executing the executable code, implements the method of any one of claims 1-11.