Method and device for detecting safety of drug compatibility conflict based on uncertainty quantification
By fusing knowledge graphs of drug compatibility conflicts with modal coding of medical texts and Bayesian inference, a joint uncertainty scalar is generated to control the output of the large language model. This solves the safety and reliability problems of drug compatibility conflict detection in existing technologies and achieves safe and reliable drug compatibility conflict detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGDONG LAB OF ARTIFICIAL INTELLIGENCE & DIGITAL ECONOMY (SZ)
- Filing Date
- 2026-01-28
- Publication Date
- 2026-06-19
AI Technical Summary
Existing methods for detecting drug incompatibility conflicts cannot effectively quantify the confidence level of prediction results, are prone to generating false interaction information, and are difficult to guarantee the safety and reliability of test results, thus affecting the safety of clinical medication.
By acquiring the knowledge graph modal and medical text modal encoding of the target drug pair, first and second probability distribution parameters are generated. These parameters are then fused using Bayesian inference rules to generate a joint uncertainty scalar. This scalar is then used to control the output of the matching detection results of the pre-trained large language model.
It enables safe detection of drug incompatibility, effectively avoids false interaction information, improves the safety and reliability of detection results, and provides credible support for clinical medication decisions.
Smart Images

Figure CN122245601A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, specifically to a method and apparatus for safe detection of drug compatibility conflicts based on uncertainty quantification. Background Technology
[0002] Drug-drug interaction (DDI) detection is a crucial safeguard for clinical medication safety, playing a vital role in mitigating adverse reactions from combined drug use and improving the safety of healthcare services. In recent years, deep learning technologies (such as knowledge graph analysis and medical text mining) have made significant progress in this field, overcoming the efficiency limitations of traditional detection methods and providing new pathways for rapidly identifying potential drug incompatibilities.
[0003] However, existing drug incompatibility detection methods still suffer from core technical bottlenecks in practical applications, making it difficult to meet the reliability requirements of precision medicine in clinical practice. On the one hand, existing methods cannot effectively quantify the confidence level of prediction results. When medical personnel obtain test results, they cannot know whether the results are based on sufficient and reliable evidence, introducing uncertainty and risk into medication decisions. On the other hand, when faced with drug combinations not covered in the training data, generative models are prone to outputting seemingly reasonable but actually false interaction information, which may mislead clinical decisions and threaten patient medication safety. Furthermore, the results after multimodal data fusion lack effective reliability judgment criteria, making it difficult to adapt to different data completeness scenarios and affecting the practical application value of the test results. In summary, existing drug incompatibility detection methods suffer from the inability to effectively quantify the prediction confidence of multimodal data and the tendency to generate false interaction information, thus making it difficult to guarantee the safety and reliability of test results and severely restricting the safe application of drug incompatibility detection technology in clinical practice.
[0004] The preceding description is intended to provide general background information and does not necessarily constitute prior art. Summary of the Invention
[0005] This application provides a method and apparatus for safe detection of drug compatibility conflicts based on uncertainty quantification, which can realize the safe detection of drug compatibility conflicts, effectively avoid false interaction information, and thus improve the safety and reliability of the detection results.
[0006] In a first aspect, embodiments of this application provide a drug compatibility conflict safety detection method based on uncertainty quantification, including: Target drug pairs are acquired and encoded based on knowledge graph modalities and medical text modalities, respectively, to obtain a first probability distribution parameter and a second probability distribution parameter characterizing the conflict risk of the target drug pairs; wherein, each probability distribution parameter includes a mean parameter characterizing the prediction mean and a variance parameter characterizing the variance of cognitive uncertainty. The first probability distribution parameter and the second probability distribution parameter are fused based on Bayesian inference rules to generate a joint uncertainty scalar for the target drug pair; Based on the comparison result between the joint uncertainty scalar and the preset rules, a corresponding control command is generated, and the control command is input into the pre-trained large language model to control the large language model to output a drug conflict detection result that matches the joint uncertainty scalar.
[0007] Secondly, embodiments of this application provide a drug compatibility conflict safety detection device based on uncertainty quantification, comprising: An encoding module is used to acquire target drug pairs and encode the target drug pairs based on knowledge graph modalities and medical text modalities respectively, to obtain a first probability distribution parameter and a second probability distribution parameter characterizing the conflict risk of the target drug pairs; wherein, each of the probability distribution parameters includes a mean parameter characterizing the prediction mean and a variance parameter characterizing the variance of cognitive uncertainty; The fusion module is used to fuse the first probability distribution parameters and the second probability distribution parameters based on Bayesian inference rules to generate a joint uncertainty scalar of the target drug pair; The detection module is used to generate corresponding control commands based on the comparison results between the joint uncertainty scalar and the preset rules, and input the control commands into the pre-trained large language model to control the large language model to output drug conflict detection results that match the joint uncertainty scalar.
[0008] This application provides a method and apparatus for drug compatibility conflict safety detection based on uncertainty quantification. First, by encoding the target drug pair in both knowledge graph and medical text modalities, probability distribution parameters containing the prediction mean and cognitive uncertainty variance are obtained. This achieves a quantitative characterization of the prediction reliability of the two core modalities, overcoming the limitation of traditional methods that cannot reflect prediction confidence levels. Second, by fusing the bimodal probability distribution parameters based on Bayesian inference rules, the effective information from both types of data is effectively integrated, generating a joint uncertainty scalar that objectively reflects the overall prediction confidence level, avoiding the one-sided influence of single-modal data. Finally, by converting the comparison results of the joint uncertainty scalar and preset rules into control instructions, this is input into a pre-trained large language model to control its output matching results. This allows the model to output corresponding drug conflict detection conclusions when the prediction confidence is sufficient, and to avoid generating false interaction information through instruction constraints when the confidence is insufficient. This fully leverages the complementary value of multimodal data and effectively avoids the risk of misleading clinical decisions, ultimately improving the safety and reliability of drug compatibility conflict detection and providing reliable technical support for precision medication decisions. In summary, the drug compatibility conflict safety detection scheme based on uncertainty quantification provided in this application generates a joint uncertainty scalar by performing probability distribution encoding and Bayesian inference fusion on the knowledge graph modal data and medical text modal data of the target drug pair. The joint uncertainty scalar is then used to control the output matching results of the pre-trained large language model, thereby achieving safe detection of drug compatibility conflicts, effectively avoiding false interaction information, and thus improving the safety and reliability of the detection results. Attached Figure Description
[0009] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0010] Figure 1 This is an application environment diagram of the drug compatibility conflict safety detection method based on uncertainty quantification provided in the embodiments of this application; Figure 2 This is a schematic flowchart of the drug compatibility conflict safety detection method based on uncertainty quantification provided in the embodiments of this application; Figure 3 This is another schematic diagram of the drug compatibility conflict safety detection system based on uncertainty quantification provided in the embodiments of this application; Figure 4 This is a schematic diagram illustrating the principle of Bayesian expert product provided in an embodiment of this application; Figure 5This is a schematic diagram of the drug compatibility conflict safety detection algorithm provided in the embodiments of this application; Figure 6 This is a schematic diagram of the uncertainty-driven LLM gating logic provided in the embodiments of this application; Figure 7 This is a schematic diagram of the structure of the drug compatibility conflict safety detection device based on uncertainty quantification provided in the embodiments of this application; Figure 8 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0011] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of systems and methods consistent with those detailed in the appended claims or with some aspects of this application.
[0012] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover descriptions such as non-exclusive inclusion, so that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, components, features, and elements with the same names in different embodiments of this application may have the same meaning or different meanings, the specific meaning of which must be determined by its interpretation in that specific embodiment or further in conjunction with the context of that specific embodiment.
[0013] It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.
[0014] In the following description, the use of suffixes such as "module," "part," or "unit" to denote elements is solely for the purpose of illustrative purposes and has no specific meaning in itself. Therefore, "module," "part," or "unit" may be used interchangeably.
[0015] To address the aforementioned technical problems and overcome the shortcomings of existing technologies, this application provides a method and apparatus for safe detection of drug compatibility conflicts based on uncertainty quantification. This method and apparatus can achieve safe detection of drug compatibility conflicts, effectively avoid false interaction information, and thus improve the safety and reliability of the detection results.
[0016] Figure 1 This is an application environment diagram of a drug compatibility conflict safety detection method based on uncertainty quantification in one embodiment. (Refer to...) Figure 1 This drug compatibility conflict safety detection method based on uncertainty quantification is applied to a drug compatibility conflict safety detection system based on uncertainty quantification. The system includes a terminal 110 and a server 120. The terminal 110 and server 120 are connected via a network. The terminal 110 can be a desktop terminal or a mobile terminal; the mobile terminal can be at least one of a mobile phone, tablet, or laptop. The server 120 can be a standalone server or a server cluster consisting of multiple servers. Server 120 is configured to execute the aforementioned drug compatibility conflict safety detection method based on uncertainty quantification, including: acquiring target drug pairs and encoding them based on knowledge graph modalities and medical text modalities respectively to obtain a first probability distribution parameter and a second probability distribution parameter characterizing the conflict risk of the target drug pairs; wherein, each probability distribution parameter includes a mean parameter characterizing the predicted mean and a variance parameter characterizing the variance of cognitive uncertainty; fusing the first probability distribution parameter and the second probability distribution parameter based on Bayesian inference rules to generate a joint uncertainty scalar of the target drug pairs; generating corresponding control instructions based on the comparison results between the joint uncertainty scalar and preset rules, and inputting the control instructions into a pre-trained large language model to control the large language model to output drug conflict detection results that match the joint uncertainty scalar.
[0017] Please see Figure 2 , Figure 2 This is a flowchart illustrating a drug compatibility conflict safety detection method based on uncertainty quantification according to an embodiment of this application. This embodiment primarily uses the application of this drug compatibility conflict safety detection method based on uncertainty quantification to a computer device as an example for illustration. Specifically, the drug compatibility conflict safety detection method based on uncertainty quantification according to an embodiment of this application may include the following steps: S10. Obtain the target drug pair and encode it based on the knowledge graph modality and the medical text modality respectively to obtain the first probability distribution parameter and the second probability distribution parameter that characterize the conflict risk of the target drug pair; wherein, the probability distribution parameters each include the mean parameter that characterizes the prediction mean and the variance parameter that characterizes the variance of cognitive uncertainty; Specifically, for step S10, firstly, the target drug pair to be detected is acquired and identified. Target drug pairs can come from scenarios such as clinical medication consultation and drug combination regimen review. Then, relevant association information of the target drug pair in the knowledge graph is extracted, such as potential associations between drugs and targets, drugs and side effects, and drugs and indications. This structured association information is then encoded into a first probability distribution parameter that characterizes the risk of drug pair conflict. The first probability distribution parameter includes a mean parameter and a variance parameter. The mean parameter reflects the predicted trend of drug pair compatibility conflict; a higher value indicates a stronger bias towards conflict. The variance parameter characterizes the cognitive uncertainty of the prediction result; a smaller value indicates a more reliable prediction. Medical literature information related to the target drug pair is collected, such as clinical research reports, case records, and pharmacological analysis literature. This unstructured text information is then encoded into a second probability distribution parameter that characterizes the risk of drug pair conflict. The second probability distribution parameter also includes a mean parameter (reflecting the predicted trend of conflict risk) and a variance parameter (reflecting the cognitive uncertainty of the prediction).
[0018] For example, taking the target drug pair "aspirin and ginkgo biloba extract" as an example, after knowledge graph modal encoding, the first probability distribution parameter is obtained as (mean = 0.7, variance = 0.2), where the mean of 0.7 indicates a bias towards mismatch, and the variance of 0.2 indicates that the uncertainty of the prediction is moderate; after medical text modal encoding, the second probability distribution parameter is obtained as (mean = 0.9, variance = 0.1), where the mean of 0.9 indicates a strong bias towards mismatch, and the variance of 0.1 indicates that the uncertainty of the prediction is low.
[0019] S20. Based on Bayesian inference rules, the parameters of the first probability distribution and the second probability distribution are fused to generate a joint uncertainty scalar for the target drug pair; Specifically, in step S20, using the obtained first and second probability distribution parameters as input, Bayesian inference rules are employed to fuse multimodal information. The core of the fusion process is to integrate the prediction trends (mean parameter) and uncertainties (variance parameter) of the two modalities, automatically weighing the reliability of each modality's information to avoid the biased influence of a single modality. Through the probability fusion logic of Bayesian inference, the two independent probability distribution parameters are integrated into a joint uncertainty scalar that reflects the overall prediction confidence level. This scalar is a quantitative representation of the overall uncertainty after dual-modal fusion; the smaller the scalar value, the higher the confidence level of the fused prediction result; the larger the value, the higher the overall uncertainty.
[0020] For example, for the two probability distribution parameters ((0.7, 0.2) and (0.9, 0.1)) of "aspirin and ginkgo leaf extract" in step 1, after fusion based on Bayesian inference rules, the joint uncertainty scalar is calculated to be about 0.258, which indicates that the overall prediction confidence is high.
[0021] S30. Based on the comparison results between the joint uncertainty scalar and the preset rules, generate corresponding control instructions and input the control instructions into the pre-trained large language model to control the output of the large language model to match the drug conflict detection results with the joint uncertainty scalar; Specifically, for step S30, a preset rule corresponding to the joint uncertainty scalar is pre-defined. This rule is usually based on clinical medication safety needs to set grading criteria (e.g., setting two cutoff thresholds, with the first cutoff threshold higher than the second, forming three confidence level intervals: high, medium, and low). The generated joint uncertainty scalar is compared with the threshold in the preset rule. Based on the comparison result, a corresponding control instruction is generated. If the joint uncertainty scalar is higher than the first cutoff threshold (e.g., 0.8), it indicates insufficient evidence and extremely high overall uncertainty, generating a defensive control instruction that explicitly requires prohibiting the fabrication of pharmacological mechanisms and truthfully disclosing the lack of clear evidence. If the joint uncertainty scalar is lower than the second cutoff threshold (e.g., 0.3), it indicates sufficient evidence and extremely high overall confidence, generating a confidence-based control instruction that requires a detailed explanation of the interaction mechanism and provides relevant suggestions. If the joint uncertainty scalar is between the two cutoff thresholds, it indicates some uncertainty, generating a cautious control instruction that requires the use of non-deterministic expressions to indicate potential risks. The generated control commands are input into a pre-trained large language model. The large language model will strictly follow the requirements of the control commands and output drug conflict detection results that match the joint uncertainty scalar, thus avoiding false generation that exceeds the scope of evidence.
[0022] For example, if the combined uncertainty scalar of "aspirin and ginkgo biloba extract" (0.258) is lower than the second cutoff threshold (0.3), a confidence-based control instruction is generated: "Based on high-confidence evidence, explain the drug interaction mechanism in detail and output clinical recommendations." After receiving this instruction, the pre-trained large language model outputs: "Ginkgo biloba extract has antiplatelet activity, and its combination with aspirin will produce a synergistic effect, significantly increasing the risk of bleeding. It is recommended to discontinue the use of ginkgo biloba extract or monitor coagulation indicators." If the combined uncertainty scalar of a drug pair is 0.9 (higher than the first cutoff threshold of 0.8), a defensive control instruction is generated: "Current evidence is insufficient; it is forbidden to fabricate pharmacological mechanisms. Clearly reply that no clear evidence of interaction has been found." The large language model will output the corresponding result as required.
[0023] This embodiment quantifies the confidence level of drug compatibility conflict prediction through bimodal probabilistic coding, fully integrates the value of multi-source information by leveraging Bayesian inference fusion, and constrains the output behavior of the large language model by control instructions, effectively avoiding the generation of false information and ensuring that the detection results match the sufficiency of evidence, thereby improving the safety and reliability of drug compatibility conflict detection and providing credible support for clinical medication decisions.
[0024] Furthermore, in some embodiments, step S10, "acquiring target drug pair data and encoding the target drug pair data based on knowledge graph modality and medical text modality respectively to obtain a first probability distribution parameter and a second probability distribution parameter characterizing the conflict risk of the target drug pair," may specifically include: S11. Based on the knowledge graph modality, extract the graph structure features related to the target drug pair, and encode the graph structure features through the first variational inference head structure to obtain the first probability distribution parameters; Specifically, for step S11, the focus is first on the knowledge graph modality. For the acquired target drug pairs, the relevant graph structural features are mined and extracted. These graph structural features originate from the connections between drug entities and other related entities (such as targets, indications, side effects, etc.) in the knowledge graph, as well as the potential association patterns between drug entities. They are important structured information reflecting the conflict risk of drug pairs. After extracting the graph structural features, they are input into a pre-constructed first variational inference head structure. Through the encoding processing of this structure, the abstract graph structural features are transformed into quantifiable first probability distribution parameters. These parameters include a first prediction mean parameter and a first cognitive uncertainty variance parameter. The first prediction mean parameter directly reflects the core prediction result of the conflict risk of the target drug pair, while the first cognitive uncertainty variance parameter reflects the reliability of the prediction result.
[0025] For example, the target drug pair is set as "aspirin" and "ginkgo leaf extract". In the knowledge graph modality, the extracted graph structure features include: the interaction between aspirin and the "anti-platelet aggregation" target, the association between ginkgo leaf extract and the indication of "improving blood circulation", and the indirect association features formed between the two through the "platelet function regulation" pathway. After encoding these graph structure features into the first variational inference head structure, the first probability distribution parameters are obtained: the first prediction mean parameter μ1=0.7 (indicating a tendency for compatibility conflict risk), and the first cognitive uncertainty variance parameter σ1²=0.2 (indicating that the uncertainty of the prediction is at a moderate level).
[0026] S12. Based on the medical text modality, extract textual evidence features related to the target drug pair, and encode the textual evidence features through the second variational inference head structure to obtain the second probability distribution parameters; Specifically, for step S12, the focus shifts to the medical text modality. For the target drug pair, relevant textual evidence features are collected and extracted. These textual evidence features come from various medical text resources, including case reports of drug combination use, pharmacological mechanism analyses, and clinical research literature. They represent important textual information reflecting the risk of drug pair conflict. After extracting the textual evidence features, they are input into a pre-constructed second variational inference head structure. Through the encoding processing of this structure, the unstructured textual evidence features are transformed into quantifiable second probability distribution parameters. These parameters also include a second prediction mean parameter and a second cognitive uncertainty variance parameter, corresponding to the core prediction results of the drug pair conflict risk under the text modality and the reliability of this prediction, respectively.
[0027] For example, let's still use "aspirin" and "ginkgo leaf extract" as the target drug pair. In the medical text modality, the extracted textual evidence features include: case descriptions from multiple clinical studies documenting increased bleeding risk in patients after combined use of the two drugs, and explanations from pharmacological analyses regarding the mechanism of action of both drugs in inhibiting platelet aggregation. After encoding these textual evidence features into the second variational inference head structure, the second probability distribution parameters are obtained: the second prediction mean parameter μ2 = 0.9 (strongly indicating a risk of compatibility conflict), and the second cognitive uncertainty variance parameter σ2² = 0.1 (indicating low uncertainty in the prediction and more reliable results).
[0028] This embodiment clarifies the feature extraction directions and encoding paths of the knowledge graph modality and the medical text modality, and uses a variational inference head structure to achieve accurate conversion of different types of features into probability distribution parameters. This makes the prediction of conflict risks and the quantification of uncertainty in the two modalities more targeted and accurate, providing high-quality and quantifiable basic data for subsequent multimodal fusion based on Bayesian inference rules, and further ensuring the reliability of drug compatibility conflict detection.
[0029] Furthermore, in some embodiments, step S11, "based on the knowledge graph modality, extracting the graph structure features related to the target drug pair, and encoding the graph structure features through a first variational inference head structure to obtain a first probability distribution parameter," may specifically include: S111. Obtain a k-hop neighbor subgraph centered on the drug entity in the target drug pair from the heterogeneous drug knowledge graph, where k≥2; Specifically, for step S111, the heterogeneous drug knowledge graph is first identified. This graph contains various types of relationships, such as drug-target, drug-side effects, drug-indications, and drug-drug relationships, covering multi-dimensional structured information related to drugs. For the identified target drug pair, each drug entity is used as an independent central node, and neighbor nodes are searched in the aforementioned heterogeneous drug knowledge graph. The search scope is set to k hops (k≥2), which includes not only 1-hop neighbor nodes directly connected to the drug entity (such as the drug's direct target and direct side effects), but also 2-hop or higher neighbor nodes indirectly connected through 1-hop neighbor nodes (such as other pathways associated with the target and complications related to side effects). These central nodes, neighbor nodes, and their relationships together form a complete subgraph, namely the k-hop neighbor subgraph. This subgraph can comprehensively capture the potential relationship structure of the target drug pair in the knowledge graph, avoiding information omissions caused by only considering direct relationships.
[0030] For example, let's define the target drug pair as "aspirin" and "ginkgo biloba extract," with k=2. In the heterogeneous drug knowledge graph, with "aspirin" as the central node, 1-hop neighbor nodes include "antiplatelet aggregation target," "gastrointestinal irritation side effects," and "antipyretic and analgesic indications." 2-hop neighbor nodes include "thrombosis prevention pathway" associated through "antiplatelet aggregation target," and "mucosal injury complications" associated through "gastrointestinal irritation side effects." With "ginkgo biloba extract" as the central node, 1-hop neighbor nodes include "platelet regulation pathway," "indication for improving blood circulation," and "minor bleeding risk side effects." 2-hop neighbor nodes include "coagulation factor synergistic entity" associated through "platelet regulation pathway," and "cardiovascular and cerebrovascular disease treatment scenario" associated through "indication for improving blood circulation." Integrating the above two central nodes and all neighbor nodes within their 2-hop range, along with various relationships, forms a 2-hop neighbor subgraph for this drug pair.
[0031] S112. The graph structure feature vector of the target drug pair is obtained by processing the neighbor subgraph through a graph neural network encoder. Specifically, in step S112, the acquired k-hop neighbor subgraph is input into a pre-constructed graph neural network encoder. This encoder can identify the type of each entity in the subgraph, the type and strength of the relationships between entities, and perform in-depth mining and integration of this structured information. Through the encoder's computational processing, the complex network structure in the subgraph is transformed into a one-dimensional, quantifiable vector form, namely, the graph structure feature vector. This vector can condense and represent the core structural relationship information of the target drug pair in the knowledge graph, such as the degree of association between the drug and key targets, the similarity of their shared pathways, and the association patterns of potentially conflict-related entities, providing structured feature support for subsequent conflict risk prediction.
[0032] For example, the obtained 2-hop neighbor subgraphs of "aspirin" and "ginkgo leaf extract" are input into a graph neural network encoder. The encoder first analyzes the type of entity association in the subgraph, distinguishing different associations such as "drug-target," "drug-pathway," and "drug-side effect." Then, it quantifies the association strength; for example, the association strength between aspirin and the antiplatelet aggregation target is 0.9 (strong association), and the association strength between ginkgo leaf extract and the platelet regulatory pathway is 0.85 (strong association). Subsequently, it identifies the core structural feature that both have a strong association with entities related to "platelet function regulation." Finally, the encoder outputs a graph structural feature vector, such as [0.9, 0.85, 0.7, 0.65, ...], where each dimension corresponds to a different quantified value of the structural feature, which centrally reflects the core information of the structural association of the drug pair in the knowledge graph.
[0033] S113. Input the graph structure feature vector into the first variational inference head structure to map and obtain the first probability distribution parameter containing the first prediction mean parameter and the first cognitive uncertainty variance parameter; Specifically, in step S113, the obtained graph structure feature vector is input into the first variational inference head structure. This structure can analyze and transform the core information in the feature vector, and output the first probability distribution parameter composed of two key parameters. The first prediction mean parameter quantifies the core prediction result of the risk of compatibility conflict between the target drug pair; its value directly reflects the degree of tendency towards conflict risk (the higher the value, the stronger the tendency towards conflict). The first cognitive uncertainty variance parameter is a quantitative representation of the reliability of the prediction result; the smaller the value, the more reliable the prediction based on the current knowledge graph structure information, and the lower the cognitive uncertainty; the larger the value, the lower the reliability of the prediction, and the higher the cognitive uncertainty.
[0034] For example, the feature vectors [0.9, 0.85, 0.7, 0.65, ...] of the graph structure of "aspirin" and "ginkgo leaf extract" are input into the first variational inference head structure. This structure parses the core information in the feature vector that "both are strongly associated with entities related to platelet function regulation," and maps and outputs the first prediction mean parameter μ1=0.75 (indicating a tendency for compatibility conflict risk). At the same time, based on the completeness of the subgraph structure in the graph and the sufficiency of the association information, the first cognitive uncertainty variance parameter σ1²=0.18 is output (indicating that the cognitive uncertainty of the prediction is at a moderately low level, and the prediction based on the graph structure information is relatively reliable).
[0035] This embodiment obtains the comprehensive association structure information of the target drug pair in the knowledge graph through the k-hop neighbor subgraph, accurately extracts the core structural features with the help of the graph neural network encoder, and then realizes the transformation of the feature vector probability distribution parameters through the first variational inference head structure. This makes the conflict risk prediction and uncertainty quantification in the knowledge graph mode more targeted and accurate, and provides high-quality structured data support for drug compatibility conflict detection.
[0036] Furthermore, in some embodiments, before step S111 "obtaining the k-hop neighbor subgraph centered on the drug entity in the target drug pair", the method may further include: Search for the entity identifiers of the target drug pair in the heterogeneous drug knowledge graph; If any drug entity identifier in the target drug pair does not exist, the first cognitive uncertainty variance parameter is set to a preset maximum value so that the weight of the first probability distribution parameter in the subsequent fusion step approaches zero.
[0037] Specifically, before retrieving the k-hop neighbor subgraph of the target drug pair from the heterogeneous drug knowledge graph, an entity identifier query operation is first performed. The heterogeneous drug knowledge graph contains a massive number of drug entities, each corresponding to a unique entity identifier. This identifier is the core index for locating the relevant association information of the drug entity in the knowledge graph, ensuring accurate association with structured data such as the drug's target, indications, and side effects. The query process requires matching and searching each drug entity in the target drug pair one by one in the entity index of the heterogeneous drug knowledge graph to confirm whether each drug entity has a corresponding unique identifier in the knowledge graph. For example, let's define the target drug pair as "novel experimental drug M" and "clopidogrel". When performing a query operation on this drug pair, searching for "clopidogrel" in the entity index of the heterogeneous drug knowledge graph successfully matched the unique entity identifier "ID-C001", indicating that the drug entity has complete structured association information in the knowledge graph. However, when searching for "novel experimental drug M", no corresponding entity identifier was found in the index, indicating that the drug entity is not included in the current heterogeneous drug knowledge graph and its related graph structure information cannot be obtained.
[0038] After completing the query, the query results are evaluated. If both drug entities in the target drug pair have corresponding entity identifiers, it indicates that the knowledge graph contains relevant structured information about the drug pair, and the process can proceed to the subsequent k-hop neighbor subgraph acquisition step. If at least one drug entity in the target drug pair does not have a corresponding entity identifier, it indicates that the knowledge graph lacks structured association data for that drug, and a reliable conflict risk prediction result cannot be generated based on the knowledge graph modality. In this case, to objectively reflect the information deficiency state of this modality, the first cognitive uncertainty variance parameter needs to be set to a preset maximum value. This quantifies the extremely high uncertainty of the prediction result under the knowledge graph modality, so that the weight of the first probability distribution parameter in the subsequent fusion step approaches zero. For example, if no entity identifier is found for "novel experimental drug M" in the target drug pair, it meets the condition that "no drug entity identifier exists." The preset maximum value is 1000, so the first cognitive uncertainty variance parameter is set to 1000. This maximum value clearly reflects that, based on the current knowledge graph modality, due to the lack of relevant structured information on "novel experimental drug M", it is impossible to reliably predict the compatibility conflict risk between "novel experimental drug M" and "clopidogrel", and the prediction uncertainty of this modality is at an extremely high level.
[0039] This embodiment can accurately identify information missing scenarios in the knowledge graph modality by querying the entity identifiers of the target drug pair in the knowledge graph in advance and handling the missing cases. By setting a maximum value to quantify the high uncertainty in this scenario, it ensures that the first probability distribution parameter can truly reflect the information reliability of the knowledge graph modality, which provides an important guarantee for the accuracy of subsequent multimodal fusion and the final detection results.
[0040] Furthermore, in some embodiments, step S12, "based on the medical text modality, extracting textual evidence features related to the target drug pair, and encoding the textual evidence features through a second variational inference head structure to obtain a second probability distribution parameter," may specifically include: S121. A hybrid retrieval strategy is adopted to retrieve and filter the set of textual evidence related to the target drug pair from the medical literature database; Specifically, for step S121, for the identified target drug pair, a hybrid search strategy is employed to conduct a search using a vast medical literature database containing clinical research reports, pharmacological mechanism analyses, case reports, and safety evaluations of drug combinations. This hybrid search strategy combines the advantages of different search methods, accurately matching keyword-related literature while capturing semantic-level connections, ensuring the comprehensiveness and relevance of the search results. After the search is completed, medical entity linking technology is used to filter the preliminary search results, eliminating literature that is not directly related to the target drug pair, contains redundant information, or deviates from the topic, ultimately selecting a set of textual evidence that reflects the potential compatibility risks of the drug pair.
[0041] For example, the target drug pair was set as "aspirin and ginkgo biloba extract". When searching the medical literature database using a hybrid search strategy, on the one hand, relevant literature was retrieved through keyword matching (such as "aspirin + ginkgo biloba extract + combination" or "aspirin + bleeding risk + ginkgo biloba"), and on the other hand, semantic search was used to capture literature with semantic associations such as "antiplatelet drugs + plant extracts + synergistic effects". After initially obtaining 100 articles, 60 articles were filtered using medical entity linking technology to remove those that only discussed the side effects of aspirin alone or the pharmacological effects of ginkgo biloba extract alone, which were irrelevant to the combination of the two drugs. Finally, a set of 40 articles containing textual evidence including cases of bleeding from the combination of the two drugs, pharmacological mechanism analysis, and clinical safety evaluation was obtained.
[0042] S122. The text evidence set is processed by a medical pre-trained language model to obtain the text evidence feature vector of the target drug pair; Specifically, in step S122, the selected set of textual evidence is input into a pre-trained medical language model. This model, trained on a large amount of biomedical corpus, is capable of accurately understanding professional content such as medical terminology, descriptions of pharmacological mechanisms, and clinical case logic. The model extracts, integrates, and quantifies core information from the textual evidence (such as adverse reactions after drug combination, mutual influence of target sites, and dose-related risk changes), transforming unstructured textual information into a structured, computable one-dimensional vector form—the textual evidence feature vector. This vector condenses the core feature information related to drug compatibility conflicts within the textual modality, providing quantitative support at the textual level for subsequent risk prediction.
[0043] For example, the obtained set of 40 textual evidences is input into a medical pre-trained language model. The model analyzes the core content of each document: 25 documents record adverse reactions such as gingival bleeding and gastrointestinal bleeding in patients after the combined use of the two drugs; 10 documents indicate that both drugs have pharmacological effects of inhibiting platelet aggregation; and 5 documents clearly state that the combined use exhibits a synergistic effect. The model quantifies and integrates this information, and finally outputs a textual evidence feature vector, such as [0.92, 0.88, 0.76, 0.63, ...], where each dimension corresponds to the quantified value of core features such as "incidence of adverse reactions," "consistency of pharmacological effects," and "strength of synergistic effect."
[0044] S123. The text evidence feature vector is mapped through the second variational inference head structure to obtain the second probability distribution parameter, which includes the second prediction mean parameter and the second cognitive uncertainty variance parameter; Specifically, in step S123, the obtained textual evidence feature vector is input into the second variational inference head structure. This structure can deeply analyze the core risk information in the feature vector and transform it into quantitative parameters that can directly characterize the risk of drug incompatibility conflicts and the reliability of predictions. Among them, the second prediction mean parameter is the core prediction result of the risk of incompatibility conflicts between the target drug pair. The higher the value, the more obvious the tendency of conflict risk based on textual evidence. The second cognitive uncertainty variance parameter is used to characterize the reliability of the prediction result. The smaller the value, the more sufficient the textual evidence, the more reliable the prediction, and the lower the cognitive uncertainty; conversely, it indicates insufficient textual evidence support and higher prediction uncertainty.
[0045] For example, the textual evidence feature vector [0.92, 0.88, 0.76, 0.63, ...] of "aspirin and ginkgo biloba extract" is input into the second variational inference head structure. Based on the core information in the feature vector, such as "high incidence of adverse reactions" and "consistent and synergistic pharmacological effects", the structure maps and outputs the second prediction mean parameter μ2=0.91 (strongly indicating that there is a risk of incompatibility conflict when the two are used together); at the same time, combined with the size of the textual evidence set (40 articles) and the consistency of evidence (most articles point to the same risk), the second cognitive uncertainty variance parameter σ2²=0.09 is output (indicating that the cognitive uncertainty of the prediction is low and the textual evidence strongly supports the prediction).
[0046] This embodiment uses a hybrid retrieval strategy to accurately filter textual evidence highly relevant to the target drug pair, efficiently extracts core textual features using a medical pre-trained language model, and then transforms the feature vectorization probability distribution parameters through a second variational inference head structure. This makes the prediction of conflict risk and the quantification of uncertainty in the medical text modality more accurate and reliable, providing high-quality textual basic data for subsequent multimodal fusion and ensuring the overall accuracy of drug compatibility conflict detection.
[0047] Furthermore, in some embodiments, step S20, "fusing the first probability distribution parameters and the second probability distribution parameters based on Bayesian inference rules to generate a joint uncertainty scalar for the target drug pair," may specifically include: S21. Calculate the first precision corresponding to the first probability distribution parameter and the second precision corresponding to the second probability distribution parameter respectively; Specifically, for step S21, it is first clarified that the first probability distribution parameters include the first prediction mean parameter and the first cognitive uncertainty variance parameter, and the second probability distribution parameters include the second prediction mean parameter and the second cognitive uncertainty variance parameter. Accuracy is the core indicator for measuring the reliability of the probability distribution, and it is inversely proportional to the cognitive uncertainty variance; that is, the smaller the variance, the higher the accuracy, indicating that the prediction result under that mode is more reliable. In the calculation, the reciprocal of the first cognitive uncertainty variance parameter is used as the first accuracy, and the reciprocal of the second cognitive uncertainty variance parameter is used as the second accuracy. This calculation achieves a quantitative characterization of the prediction reliability of the two modes.
[0048] For example, the first probability distribution parameter for the target drug pair “aspirin and ginkgo biloba extract” is set as (first prediction mean μ1=0.7, first cognitive uncertainty variance σ1²=0.2), and the second probability distribution parameter is set as (second prediction mean μ2=0.9, second cognitive uncertainty variance σ2²=0.1). The first precision is calculated as: λ1=1 / σ1²=1 / 0.2=5; the second precision is calculated as: λ2=1 / σ2²=1 / 0.1=10. The results show that the precision (10) of the medical text modality is higher than that of the knowledge graph modality (5), that is, the prediction of the text modality is more reliable.
[0049] S22. Using the first precision and the second precision as weights, perform a weighted average of the first prediction mean parameter and the second prediction mean parameter to calculate the joint prediction mean; Specifically, in step S22, the obtained first and second accuracies are used as weights and multiplied by the corresponding first and second prediction mean parameters, respectively. The two products are then summed, and finally divided by the sum of the two accuracies to obtain the joint prediction mean. The core of this weighted average logic is to give greater weight to modes with higher reliability (greater accuracy) in the joint prediction result, making the joint prediction mean more closely match the prediction trend of high-confidence modes, thus ensuring the objectivity and accuracy of the fusion result.
[0050] For example, with a first precision λ1=5 and a first prediction mean μ1=0.7, and a second precision λ2=10 and a second prediction mean μ2=0.9, the joint prediction mean is calculated using the weighted average formula: μjoint = (λ1×μ1+λ2×μ2) / (λ1+λ2) = (5×0.7+10×0.9) / (5+10) = (3.5+9) / 15 = 12.5 / 15≈0.83. This result (0.83) is closer to the prediction mean of the text modality (0.9), demonstrating the dominant role of the high-precision modality in the joint prediction result.
[0051] S23. Calculate the reciprocal of the sum of the first precision and the second precision, and take the square root of the reciprocal to obtain the joint uncertainty scalar; Specifically, for step S23, firstly, the sum of the first precision and the second precision is calculated, which reflects the reliability level of the two modal integrations; then, the reciprocal of this sum is taken to obtain the quantified value of the joint variance; finally, the square root of this reciprocal is taken to obtain the joint uncertainty scalar. This scalar is a comprehensive quantification of the overall prediction uncertainty after multimodal fusion. The smaller the scalar value, the higher the confidence and the lower the uncertainty of the fused prediction result; conversely, the larger the value, the lower the overall confidence and the higher the uncertainty.
[0052] For example, with a first precision λ1=5 and a second precision λ2=10, the sum of the two is λ_total = 5 + 10 = 15. Calculating the reciprocal of this sum: 1 / λ_total = 1 / 15 ≈ 0.0667; taking the square root of this reciprocal gives the joint uncertainty scalar: σ_joint = √(1 / 15) ≈ 0.258. This value indicates that, after multimodal fusion, the overall uncertainty in predicting the compatibility conflict risk of "aspirin and ginkgo biloba extract" is low, and the confidence level is high.
[0053] This embodiment fully reflects the differences in prediction reliability among different modalities through a weighted fusion logic with accuracy as the weight, making the joint prediction mean more consistent with high-confidence information. At the same time, it accurately quantifies the overall uncertainty after fusion, providing an objective and reliable quantitative basis for subsequent control of the output of the large language model based on the confidence level, and ensuring the accuracy of drug compatibility conflict detection results.
[0054] Furthermore, in some embodiments, step S30, "generating corresponding control commands based on the comparison results between the joint uncertainty scalar and preset rules, and inputting the control commands into the pre-trained large language model to control the large language model to output drug conflict detection results that match the joint uncertainty scalar," may specifically include: S31. Compare the joint uncertainty scalar with a preset first cutoff threshold and a preset second cutoff threshold respectively, and generate a comparison result, wherein the preset first cutoff threshold is higher than the preset second cutoff threshold; Specifically, for step S31, two cutoff thresholds with clear discriminative power are pre-defined. The first cutoff threshold is used to define the scenario of "severely insufficient evidence and extremely high uncertainty," and the second cutoff threshold is used to define the scenario of "sufficient evidence and extremely low uncertainty." The value of the first cutoff threshold is always higher than that of the second cutoff threshold. The previously generated joint uncertainty scalar is used as a comparison object and compared with these two preset thresholds. Based on the comparison results, the confidence interval of the scalar is determined, and three types of comparison results are generated: first, the joint uncertainty scalar is higher than the first cutoff threshold; second, the joint uncertainty scalar is lower than the second cutoff threshold; and third, the joint uncertainty scalar is between the first and second cutoff thresholds.
[0055] For example, a first cutoff threshold is preset to 0.8, and a second cutoff threshold is preset to 0.3 (satisfying the requirement that the first threshold is higher than the second threshold). If the joint uncertainty scalar of the target drug pair "aspirin and ginkgo biloba extract" is 0.258, and after comparison, 0.258 < 0.3 is found, generating a comparison result of "scalar is lower than the second cutoff threshold"; if the joint uncertainty scalar of a drug pair is 0.9, and after comparison, 0.9 > 0.8, generating a comparison result of "scalar is higher than the first cutoff threshold"; if the joint uncertainty scalar of a drug pair is 0.5, and after comparison, 0.3 < 0.5 < 0.8, generating a comparison result of "scalar is between the two thresholds".
[0056] S32. Based on the comparison results, generate the corresponding control commands; Specifically, for step S32, appropriate control instructions are formulated for the three types of comparison results generated, ensuring that the content of the instructions matches the confidence level. For results where "the scalar is higher than the first cutoff threshold," the control instructions should focus on "avoiding false generation," explicitly requiring the model not to fabricate information and to truthfully state the state of evidence. For results where "the scalar is lower than the second cutoff threshold," the control instructions should focus on "detailed output," requiring the model to fully explain the core information and related suggestions. For results where "the scalar is between the two thresholds," the control instructions should focus on "cautious expression," requiring the model to use non-deterministic language to indicate potential risks and not to make absolute conclusions.
[0057] For example, if the scalar value is 0.9 (above the first threshold of 0.8), the control instruction is generated: "Current evidence is insufficient; fabricating pharmacological mechanisms is prohibited. Please explicitly reply 'No clear evidence of interaction'." If the scalar value is 0.258 (below the second threshold of 0.3), the control instruction is generated: "Based on high-confidence evidence, please explain the drug interaction mechanism in detail and output clinical recommendations in the standard format." If the scalar value is 0.5 (between the two thresholds), the control instruction is generated: "The existing evidence has some uncertainty. Please use expressions such as 'may exist' or 'further verification is needed' to indicate potential risks and not to draw definitive conclusions."
[0058] S33. Inject control commands as system prompts or command prefixes into the large language model to constrain the large language model to strictly follow the deterministic requirements and content framework in the control commands to generate the final drug conflict detection response text as the drug conflict detection result. Specifically, in step S33, the generated control instructions are directly input into the pre-trained large language model as system prompts or instruction prefixes. These control instructions serve as hard constraints, limiting the output logic of the large language model: on the one hand, the model is required to strictly adhere to the deterministic requirements in the instructions (such as prohibiting fabrication, requiring detailed explanation, and requiring careful expression), and must not deviate from the constraints; on the other hand, the model is required to organize language according to the content framework set by the instructions, ensuring that the output content highly matches the instruction requirements. Finally, the drug conflict detection response text generated by the large language model based on these constraints is the final result of this detection.
[0059] For example, if the input control instruction is "Based on high-confidence evidence, please explain the drug interaction mechanism in detail and output clinical recommendations in the standard format," the large language model will strictly follow this instruction and output the response text: "[High-confidence prompt] Both Ginkgo biloba extract and aspirin have the effect of inhibiting platelet aggregation. When used together, they will produce a synergistic effect and significantly increase the risk of bleeding. Clinical recommendation: Discontinue the use of Ginkgo biloba extract, or monitor coagulation function indicators under the guidance of a doctor."; if the input control instruction is "Current evidence is insufficient, do not fabricate pharmacological mechanisms, please clearly reply 'No clear evidence of interaction'", the large language model will directly output: "No clear evidence of interaction"; if the input control instruction is "The existing evidence has some uncertainty, please use expressions such as 'may exist' or 'further verification is needed' to indicate potential risks, and do not draw definitive conclusions", the large language model will output: "There may be potential drug incompatibility risks, which need to be further verified in combination with actual clinical scenarios. It is not recommended to use them blindly at this time."
[0060] This embodiment clarifies the confidence level of the joint uncertainty scalar by comparing hierarchical thresholds, and then generates control instructions to constrain the output of the large language model. This ensures that the model can output detection results that conform to the sufficiency of evidence under different confidence scenarios, effectively avoiding the generation of false information and improving the rigor and reliability of drug compatibility conflict detection.
[0061] Furthermore, in some embodiments, the method may further include: S311. Identify the clinical risk level of the target drug in relation to the corresponding drug; S312. Adjust the first cutoff threshold and the second cutoff threshold dynamically according to the clinical risk level.
[0062] Specifically, for each identified target drug pair, the clinical risk level of each drug is identified. The classification of clinical risk levels is determined based on the clinical usage characteristics of the drugs, with core reference dimensions including but not limited to: the therapeutic index (the ratio of effective dose to toxic dose), the severity of adverse reactions (e.g., whether they are life-threatening or cause irreversible damage), the sensitivity of the user population (e.g., the risk of drug use in special populations), and the risk of drug abuse. Combining clinical practice guidelines, drug instructions, and medical consensus, the clinical risk levels of the drugs are classified into high, medium, and low categories to ensure that the classification objectively reflects the severity of the potential risks after combined drug use.
[0063] A set of baseline cutoff thresholds (first cutoff threshold and second cutoff threshold) is pre-defined, based on general clinical safety requirements. After identifying the clinical risk level of the target drug pair, the two cutoff thresholds are dynamically adjusted according to the corresponding adjustment rules: For high-risk drug pairs, the rigor of the test needs to be improved, so the second cutoff threshold is lowered (requiring higher confidence to output a "confident" result), and the first cutoff threshold is moderately lowered (to trigger "defensive statements" earlier and avoid risk output when evidence is insufficient); for medium-risk drug pairs, the baseline thresholds remain unchanged to balance the rigor and practicality of the test; for low-risk drug pairs, the thresholds can be appropriately relaxed, the second cutoff threshold is raised (allowing relevant suggestions to be output with moderate confidence), and the first cutoff threshold is raised (reducing unnecessary "defensive statements" and improving test efficiency).
[0064] This embodiment identifies the clinical risk level of drugs and dynamically adjusts the cutoff threshold, so that the judgment criteria for the joint uncertainty scalar are adapted to the actual clinical risk of the drugs. The detection of high-risk drug combinations is more rigorous, and the detection of low-risk drug combinations is more flexible, thereby further improving the clinical suitability and safety reliability of drug compatibility conflict detection.
[0065] Furthermore, in some embodiments, the training method for the large language model may specifically include: S41. Construct a fine-tuning instruction dataset, which contains triplets consisting of evidence text, uncertainty labels, and target responses corresponding to uncertainty labels; Specifically, for step S41, firstly, a massive amount of relevant medical evidence resources are collected around the drug compatibility conflict detection scenario, and evidence texts are extracted and formed. These texts must accurately reflect information related to the potential interactions between drug pairs (such as descriptions of pharmacological mechanisms, clinical case data, and records of combined use risks). Then, each piece of evidence text is labeled with a corresponding uncertainty tag. The tags need to be quantitatively set according to the sufficiency and reliability of the evidence (e.g., divided into high, medium, and low confidence levels, or represented by specific numerical ranges). Finally, for different uncertainty tags, corresponding target responses are manually labeled. The response style must match the tag, specifically divided into three categories: "Refusal to answer" (suitable for scenarios with severely insufficient evidence and extremely high uncertainty), "Cautious speculation" (suitable for scenarios with insufficient evidence and some uncertainty), and "Detailed argumentation" (suitable for scenarios with sufficient evidence and extremely low uncertainty). Each piece of evidence text, its corresponding uncertainty tag, and the target response are combined to form triplet data. After batch integration, a complete instruction fine-tuning dataset is constructed, providing targeted sample support for model training.
[0066] S42. The low-rank adaptation algorithm is used to freeze the backbone parameters of the large language model, and low-rank adaptation matrices are inserted and trained in some network layers of the large language model. The instruction fine-tuning dataset is used to train the model. Specifically, for step S42, a pre-trained large language model is selected as the base model. To avoid damaging the model's original understanding of general language and medical expertise during training, the backbone network parameters are frozen (i.e., the backbone network weights are no longer updated). Subsequently, a low-rank adaptation algorithm is used. In the Transformer layer of the large language model, a trainable low-rank adaptation matrix is inserted into the Query and Value matrices. The rank of this matrix is set to a reasonable range (e.g., 8-64). The parameters of this low-rank matrix are trained only to adapt to the specific task of drug compatibility conflict detection, achieving lightweight training (without updating the large backbone parameters, reducing training costs and computational resource consumption). Finally, the instruction fine-tuning dataset constructed in step 1 is input into the model, using triples as training units, allowing the model to learn the mapping relationship between "evidence text - uncertainty label - target response," gradually mastering the ability to adjust the output style according to the uncertainty label.
[0067] S43. During model training, a loss function combining cross-entropy loss and response style consistency penalty term is used for optimization; Specifically, for step S43, during the optimization phase of model training, a composite loss function integrating two types of losses is designed. The cross-entropy loss measures the difference between the model's predicted output and the target response at the content level, ensuring that the core information in the model's output (such as risk conclusions and suggested directions) accurately matches the target response and avoids content deviation. The response style consistency penalty term constrains the style of the model's output to remain consistent with the style of the target response corresponding to the uncertainty label. If the model's output style does not match the label (e.g., outputting a "cautious speculation" style for a "high confidence" label, or an "extensive argumentation" style for a "very low confidence" label), a penalty is triggered, increasing the loss value. Through backpropagation of this composite loss function, the low-rank adaptation matrix parameters of the model are continuously adjusted to optimize both content accuracy and style fit.
[0068] This embodiment constructs a targeted triplet instruction fine-tuning dataset, combines a low-rank adaptation algorithm to achieve lightweight model training, and then uses a composite loss function to ensure the accuracy and style adaptability of the output content. This enables the large language model to accurately understand uncertain instructions and flexibly adjust the response style according to different confidence levels. This provides reliable model support for subsequent matching detection results based on joint uncertainty scalar output, improving the accuracy and adaptability of drug compatibility conflict detection response.
[0069] To facilitate understanding of the drug compatibility conflict safety detection method based on uncertainty quantification provided in this embodiment, this embodiment also provides a specific implementation method for the drug compatibility conflict safety detection method based on uncertainty quantification, such as... Figure 3 As shown, firstly, graph neural networks and text retrieval models are used to map the structural features of drugs in the knowledge graph and the textual features in medical literature to Gaussian probability distributions containing mean and variance, respectively. Then, the Bayesian Expert Product (PoE) rule is used to jointly infer the multimodal distributions, and a global uncertainty score is derived based on the joint accuracy. Finally, a mapping relationship between the uncertainty score and the model response mode is established, controlling the large language model, after parameter efficient fine-tuning (PEFT), to automatically switch between a confident generation mode and a defensive claim mode. This embodiment ensures the system's security under out-of-distribution (OOD) data through mathematical evidence fusion and hard gating mechanisms, effectively eliminating false generation phenomena in medical recommendations.
[0070] The specific implementation method of the drug compatibility conflict safety detection method based on uncertainty quantification provided in this embodiment is as follows: (1) Distributed mapping steps Data on target drug pairs to be detected are acquired, and a graph neural network encoder and a text retrieval encoder are constructed respectively. The graph neural network encoder is constructed based on a heterogeneous knowledge graph, wherein the defined edge relationship types include at least: drug-target interaction, drug-side effect association, drug-indication association, and drug-drug interaction; a k-hop neighbor sampling strategy with a fixed depth k (k≥2) is adopted, and an attention mechanism is introduced to dynamically aggregate neighbor information.
[0071] The text retrieval encoder employs a language model (such as PubMedBERT) pre-trained on a biomedical corpus. The retrieval strategy combines sparse retrieval (BM25) with semantic retrieval, and utilizes medical entity linking technology to filter the retrieval results. Both the graph neural network encoder and the text retrieval encoder's output layers are configured as variational inference head structures. This structure includes a shared feature extraction layer and two independent prediction heads, which map the drug subgraph features in the knowledge graph and the text features of medical literature to first Gaussian distribution parameters, respectively. Second Gaussian distribution parameters ,in Represents the predicted mean. This represents the variance of cognitive uncertainty that is positive after being constrained by the Softplus function.
[0072] In order to quantify cognitive uncertainty, this embodiment abandons the traditional deterministic vector output and instead outputs probability distribution parameters.
[0073] Graph Modalities: Heterogeneous graphs are processed using RGCN. To avoid mutual interference between the predicted mean and variance during backpropagation, the output layer is designed as a "dual-head structure," where the variance head is activated via Softplus. .
[0074] Text Modality: PubMedBERT was used for text encoding. For textual evidence, a semantic similarity-based retrieval augmentation (RAG) strategy was employed to extract the Top-N relevant document fragments. Subsequently, an evidence network was used to map the text embeddings to a Gaussian distribution.
[0075] (2) Expert product fusion steps like Figure 4 As shown, Figure 4 This is a schematic diagram illustrating the principle of Bayesian expert product (PoE). The PoE rule is used to jointly infer the parameters of the first and second Gaussian distributions. If any modality data is missing, the system sets its corresponding variance to infinity, thus reducing its weight to zero during fusion and supporting single-modality inference. The accuracy of the fused joint distribution is then calculated. ,in Defined as the sum of the distribution precision of each component, i.e. And based on the joint distribution accuracy, a global uncertainty scalar is derived. .
[0076] Bayesian expert product (PoE) fusion has the following advantages: Advantage 1 (Precision Weighting): PoE is based on Bayesian inference, and its joint distribution has high precision. Equal to the sum of the precision of each component ( This means that if a mode is highly uncertain ( It's very big. (It is very small), and its contribution to the fusion result will automatically decrease. This is more objective and mathematically interpretable than traditional manually designed attention weights.
[0077] Advantage 2 (Lack Robustness): When a certain mode is missing, the system does not require special filling. It only needs to set its variance to infinity (precision to 0), and the PoE formula can smoothly degenerate into single-modal inference, ensuring the availability of the system.
[0078] (3) Out-of-Distribution (OOD) Response Control Steps Pre-train a large language model that supports multi-level security instructions to establish the global uncertainty standard. The mapping relationship between the model and the response pattern.
[0079] Set tiered cutoff thresholds, which are dynamically adjusted based on the drug's clinical risk level; for example, setting a more stringent low threshold for drugs with a narrow therapeutic index. The calculated... Compare with a preset cutoff threshold. When When the first cutoff threshold is exceeded, a defensive system prompt is injected into the large language model: "Current evidence is insufficient (uncertainty score: X), please explicitly reply 'No clear evidence of interaction found,' and refrain from fabricating pharmacological mechanisms." Only when... When the threshold is below the second cutoff, a confidence prompt is injected into the large language model: "Based on high-confidence evidence (uncertainty score: Y), please explain the following interaction mechanism in detail and output clinical recommendations in JSON format." When the model falls between these two extremes, suggest using non-deterministic statements such as "may exist" or "requires further verification".
[0080] This embodiment not only yields a score, but also uses that score as a switch to control the behavior of the LLM.
[0081] OOD response control: By establishing The mapping to the Prompt template enables gating. In high-risk scenarios, the LLM degenerates into a conservative query tool; in low-risk scenarios, the LLM acts as a professional reasoning expert.
[0082] PEFT Fine-tuning: To enable the LLM to understand uncertain instructions, we constructed an instruction fine-tuning dataset containing different confidence level labels. We used LoRA technology to train the LLM in a lightweight manner, enabling it to adjust the tone and level of detail of the response according to the confidence level of the input.
[0083] The graph neural network encoder employs a relational graph convolutional network (RGCN) architecture, and its output layer is configured as a dual-head multilayer perceptron (MLP): Shared layer: Two fully connected layers using the ReLU activation function.
[0084] Mean Header: Single-layer linear mapping, outputs unconstrained real numbers.
[0085] Variance head: A single-layer linear mapping followed by a Softplus activation function. ( (where is a very small positive number) to prevent gradient vanishing and to separate the optimization path from the mean and variance.
[0086] In the expert product fusion step, the joint mean after fusion is calculated. The formula is: in , This formula uses the accuracy of each mode as a weight for a weighted average, so that the fusion result is automatically biased towards the mode with higher certainty (lower variance).
[0087] In this embodiment, the large language model is trained using the Parameter Efficient Fine-Tuning (PEFT) technique. The training process includes: Data Construction: Construct a fine-tuning dataset of instructions containing triples of <evidence text, uncertainty label, target response>; the target responses are manually labeled into three styles: "refusal to answer", "cautious speculation" and "detailed argumentation" based on the value range of the uncertainty label. Fine-tuning strategy: Utilize the Low-Rank Adaptation (LoRA) algorithm to freeze the backbone parameters of the large language model, inserting parameters with a rank of 0 only into the Query and Value matrices of the Transformer layer. Trainable low-rank matrices; Loss function: Combining cross-entropy loss with a consistency penalty for response style, enabling the model to learn based on the values embedded in the Prompt. Automatically switch output tone.
[0088] The method provided in this embodiment further includes a pre-filtering step: before the distributed mapping step, the entity identifiers of the target drug pair in the knowledge graph are retrieved. If the identifier of any drug entity does not exist, the corresponding... Set to a preset maximum value to ensure the accuracy of this component in subsequent expert product fusion steps. It approaches zero, thus making the fusion result completely dependent on another mode or degenerate into a state of high uncertainty.
[0089] To facilitate understanding of the drug compatibility conflict safety detection method based on uncertainty quantification provided in this embodiment, the core module of this embodiment is constructed in detail using mathematical methods.
[0090] (1) Probabilistic coding Assuming the input drug pair is For knowledge graph branches, feature extraction is performed using graph neural networks (such as RGCN). The output layer is mapped to the first Gaussian distribution: Among them, variance The activation function, Softplus, is constrained to be positive, and the formula is as follows: This operation ensures that the variance remains positive, effectively characterizing cognitive uncertainty.
[0091] Similarly, for text branches, the second Gaussian distribution is obtained using a medical pre-trained model. .
[0092] (2) Expert product fusion like Figure 4 As shown, the Bayesian expert product (PoE) rule is used to jointly infer the first Gaussian distribution parameters and the second Gaussian distribution parameters.
[0093] Define precision It is the reciprocal of the variance, i.e. .
[0094] According to Bayesian inference theory, it is assumed that the prior distribution is uniform and the posterior distribution is proportional to the likelihood product. For a Gaussian distribution, the joint distribution after fusion is still a Gaussian distribution.
[0095] The joint accuracy derived in this embodiment The calculation formula is: Calculate the joint mean after fusion The formula is: The formula uses the accuracy of each mode as a weight for weighted averaging, so that the fusion result is automatically biased towards the more certain mode (smaller variance and higher accuracy).
[0096] Finally, the global uncertainty scalar is derived. The formula is: Results analysis: If KG is very uncertain about the result (i.e.) Then its accuracy .at this time, ,and This means that the system automatically ignores non-informative modalities and relies entirely on informative modalities, thus achieving adaptive weighting.
[0097] (3) Uncertainty Gating Calculate global uncertainty scalar .
[0098] Define control function : like (Threshold T1): Prompt="If the evidence is insufficient, please clearly state that the risk is unknown." like (Threshold T2): Prompt="Based on high-confidence evidence, explain the interaction mechanism: [Evidence Summary]." For a specific embodiment, please refer to Figure 5 and Figure 6 , Figure 5 This is a flowchart illustrating the drug compatibility conflict safety detection algorithm provided in this embodiment. Figure 6 This is a schematic diagram of the uncertainty-driven LLM gating logic provided in this embodiment.
[0099] (1) Input The doctor looked up "aspirin" and "ginkgo leaf extract".
[0100] (2) Encoding KG branch: RGCN detected that although there is no direct connection between the two, they share the "anti-platelet aggregation" pathway, and output... (Slightly risky) (Moderately certain).
[0101] Text branch: Multiple bleeding case reports were retrieved; BERT output. , (Absolutely certain).
[0102] (3) Integration decision making (Safety threshold)
[0103] Activate "Confirmation Mode".
[0104] (5) Output LLM generated: "[Confidence Warning] Ginkgo biloba extract has antiplatelet activity and may have a synergistic effect when used in combination with aspirin, significantly increasing the risk of bleeding (confidence: high). It is recommended to discontinue the use of ginkgo biloba or monitor coagulation parameters."
[0105] In summary, compared with the prior art, the drug compatibility conflict safety detection method based on uncertainty quantification provided in this embodiment generates a joint uncertainty scalar by performing probability distribution encoding and Bayesian inference fusion on the knowledge graph modal data and medical text modal data of the target drug pair. The method then controls the output matching results of the pre-trained large language model based on the joint uncertainty scalar, thereby achieving safe detection of drug compatibility conflicts, effectively avoiding false interaction information, and improving the safety and reliability of the detection results. To facilitate better implementation of the drug compatibility conflict safety detection method based on uncertainty quantification in the embodiments of this application, this application also provides a drug compatibility conflict safety detection device based on uncertainty quantification, which is based on the aforementioned drug compatibility conflict safety detection method based on uncertainty quantification. The meanings of the terms used are the same as in the aforementioned drug compatibility conflict safety detection method based on uncertainty quantification, and specific implementation details can be found in the descriptions in the method embodiments.
[0106] Please see Figure 7 , Figure 7 This is a schematic diagram of the structure of a drug compatibility conflict safety detection device based on uncertainty quantification provided in an embodiment of this application. Specifically, the device may include an encoding module 201, a fusion module 202, and a detection module 203, as follows: The encoding module 201 is used to acquire target drug pairs and encode them based on knowledge graph modality and medical text modality respectively to obtain a first probability distribution parameter and a second probability distribution parameter that characterize the conflict risk of the target drug pairs; wherein, the probability distribution parameters each include a mean parameter that characterizes the prediction mean and a variance parameter that characterizes the variance of cognitive uncertainty. The fusion module 202 is used to fuse the first probability distribution parameters and the second probability distribution parameters based on Bayesian inference rules to generate a joint uncertainty scalar of the target drug pair; The detection module 203 is used to generate corresponding control commands based on the comparison results between the joint uncertainty scalar and the preset rules, and input the control commands into the pre-trained large language model to control the large language model to output drug conflict detection results that match the joint uncertainty scalar.
[0107] Furthermore, in some embodiments, the encoding module 201 is specifically used for: Based on the knowledge graph modality, the graph structure features related to the target drug pair are extracted, and the graph structure features are encoded through the first variational inference head structure to obtain the first probability distribution parameters; Based on medical text modalities, textual evidence features related to the target drug pair are extracted, and these textual evidence features are encoded through a second variational inference head structure to obtain second probability distribution parameters.
[0108] Furthermore, in some embodiments, the encoding module 201 is specifically used for: From the heterogeneous drug knowledge graph, obtain the k-hop neighbor subgraph centered on the drug entity in the target drug pair, where k≥2; The graph neural network encoder processes the neighbor subgraph to obtain the graph structure feature vector of the target drug pair; The feature vector of the graph structure is input into the first variational inference head structure, and the first probability distribution parameter containing the first prediction mean parameter and the first cognitive uncertainty variance parameter is obtained.
[0109] Furthermore, in some embodiments, the encoding module 201 is specifically used for: Search for the entity identifiers of the target drug pair in the heterogeneous drug knowledge graph; If any drug entity identifier in the target drug pair does not exist, the first cognitive uncertainty variance parameter is set to a preset maximum value so that the weight of the first probability distribution parameter in the subsequent fusion steps approaches zero.
[0110] Furthermore, in some embodiments, the encoding module 201 is specifically used for: A hybrid retrieval strategy was adopted to retrieve and filter the set of textual evidence related to the target drug pair from the medical literature database; By processing the text evidence set using a medical pre-trained language model, the text evidence feature vector of the target drug pair is obtained. The text evidence feature vector is mapped through the second variational inference head structure to obtain the second probability distribution parameters, which include the second prediction mean parameter and the second cognitive uncertainty variance parameter.
[0111] Furthermore, in some embodiments, the fusion module 202 is specifically used for: Calculate the first precision corresponding to the first probability distribution parameter and the second precision corresponding to the second probability distribution parameter, respectively. Using the first precision and the second precision as weights, a weighted average is calculated on the first prediction mean parameter and the second prediction mean parameter to obtain the joint prediction mean. Calculate the reciprocal of the sum of the first and second precisions, and take the square root of the reciprocal to obtain the joint uncertainty scalar.
[0112] Furthermore, in some embodiments, the detection module 203 is specifically used for: The joint uncertainty scalar is compared with a preset first truncation threshold and a preset second truncation threshold respectively to generate a comparison result, wherein the preset first truncation threshold is higher than the preset second truncation threshold; Based on the comparison results, the corresponding control commands are generated; Control commands are injected into the large language model as system prompts or command prefixes to constrain the large language model to strictly follow the deterministic requirements and content framework in the control commands, and generate the final drug conflict detection response text as the drug conflict detection result.
[0113] Furthermore, in some embodiments of this application, the detection module 203 is specifically used for: Identify the clinical risk level of the target drug in the corresponding drug pair; The first and second cutoff thresholds are dynamically adjusted based on the clinical risk level.
[0114] Furthermore, in some embodiments, a model training module is also included, specifically for: Construct a fine-tuning instruction dataset, which contains triples consisting of evidence text, uncertainty labels, and target responses corresponding to uncertainty labels; We employ a low-rank adaptation algorithm to freeze the backbone parameters of a large language model, insert and train low-rank adaptation matrices in some network layers of the large language model, and use instruction-based fine-tuning datasets for model training. During model training, a loss function combining cross-entropy loss and response style consistency penalty term is used for optimization.
[0115] For specific limitations regarding the drug compatibility conflict safety detection device based on uncertainty quantification, please refer to the limitations of the drug compatibility conflict safety detection method based on uncertainty quantification mentioned above, which will not be repeated here. Each module in the aforementioned drug compatibility conflict safety detection device based on uncertainty quantification can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the corresponding operations of each module.
[0116] The drug compatibility conflict safety detection device based on uncertainty quantification provided in this embodiment generates a joint uncertainty scalar by performing probability distribution encoding and Bayesian inference fusion on the knowledge graph modal data and medical text modal data of the target drug pair. Based on the joint uncertainty scalar, the device controls the output matching results of the pre-trained large language model to achieve safe detection of drug compatibility conflicts, effectively avoids false interaction information, and thus improves the safety and reliability of the detection results.
[0117] Furthermore, embodiments of this application also provide an electronic device, such as... Figure 8 As shown, it illustrates a structural schematic diagram of the electronic device involved in the embodiments of this application, specifically: The electronic device may include components such as a processor 301 with one or more processing cores, a memory 302 with one or more computer-readable storage media, a power supply 303, and an input unit 304. Those skilled in the art will understand that... Figure 8 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein: The processor 301 is the control center of the electronic device. It connects various parts of the electronic device via various interfaces and lines, and performs various functions and processes data by running or executing software programs and / or modules stored in the memory 302, and by calling data stored in the memory 302, thereby providing overall monitoring of the electronic device. Optionally, the processor 301 may include one or more processing cores; preferably, the processor 301 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 301.
[0118] The memory 302 can be used to store software programs and modules. The processor 301 executes various functional applications and a drug compatibility conflict safety detection method based on uncertainty quantification by running the software programs and modules stored in the memory 302. The memory 302 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 302 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 302 may also include a memory controller to provide the processor 301 with access to the memory 302.
[0119] The electronic device also includes a power supply 303 that supplies power to various components. Preferably, the power supply 303 can be logically connected to the processor 301 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 303 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0120] The electronic device may also include an input unit 304, which can be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0121] Although not shown, the electronic device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 301 in the electronic device loads the executable files corresponding to the processes of one or more applications into the memory 302 according to the following instructions, and the processor 301 runs the applications stored in the memory 302 to realize various functions, as follows: Target drug pairs are acquired and encoded based on knowledge graph modalities and medical text modalities, respectively, to obtain a first probability distribution parameter and a second probability distribution parameter characterizing the conflict risk of the target drug pairs. Each probability distribution parameter includes a mean parameter characterizing the predicted mean and a variance parameter characterizing the variance of cognitive uncertainty. The first and second probability distribution parameters are fused based on Bayesian inference rules to generate a joint uncertainty scalar for the target drug pairs. Based on the comparison between the joint uncertainty scalar and preset rules, corresponding control instructions are generated and input into a pre-trained large language model to control the large language model to output drug conflict detection results that match the joint uncertainty scalar.
[0122] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0123] This application embodiment generates a joint uncertainty scalar by performing probability distribution encoding and Bayesian inference fusion on the knowledge graph modal data and medical text modal data of the target drug pair. Based on the joint uncertainty scalar, the pre-trained large language model outputs matching results, thereby achieving safe detection of drug compatibility conflicts, effectively avoiding false interaction information, and thus improving the safety and reliability of the detection results.
[0124] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0125] Therefore, embodiments of this application provide a storage medium storing multiple instructions that can be loaded by a processor to execute steps in any of the drug compatibility conflict safety detection methods based on uncertainty quantification provided in embodiments of this application. For example, the instructions can execute the following steps: Target drug pairs are acquired and encoded based on knowledge graph modalities and medical text modalities, respectively, to obtain a first probability distribution parameter and a second probability distribution parameter characterizing the conflict risk of the target drug pairs. Each probability distribution parameter includes a mean parameter characterizing the predicted mean and a variance parameter characterizing the variance of cognitive uncertainty. The first and second probability distribution parameters are fused based on Bayesian inference rules to generate a joint uncertainty scalar for the target drug pairs. Based on the comparison between the joint uncertainty scalar and preset rules, corresponding control instructions are generated and input into a pre-trained large language model to control the large language model to output drug conflict detection results that match the joint uncertainty scalar.
[0126] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0127] The storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0128] Since the instructions stored in the storage medium can execute the steps in any of the drug compatibility conflict safety detection methods based on uncertainty quantification provided in the embodiments of this application, the beneficial effects that any of the drug compatibility conflict safety detection methods based on uncertainty quantification provided in the embodiments of this application can achieve can be realized, as detailed in the preceding embodiments, and will not be repeated here.
[0129] The above provides a detailed description of a drug compatibility conflict safety detection method and apparatus based on uncertainty quantification provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for detecting a drug compatibility conflict safety based on uncertainty quantification, characterized in that, include: Target drug pairs are acquired and encoded based on knowledge graph modalities and medical text modalities, respectively, to obtain a first probability distribution parameter and a second probability distribution parameter characterizing the conflict risk of the target drug pairs; wherein, each probability distribution parameter includes a mean parameter characterizing the prediction mean and a variance parameter characterizing the variance of cognitive uncertainty. The first probability distribution parameter and the second probability distribution parameter are fused based on Bayesian inference rules to generate a joint uncertainty scalar for the target drug pair; Based on the comparison result between the joint uncertainty scalar and the preset rules, a corresponding control command is generated, and the control command is input into the pre-trained large language model to control the large language model to output a drug conflict detection result that matches the joint uncertainty scalar.
2. The method for detecting the safety of the drug compounding conflict based on the uncertainty quantification according to claim 1, characterized in that, The process of acquiring target drug pair data and encoding the target drug pair data based on knowledge graph modalities and medical text modalities respectively to obtain a first probability distribution parameter and a second probability distribution parameter characterizing the conflict risk of the target drug pair includes: Based on the knowledge graph modality, graph structure features related to the target drug pair are extracted, and the graph structure features are encoded through a first variational inference head structure to obtain the first probability distribution parameters; Based on the medical text modality, textual evidence features related to the target drug pair are extracted, and the textual evidence features are encoded through a second variational inference head structure to obtain the second probability distribution parameters.
3. The method for detecting the incompatibility of drug combination based on uncertainty quantification according to claim 2, wherein, The step of extracting graph structure features related to the target drug pair based on the knowledge graph modality, and encoding the graph structure features through a first variational inference head structure to obtain the first probability distribution parameters includes: From the heterogeneous drug knowledge graph, obtain a k-hop neighbor subgraph centered on the drug entity in the target drug pair, where k≥2; The graph structure feature vector of the target drug pair is obtained by processing the neighbor subgraph through a graph neural network encoder. The feature vector of the graph structure is input into the first variational inference head structure to obtain the first probability distribution parameter, which includes the first prediction mean parameter and the first cognitive uncertainty variance parameter.
4. The method for detecting the incompatibility of drug combination based on uncertainty quantification according to claim 3, wherein, Prior to obtaining the k-hop neighbor subgraph centered on the drug entities in the target drug pair, the method further includes: Query the entity identifiers of the target drug pair in the heterogeneous drug knowledge graph; If any drug entity identifier in the target drug pair does not exist, the first cognitive uncertainty variance parameter is set to a preset maximum value so that the weight of the first probability distribution parameter in the subsequent fusion step approaches zero.
5. The method for detecting the incompatibility of drug combination based on uncertainty quantification according to claim 2, wherein, The step of extracting textual evidence features related to the target drug pair based on the medical text modality, and encoding the textual evidence features through a second variational inference head structure to obtain the second probability distribution parameters includes: A hybrid retrieval strategy is employed to retrieve and filter a set of textual evidence related to the target drug pair from a medical literature database; The text evidence set is processed by a medical pre-trained language model to obtain the text evidence feature vector of the target drug pair; The text evidence feature vector is mapped through the second variational inference head structure to obtain the second probability distribution parameter, which includes the second prediction mean parameter and the second cognitive uncertainty variance parameter.
6. The method for detecting the incompatibility of drug combination based on uncertainty quantification according to claim 1, wherein, The process of fusing the first probability distribution parameters and the second probability distribution parameters based on Bayesian inference rules to generate a joint uncertainty scalar for the target drug pair includes: Calculate the first precision corresponding to the first probability distribution parameter and the second precision corresponding to the second probability distribution parameter, respectively; Using the first precision and the second precision as weights, a weighted average is calculated on the first prediction mean parameter and the second prediction mean parameter to obtain the joint prediction mean. Calculate the reciprocal of the sum of the first precision and the second precision, and take the square root of the reciprocal to obtain the joint uncertainty scalar.
7. The method for detecting the incompatibility of drug combination based on uncertainty quantification according to claim 1, wherein, The step of generating corresponding control commands based on the comparison result between the joint uncertainty scalar and preset rules, and inputting the control commands into a pre-trained large language model to control the large language model to output drug conflict detection results that match the joint uncertainty scalar includes: The joint uncertainty scalar is compared with a preset first truncation threshold and a preset second truncation threshold respectively to generate a comparison result, wherein the preset first truncation threshold is higher than the preset second truncation threshold; Based on the comparison results, corresponding control commands are generated; The control instructions are injected into the large language model as system prompts or instruction prefixes to constrain the large language model to strictly follow the deterministic requirements and content framework in the control instructions to generate the final drug conflict detection response text as the drug conflict detection result.
8. The drug compatibility conflict safety detection method based on uncertainty quantification according to claim 7, characterized in that, The method further includes: Identify the clinical risk level of the corresponding drug in the target drug pair; The first cutoff threshold and the second cutoff threshold are dynamically adjusted based on the clinical risk level.
9. The drug compatibility conflict safety detection method based on uncertainty quantification according to claim 1, characterized in that, The pre-trained large language model is obtained by training a low-rank adaptation algorithm based on an instruction fine-tuning dataset, and includes: Construct an instruction fine-tuning dataset, which contains triples consisting of evidence text, uncertainty labels, and target responses corresponding to the uncertainty labels; The low-rank adaptation algorithm is used to freeze the backbone parameters of the large language model, and low-rank adaptation matrices are inserted and trained in some network layers of the large language model. The instruction fine-tuning dataset is used for model training. During model training, a loss function combining cross-entropy loss and response style consistency penalty term is used for optimization.
10. A drug compatibility conflict safety detection device based on uncertainty quantification, characterized in that, include: An encoding module is used to acquire target drug pairs and encode the target drug pairs based on knowledge graph modalities and medical text modalities respectively, to obtain a first probability distribution parameter and a second probability distribution parameter characterizing the conflict risk of the target drug pairs; wherein, each of the probability distribution parameters includes a mean parameter characterizing the prediction mean and a variance parameter characterizing the variance of cognitive uncertainty; The fusion module is used to fuse the first probability distribution parameters and the second probability distribution parameters based on Bayesian inference rules to generate a joint uncertainty scalar of the target drug pair; The detection module is used to generate corresponding control commands based on the comparison results between the joint uncertainty scalar and the preset rules, and input the control commands into the pre-trained large language model to control the large language model to output drug conflict detection results that match the joint uncertainty scalar.