Drug incompatibility detection method based on fusion of atlas and large language model
By constructing a method that integrates drug knowledge graphs with large language models, the problems of missed detection and limited coverage in drug incompatibility detection in existing technologies are solved, the identification and risk assessment of potential drug conflicts are achieved, the comprehensiveness and credibility of detection are improved, and it adapts to complex individualized medication scenarios.
Patent Information
- Application Number
- CN202510851263.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-24
- Publication Date
- 2025-10-10
AI Technical Summary
Existing drug incompatibility detection methods are unable to identify potential conflicts in knowledge graphs, lack the ability to model complex interaction mechanisms, are unable to meet the needs of individualized medication safety, and fail to effectively utilize unstructured text data.
By constructing a drug knowledge graph based on graph neural networks and contrastive learning mechanisms, combined with a pre-trained large language model, potential predictions and credibility scores of drug interactions are performed, and structured graph reasoning and semantic reasoning are integrated to generate the final incompatibility detection results.
It significantly reduces the probability of missed detection, improves the comprehensiveness and intelligence level of detection, enhances the modeling depth and clinical credibility of complex drug relationships, expands the boundaries of system recognition capabilities, and provides safety guarantees for personalized medication.
Smart Images

Figure CN120766860A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of drug incompatibility detection, and specifically relates to a drug incompatibility detection method based on the fusion of a graph and a large language model. Background Art
[0002] In the process of clinical treatment, in order to improve the treatment effect or cope with the complex situation of coexistence of multiple diseases, doctors often need to prescribe a combination of multiple drugs for patients. However, different drugs may interact with each other when used in combination, resulting in reduced efficacy, enhanced adverse reactions, and even serious toxic side effects. This phenomenon is called "drug incompatibility" or "polypharmacy conflict." Drug incompatibility includes not only mechanism conflicts such as antagonism, synergy, and metabolic inhibition at the pharmacological level, but also clinical individual difference factors such as compatibility ratio, patient constitution, and disease background. Therefore, accurate and comprehensive detection of drug incompatibility is a key technical link to ensure patient medication safety and improve treatment effects.
[0003] Traditional drug incompatibility detection methods mostly rely on expert-curated drug interaction tables or rule-based decision systems, whose rules are often derived from pharmacopoeias, guidelines, or clinical experience. While these methods offer some reference value, they are subject to delayed updates, limited coverage, and a lack of modeling capabilities for complex interaction mechanisms, making them incapable of meeting the increasingly complex needs of personalized medication safety.
[0004] In the prior art, Chinese patent CN119181464A discloses a multiple medication control method and system based on multi-database backup synchronization, which relates to the field of knowledge graph technology. By converting drug clinical data into a drug knowledge graph, the drug knowledge graph is saved in a main database and a backup database using a distributed consistency algorithm. For each group of drugs in a complete prescription, the interaction path is retrieved from the drug knowledge graph. If an interaction path exists, it is determined whether there is a pharmacological conflict for each group of drugs based on the interaction path. If a pharmacological conflict exists, each group of drugs with a pharmacological conflict is regarded as a conflicting drug combination. An action intensity model is constructed for the conflicting drug combination based on the drug knowledge graph. The prescription dosage of each drug in the conflicting drug combination is input to obtain an action intensity score. Based on the action intensity score, a control warning is issued to the patient; thereby improving the efficiency and accuracy of drug conflict warning.
[0005] However, the prior art has the following problems: 1. When there is no direct path connection between the drugs in the knowledge graph, it is not possible to further determine whether there is a potential incompatibility, and there is a risk of missing detection; 2. The method uses the existence of the path as the basis for judgment, without further analyzing the importance of different interaction types in the path, and without introducing the credibility or source quality indicators of the interaction data, which can easily result in insufficient reliability of the reasoning results; 3. The knowledge graph is mainly constructed based on structured clinical data, and there is a lack of effective extraction and fusion of text data (such as drug instructions, adverse reaction reports, clinical literature, etc.), the coverage of the graph is limited, and it is difficult to express complex semantic relationships.
[0006] Therefore, how to construct a new detection method that can combine the drug knowledge graph mining capability, realize intelligent identification of incompatibility paths, quantify the risk of drug combination, and take into account the distributed consistency of the system and individualized factors of patients, is a core technical problem that needs to be solved in the field of drug incompatibility detection. SUMMARY
[0007] The purpose of the present application is to overcome the defects of the prior art and provide a drug incompatibility detection method based on the fusion of a graph and a large language model.
[0008] The purpose of the present application can be achieved by the following technical solutions:
[0009] The present application provides a drug incompatibility detection method based on the fusion of a graph and a large language model, comprising the following steps:
[0010] Obtain the prescription data to be detected, the prescription data comprising a plurality of drug names to be detected for drug incompatibility;
[0011] Map the drug names to a unified standard code and generate all possible combinations of drug pairs;
[0012] Construct a drug knowledge graph based on a graph neural network and a contrast learning mechanism, the drug knowledge graph comprising nodes representing drug standard codes and edges representing drug interaction relationships with interaction types, confidence scores and literature sources;
[0013] Perform structured graph reasoning on drug pairs based on the drug knowledge graph, perform path retrieval on the drug pairs in the knowledge graph, obtain graph reasoning results, the graph reasoning results comprising existing interaction paths, interaction types, interaction descriptions and corresponding confidence scores;
[0014] For drug pairs that do not have explicit interaction paths, predict potential interaction relationships and confidence scores based on the drug knowledge graph and a pre-trained large language model in the medical field to obtain semantic reasoning results;
[0015] Based on the graph reasoning results and semantic reasoning results, the final incompatibility detection results are generated.
[0016] Furthermore, mapping the drug name to a unified drug code specifically includes:
[0017] Performing standardization preprocessing on the drug names, including removing unit information, unifying Chinese and English formats, normalizing aliases, and cleaning up dosage form labels;
[0018] Matching the standardized drug names based on a constructed drug name mapping database, wherein the drug name mapping database includes a correspondence between drug names from multiple sources and their corresponding standard codes, wherein the standard code is a national drug entity identifier (ATC) code;
[0019] For drug names that cannot be directly matched in the drug name mapping database, a semantic similarity calculation method based on a language model is used for fuzzy matching, and candidate matches and corresponding confidence scores are output;
[0020] Based on a preset confidence threshold, the best item is screened from the candidate matching items, and the standard code corresponding to the best item is used as the mapping result of the drug name.
[0021] Furthermore, the generation of all possible drug pair combinations specifically includes: combining multiple standard codes obtained by mapping in the prescription data in pairs to form an unordered and non-repetitive set of drug pairs, where the drug pairs are the combination relationship between the standard codes of each two different drugs; and encapsulating each drug pair as a structured object to be detected.
[0022] Furthermore, the construction of a drug knowledge graph based on a graph neural network and a contrastive learning mechanism specifically includes:
[0023] Obtain pharmaceutical literature data containing drug interaction information from public pharmaceutical databases, journal article platforms, and drug regulatory websites using web crawler technology;
[0024] Preprocessing the pharmaceutical literature data, including structure standardization, invalid content filtering, drug terminology unification, and entity disambiguation;
[0025] The medical field large language model is used to perform extractive information recognition on the drug interaction descriptions in the literature to obtain detailed drug interaction information expressed in the form of triples. The triples are expressed as (D1, R, D2), where D1 and D2 represent the standard codes of the drugs involved in the interaction, and R represents the interaction type.
[0026] Based on the triplets, a heterogeneous drug knowledge graph is constructed, nodes in the graph are mapped drug standard codes, edges are different types of drug interaction relationships, and edges are accompanied by interaction descriptions, confidence scores and corresponding literature sources.
[0027] The constructed drug knowledge graph is applied to a graph neural network model for graph structure representation learning, and is trained through a contrastive learning mechanism to obtain a trained drug knowledge graph.
[0028] Further, the constructed drug knowledge graph is applied to a graph neural network model for graph structure representation learning, and is trained through a contrastive learning mechanism, specifically including:
[0029] The constructed drug knowledge graph is represented as a graph G=(V, E), where V is a node set consisting of drug standard codes, and E is an edge set consisting of drug interaction relationship triplets (D1, R, D2) extracted from pharmaceutical literature, R represents the interaction type, accompanied by interaction description, confidence score and literature source.
[0030] An initial feature vector is constructed for each drug node v i ∈V The initial feature vector is constructed based on the drug category and chemical composition, and the drug category is ATC classification.
[0031] In each round of graph neural network propagation, the node features are updated through neighbor aggregation and relationship perception mechanism, and the update process is as follows:
[0032]
[0033] Wherein, represents the embedding feature vector of node v i at the lth layer, represents the neighbor node set of node v i with interaction relationship under the drug interaction relationship triplet; R represents the interaction type set, represents the linear transformation matrix under the corresponding interaction type r, is the self-connection weight matrix.
[0034] After completing the multi-layer graph neural network propagation, the final embedding feature vector of each node is obtained
[0035] Wherein, the parameter linear transformation matrix and the self-connection weight matrix of the graph neural network are trained through the contrastive learning mechanism.
[0036] Further, the parameter linear transformation matrix and the self-connection weight matrix of the graph neural network are trained through the contrastive learning mechanism, specifically including:
[0037] Construct positive and negative sample pairs for supervised training, where the positive sample pairs are drug pairs that have interactive relationships in the drug knowledge graph. Negative sample pairs are random drug pairs that do not have an interaction relationship in the graph where v i 、 They are the graph nodes corresponding to the drug standard codes;
[0038] The contrastive learning loss function is used to optimize the graph neural network parameters, including the parameter linear transformation matrix and self-connection weight matrix of each layer. The loss function is a contrastive loss function based on noise contrast estimation and is defined as follows:
[0039]
[0040] in, Node v i 、 The initial feature vector of , N is the number of training samples, is the loss function, K is the number of negative samples corresponding to each positive sample, sim represents the cosine similarity between the initial feature vectors; τ is the temperature hyperparameter;
[0041] By minimizing the above loss function, the weight parameters of the graph neural network are trained, including the relationship perception transformation matrix and self-connection matrix of each layer, to optimize the discriminative ability of node embedding in the graph.
[0042] Furthermore, the interaction types include drug efficacy enhancement interaction, drug efficacy antagonism interaction, toxicity enhancement interaction, metabolic competition interaction, carrier occupancy interaction and contraindication interaction;
[0043] The confidence score is calculated according to the following process:
[0044] The literature fragments containing drug interaction descriptions are input into the medical field large language model. By extracting the drug interaction types and modeling their credibility, the confidence score S is calculated by integrating the language model prediction confidence, literature source quality and semantic consistency. conf , which is calculated as follows:
[0045] S conf =α·S llm +β·S src
[0046] Among them, S conf is the confidence score, S llm Score the confidence of the interaction relationship extracted by the large language model, based on the probability distribution or classification result confidence score generated by the model; srcFor the literature source credibility score, a hierarchical weight is given according to the literature level, including SCI journals, guidelines, pharmacopoeias, and regulatory agency announcements; and a and b are preset weighting coefficients.
[0047] Further, the drug pair is subjected to structured graph reasoning according to the drug knowledge graph, path retrieval is performed on the drug pair in the knowledge graph, and a graph reasoning result is obtained, specifically including:
[0048] Based on the structure of nodes and edges in the drug knowledge graph, all possible interaction paths between the two drug nodes are retrieved from the starting node of a given drug pair using a depth-first search or breadth-first search algorithm;
[0049] For each retrieved interaction path, the credibility score S of the overall path is calculated according to the interaction type, confidence score and literature source carried by each edge in the path. path The specific calculation formula is as follows:
[0050]
[0051] Where P represents the set of all edges in the retrieved interaction path, M represents the number of edges in the interaction path, e represents a single edge in the path, S conf (e) represents the confidence score of the edge, W type (e) is the weight of the corresponding interaction type of edge e, different interaction types have different weights, specifically, the weight of the incompatibility interaction is greater than the weight of the toxicity enhancement interaction, the weight of the toxicity enhancement interaction is greater than the weight of the drug efficacy antagonism interaction, the weight of the drug efficacy antagonism interaction is greater than the weight of the metabolic competition interaction and the weight of the carrier occupation interaction, and the weight of the drug efficacy enhancement interaction is the lowest.
[0052] According to the calculated path credibility score S path , the path with the highest credibility is selected as the representative interaction path of the drug pair, and if there is no path or the highest credibility score is lower than a preset threshold, it is determined that there is no explicit interaction relationship between the drug pair in the knowledge graph.
[0053] When an explicit interaction relationship is determined, the graph reasoning result of the drug pair is output, including all drug nodes and corresponding interaction edge information in the representative interaction path and the credibility score of the representative interaction path, and the interaction edge information includes the interaction type, interaction description and confidence score.
[0054] Further, for the drug pair without an explicit interaction path, a potential interaction relationship is predicted and a credibility score is given based on the drug knowledge graph and a pre-trained medical field large language model, specifically including:
[0055] For drug pairs (D1, D2) without explicit interaction relationship, according to the drug categories and chemical components in the node feature vectors, respectively, the similar substitute drug sets are retrieved from the knowledge graph With The screening basis of the substitute drug set is the chemical structure similarity score S chem , and the screening formula is as follows:
[0056]
[0057] Among them, represents the drug set belonging to the same ATC category as drug D; S chem (D, D ′ ) represents the chemical component similarity score of drug D and candidate drug D ′ , which is calculated based on the similarity of the chemical components of the two drugs; T chem is a preset structure similarity threshold;
[0058] For all possible drug pairs in the substitute drug set The interaction path retrieval and graph reasoning are performed in the drug knowledge graph to obtain the interaction path information, including the interaction path, the interaction type and the confidence score, and the path information representing the path is organized into a structured natural language prompt;
[0059] The original drug pair (D1, D2) and the drug pair interaction path information of the associated substitute drug set are input into the pre-trained medical field large language model to generate potential interaction relationship prediction and credibility score, and obtain semantic reasoning result.
[0060] Further, the final incompatibility detection result is generated based on the graph reasoning result and the semantic reasoning result, specifically including:
[0061] According to the graph reasoning result and the semantic reasoning result, all drug nodes and corresponding interaction edge information in the interaction path of each pair of drugs in the detected prescription data and the credibility score of the representative interaction path are obtained, and the final incompatibility detection result is obtained.
[0062] Compared with the prior art, the present application has the following advantages:
[0063] (1) The present application aims at the problem that the existing drug compatibility contraindication detection method cannot identify potential conflicts and has the risk of missing detection when there is no explicit path in the knowledge graph. A drug compatibility contraindication detection method combining graph reasoning and semantic reasoning is proposed. Based on graph path retrieval, the method introduces a pre-trained large language model in the medical field to predict the potential interaction relationship and credibility score of drug pairs without direct paths, realizing the complementary fusion of structured graphs and unstructured semantic information. Through this technical means, the system can not only identify drug conflicts within the coverage of existing graphs, but also discover potential risks hidden behind clinical experience and literature semantics, significantly reducing the probability of missing detection due to knowledge gaps and improving the comprehensiveness and intelligence of detection.
[0064] (2) The present application aims at the problem that the traditional method only uses the "existence" of the path as the basis for judgment, and cannot distinguish the risk weight of different interaction types, nor consider the path confidence and information source quality, resulting in the defect of insufficient reliability of reasoning results. A drug knowledge graph with interaction type, confidence score and literature source is constructed. The graph not only records the interaction relationship between drugs, but also learns the interaction semantic weight and source credibility through graph neural network and contrastive learning mechanism, realizing the quantitative modeling and explanation enhancement of interaction information. Through the graph reasoning process, the complete interaction path, interaction type description and confidence support can be output, making the detection results have higher explainability and traceability, and improving the modeling depth of complex drug relationships and the clinical credibility of output results.
[0065] (3) In view of the problem that the construction of knowledge graph in the prior art mainly depends on structured data, and it is difficult to cover non-structured semantic content such as drug instructions and adverse reaction reports, resulting in limited coverage of the graph and difficulty in expressing complex semantic relationships, the present application innovatively introduces a semantic reasoning module to extract and integrate drug interaction information from multiple sources of text using a pre-trained large language model. Based on clinical language and drug semantic context, the module can identify implicit drug relationships not explicitly recorded in the graph, realize intelligent completion of the coverage blind area of the graph, significantly expand the boundary of the system's recognition ability, and enhance the understanding ability of complex interactions at the semantic level, providing strong support for improving the safety of individualized medication.
[0066] (4) The application designs a unified standard coding mapping mechanism to standardize the drug names in the to-be-detected prescription into unified drug codes, and systematically generates all possible drug pair combinations, effectively solving the technical bottlenecks of existing systems in handling drug name ambiguity, synonym mixing and other problems, such as inaccurate matching and incomplete recognition. Through the standardization mapping and combination mechanism, the robustness and detection coverage of the model in processing large-scale prescription data are significantly improved, providing accurate and complete data basis for subsequent graph reasoning and semantic reasoning, and enhancing the adaptability and engineering practicability of the system in actual clinical application scenarios.
[0067] (5) The application generates the final compatibility contraindication detection result containing explicit path basis and semantic prediction support by constructing a decision mechanism that fuses the results of structural graph reasoning and semantic reasoning. This mechanism considers multiple dimensions of information such as the existence of interaction paths, interaction types, credibility scores and semantic prediction strength, establishes a unified risk scoring model and contraindication level division strategy, and realizes the quantitative determination and hierarchical management of drug combination risks. This method takes into account the rigor of graph structure and the semantic generalization ability of language models, not only improving the accuracy and explainability of the detection result, but also having good clinical decision support value, effectively solving the key problems of existing methods such as difficulty in quantifying risk intensity and single output dimension. BRIEF DESCRIPTION OF DRAWINGS
[0068] Figure 1 The drug compatibility contraindication detection method flowchart of the embodiment of the application;
[0069] Figure 2 The drug compatibility contraindication detection system model diagram of the embodiment of the application. DETAILED DESCRIPTION
[0070] The technical solutions in the embodiments of the application will be described clearly and completely below with reference to the drawings in the embodiments of the application. Obviously, the described embodiments are part of the embodiments of the application, rather than all the embodiments of the application. Based on the embodiments in the application, all other embodiments obtained by those skilled in the art without creative labor should fall within the scope of protection of the application.
[0071] The embodiment provides a drug compatibility contraindication detection method based on fusion of graph and large language model, as shown in Figure 1 The method comprises the following steps:
[0072] Step S1: obtaining to-be-detected prescription data, the prescription data comprising a plurality of drug names to be detected for drug compatibility contraindication;
[0073] Step S2: mapping the drug names into unified standard codes and generating all possible drug pair combinations, specifically comprising:
[0074] Standardization preprocessing of drug names includes removing unit information, unifying Chinese and English formats, normalizing aliases, and cleaning up dosage form labels;
[0075] The standardized drug names are matched based on the constructed drug name mapping database. The drug name mapping database includes the correspondence between drug names from multiple sources and their corresponding standard codes. The standard code is the National Drug Entity Identification (ATC) code.
[0076] For drug names that cannot be directly matched in the drug name mapping database, a semantic similarity calculation method based on a language model is used for fuzzy matching, and candidate matches and corresponding confidence scores are output;
[0077] Based on the preset confidence threshold, the best item is screened from the candidate matching items, and the standard code corresponding to the best item is used as the mapping result of the drug name.
[0078] Multiple standard codes mapped from prescription data are combined in pairs to form an unordered and non-repetitive set of drug pairs, where a drug pair is a combination relationship between the standard codes of two different drugs; each drug pair is encapsulated as a structured object to be detected.
[0079] In the existing technology, the first step in drug incompatibility detection is to identify and match the drugs involved in the prescription. However, the names of drugs in real prescriptions often have significant heterogeneity and ambiguity, including but not limited to the mixing of Chinese and English, differences in dosage forms, interference with unit information, and inconsistent aliases or trade names. For example, a common drug "aspirin" may appear in the prescription as "Aspirin", "Aspirin Tablets", "Aspirin Enteric-coated Tablets", "Bay Aspirin", etc. This inconsistent naming makes it difficult for traditional systems based on rule tables or literal comparison methods to correctly identify the drug entity, further affecting the subsequent generation and interactive detection process of drug pairs, resulting in missed detections and false detections, seriously affecting drug safety.
[0080] To overcome this problem, the present invention proposes in step S2 to map the drug names into a unified standard code and generate all possible drug pair combinations. Its core goal is to solve the problems of "naming confusion" and "semantic uncertainty" in the drug entity recognition stage, and provide a structured, high-standard input data foundation for subsequent graph reasoning and semantic reasoning.
[0081] Step S3: Construct a drug knowledge graph based on a graph neural network and contrastive learning mechanism. The drug knowledge graph includes nodes representing drug standard codes and edges representing drug interactions with interaction types, confidence scores, and literature sources. Specifically, it includes:
[0082] Obtain pharmaceutical literature data containing drug interaction information from public pharmaceutical databases, journal article platforms, and drug regulatory websites using web crawler technology;
[0083] Preprocessing of pharmaceutical literature data, including structure standardization, invalid content filtering, drug terminology unification, and entity disambiguation;
[0084] The medical field large language model is used to perform extractive information recognition on drug interaction descriptions in the literature, obtaining detailed drug interactions expressed in the form of triples. The triples are expressed as (D1, R, D2), where D1 and D2 represent the standard codes of the drugs involved in the interaction, and R represents the interaction type.
[0085] A heterogeneous drug knowledge graph is constructed based on triples. The nodes in the graph are mapped drug standard codes, and the edges are different types of drug interactions. The edges are accompanied by interaction descriptions, confidence scores, and corresponding literature sources.
[0086] The constructed drug knowledge graph is subjected to graph structure representation learning using a graph neural network model, and is trained through a comparative learning mechanism to obtain a trained drug knowledge graph.
[0087] The constructed drug knowledge graph is trained using a graph neural network model for graph structure representation learning and trained using a comparative learning mechanism. Specifically, the following steps are performed:
[0088] The constructed drug knowledge graph is represented as a graph G = (V, E), where V is a node set consisting of drug standard codes, E is an edge set consisting of drug interaction triplets (D1, R, D2) extracted from pharmaceutical literature, R represents the interaction type, with an interaction description, confidence score, and literature source; interaction types include efficacy enhancement interaction, efficacy antagonism interaction, toxicity enhancement interaction, metabolic competition interaction, carrier occupancy interaction, and contraindication interaction.
[0089] The confidence score is calculated according to the following process:
[0090] The literature fragments containing drug interaction descriptions are input into the medical field large language model. By extracting the drug interaction types and modeling their credibility, the confidence score S is calculated by integrating the language model prediction confidence, literature source quality and semantic consistency. conf , which is calculated as follows:
[0091] S conf =α·S llm +β·S src
[0092] Among them, S conf is the confidence score, S llmScore the confidence of the interaction relationship extracted by the large language model, based on the probability distribution or classification result confidence score generated by the model; src Scoring the credibility of literature sources, assigning graded weights based on the literature level, which includes SCI journals, guidelines, pharmacopoeias, and regulatory agency announcements; α and β are preset weighting coefficients.
[0093] For each drug node v i ∈V constructs the initial feature vector The initial feature vector is constructed based on the drug category and chemical composition. The drug category is the ATC classification;
[0094] In each round of graph neural network propagation, node features are updated through neighbor aggregation and relationship perception mechanisms. The update process is as follows:
[0095]
[0096] in, Represents the node v at the lth layer i The embedded feature vector of Represents the drug interaction relationship triple with node v i The set of neighbor nodes with interactive relationships; R represents the set of interaction types, represents the linear transformation matrix corresponding to the interaction type r, is the self-connection weight matrix;
[0097] After completing the multi-layer graph neural network propagation, the final embedding feature vector of each node is obtained
[0098] Among them, the parameter linear transformation matrix and self-connection weight matrix of the graph neural network are trained through a contrastive learning mechanism.
[0099] The parameter linear transformation matrix and self-connection weight matrix of the graph neural network are trained through a contrastive learning mechanism, specifically including:
[0100] Construct positive and negative sample pairs for supervised training. Positive sample pairs are drug pairs that have interactive relationships in the drug knowledge graph. Negative sample pairs are random drug pairs that do not have an interaction relationship in the graph where v i 、 They are the graph nodes corresponding to the drug standard codes;
[0101] The contrastive learning loss function is used to optimize the parameters of the graph neural network, including the parameter linear transformation matrix and self-connection weight matrix of each layer. The loss function is a contrastive loss function based on noise contrast estimation, which is defined as follows:
[0102]
[0103] wherein, are the initial feature vectors of nodes v i 、 , N is the number of training samples, is the loss function, K is the number of negative samples corresponding to each positive sample, sim represents the cosine similarity between the initial feature vectors; τ is a temperature hyperparameter;
[0104] By minimizing the above loss function, the weight parameters of the graph neural network are trained, including the relationship perception transformation matrix and the self-connection matrix of each layer, and the discrimination ability of the node embedding in the graph is optimized.
[0105] The present application proposes a complete method for constructing and training a drug knowledge graph based on a graph neural network (GNN) and a contrast learning mechanism in step S3, aiming to solve multiple key problems such as weak modeling ability of drug interaction relationship, single knowledge source, insufficient information reliability, rough interaction type, and limited expression of graph in existing drug compatibility contraindication detection. Traditional methods often rely on limited entries in static rule bases or structured databases, lack the ability to model complex semantic and dynamic structure of real pharmacy knowledge, and lack systematic means in data quality and relationship credibility evaluation, resulting in a shallow understanding of drug interactions and an inability to meet individual needs in complex clinical medication scenarios.
[0106] The present application inputs the constructed graph into the graph neural network for structured representation learning, dynamically learns the interaction mode between drugs through the neighbor aggregation mechanism and the relationship perception mechanism. The initial feature of each drug node not only contains basic encoding, but also combines its ATC classification and chemical composition, so that the graph neural network can perform embedding modeling from two aspects of pharmacological classification and component similarity. In the propagation process, the model not only considers the features of neighbor nodes, but also uses different linear transformation matrices according to different interaction types, enhancing the sensitivity to interaction semantics; at the same time, the node's own features are preserved and weighted through the self-connection matrix, ensuring stable updating of the features and preservation of the original properties.
[0107] To improve the discrimination ability of graph embedding expression, the present application introduces a contrast learning mechanism to train the graph neural network. By constructing positive and negative sample pairs (drug pairs with edges in the graph are positive samples, and drug pairs without edges are negative samples), and using a contrastive loss function based on noise contrast estimation (NCE) to supervise and optimize the model, the model learns more discriminative drug representations. Especially when facing large-scale heterogeneous graph structures, contrast learning is significantly better than traditional supervised or unsupervised training methods in improving feature discrimination, improving the effectiveness of downstream tasks such as drug similarity measurement and relationship inference.
[0108] Step S4: Perform structured graph reasoning on drug pairs based on the drug knowledge graph, perform path retrieval on the drug pairs in the knowledge graph, and obtain graph reasoning results. The graph reasoning results include the existing interaction paths, interaction types, interaction descriptions, and corresponding confidence scores.
[0109] Step S4 specifically includes:
[0110] Based on the structure of nodes and edges in the drug knowledge graph, a depth-first search or breadth-first search algorithm is used to retrieve all possible interaction paths between the two drug nodes starting from the starting node of a given drug pair.
[0111] For each interaction path retrieved, the overall path credibility score S is calculated based on the interaction type, confidence score and document source carried by each edge in the path. path , the specific calculation formula is as follows:
[0112]
[0113] Where P represents the set of all edges in the retrieved interaction path, M represents the number of edges in the interaction path, e represents a single edge in the path, and S conf (e) represents the confidence score of the edge, W type (e) is the weight of the interaction type corresponding to edge e. Different interaction types have different weights. Specifically, the weight of contraindication interaction is greater than the weight of toxicity enhancement interaction, the weight of toxicity enhancement interaction is greater than the weight of drug efficacy antagonism interaction, the weight of drug efficacy antagonism interaction is greater than the weight of metabolic competition interaction and carrier occupancy interaction, and the weight of drug efficacy enhancement interaction is the lowest.
[0114] Based on the calculated credibility score S of each path path , the path with the highest credibility is selected as the representative interaction path of the drug pair. If there is no path or the highest credibility score is lower than the preset threshold, it is determined that the drug pair has no explicit interaction relationship in the knowledge graph;
[0115] When an explicit interaction relationship is determined, the graph inference results of the drug pair are output, including all drug nodes representing the interaction path and the corresponding interaction edge information and the credibility score representing the interaction path. The interaction edge information includes the interaction type, interaction description and confidence score.
[0116] The present application aims at the problem that only known interactions can be identified, potential relationships cannot be found, and credibility evaluation and explainability are lacking in existing drug compatibility contraindication detection, and proposes a method of constructing a drug knowledge graph based on a graph neural network and a contrast learning mechanism. First, multi-source pharmaceutical literature data are collected through web crawling, and drug interaction triples are extracted using a large language model to construct a heterogeneous graph, with nodes being drug standard codes and edges being drug interaction relationships with interaction types, confidence scores, and literature sources. The confidence score extraction model extracts confidence and literature source level to ensure information reliability. Graph neural networks are used to learn features from the graph, and the relationship perception mechanism is used to update node representations. To improve the discrimination ability, a contrast learning mechanism is introduced, and a positive and negative sample pair is constructed to optimize the embedding representation using a contrast loss function to enhance the model's ability to distinguish interaction relationships. This method improves the depth of drug knowledge graph expression and semantic modeling ability, enhances the reasoning ability of potential interactions between unknown drug combinations, and provides more comprehensive, accurate, and reliable support for compatibility contraindication detection.
[0117] Step S5: For drug pairs without explicit interaction paths, perform potential interaction relationship prediction and confidence scoring based on the drug knowledge graph and a pre-trained medical field large language model to obtain semantic reasoning results;
[0118] Step S5 specifically includes:
[0119] For drug pairs (D1, D2) without explicit interaction relationships, respectively according to the drug categories and chemical components in the node feature vectors thereof, retrieve from the knowledge graph a set of alternative drugs similar to each of them And The screening of the set of alternative drugs is based on the chemical structure similarity score S chem , and the screening formula is as follows:
[0120]
[0121] Among them, represents a set of drugs belonging to the same ATC category as drug D; S chem (D, D ′ ) represents the chemical component similarity score of drug D and candidate drug D ′ , which is calculated based on the similarity of the chemical components of the two drugs; T chem is a preset structure similarity threshold;
[0122] For all possible drug pairs in the set of alternative drugs Perform interaction path retrieval and graph reasoning in the drug knowledge graph to obtain interaction path information, including interaction path, interaction type, and confidence score, and organize the path information into a structured natural language prompt;
[0123] The drug pair interaction path information of the original drug pair (D1, D2) and its associated set of alternative drugs is input into the pre-trained medical field large language model to generate potential interaction relationship predictions and credibility scores to obtain semantic reasoning results.
[0124] Step S5 of the present invention addresses the challenging scenario of drug pairs lacking explicit interaction paths in the knowledge graph. By combining alternative drug graph reasoning with semantic analysis from a large language model, we propose a method for predicting potential interaction relationships. This design addresses the core issue of traditional knowledge graph reasoning, which only covers known and connected drug pairs and lacks the ability to address unconnected drug pairs in the graph. This significantly expands the system's coverage and practical applicability.
[0125] In existing technologies, when two drugs do not form a direct or indirect connection path in the graph, the system usually defaults to "no interaction" or "unknown interaction." This is extremely risky in actual clinical applications, especially when dealing with new drugs, unpopular drugs, or rare clinical combinations, which inevitably lead to data sparsity and knowledge blind spots. Because the construction of knowledge graphs is limited by the data source and annotation quality, some real but undiscovered or unannotated interactions are missing from the graph and cannot be identified or inferred. This defect directly affects the recall ability and reasoning depth of the model.
[0126] To solve the above problems, the present invention first calculates the chemical structure similarity between the target drug and drugs of the same category based on the drug category (ATC classification) and chemical composition information, and screens out a set of alternative drugs with similar chemical structures and possible similar mechanisms of action. Subsequently, interaction path retrieval and graph reasoning are performed on the alternative drug pairs in the knowledge graph to obtain possible interaction types, path structures and their confidence levels. By organizing these interaction information from alternative drugs into structured natural language prompts and further inputting them into the pre-trained large language model, with the help of its powerful semantic understanding and reasoning capabilities, the prediction of potential interaction relationships and credibility scores of the original target drug pairs are completed.
[0127] This technical approach uses the graph path information of alternative drugs to make up for the missing paths of the original drug pairs, and realizes semantic induction and completion through the knowledge generalization ability of the large language model, thereby constructing a "indirect reasoning + language understanding" collaborative mechanism, effectively expanding the coverage boundary of incompatibility identification, and enhancing the ability to identify rare, unpopular, and data-sparse drug combinations, greatly improving the system's applicability and safety assurance level in diverse clinical drug use scenarios.
[0128] Step S6: Based on the graph reasoning results and the semantic reasoning results, the final incompatibility detection results are generated, which specifically include:
[0129] According to the graph reasoning result and the semantic reasoning result, all drug nodes and corresponding interaction edge information in an interaction path of each pair of drugs in the to-be-detected prescription data and a confidence score representing the interaction path are obtained, and a final incompatibility detection result is obtained.
[0130] The embodiment also provides a drug incompatibility detection system based on graph and large language model fusion, as shown in the figure, comprising: Figure 2
[0131] A drug standardization mapping module is configured to receive to-be-detected prescription data, perform standardization preprocessing on drug names in the prescription, including removing unit information, unifying English and Chinese formats, alias normalization and cleaning up dosage form annotations, mapping the standardized drug names to unified national drug standard codes (such as ATC codes) based on a constructed drug name mapping database, and performing fuzzy matching on drug names that cannot be directly matched by using a language model-based semantic similarity calculation method, outputting candidate items and selecting the optimal mapping result based on a pre-set confidence threshold.
[0132] A drug pair generation module is configured to combine a plurality of drug standard codes obtained by mapping in the prescription in pairs, generate an unordered and non-repeating drug pair set, and encapsulate each drug pair as a structured to-be-detected object.
[0133] A knowledge graph construction module is configured to obtain drug interaction information literature from public pharmacy databases, journal paper platforms and drug supervision websites by using a web crawler technology, call a large language model in the medical field to extract triplets from interaction descriptions in the literature, and construct a heterogeneous drug knowledge graph, in which nodes are drug standard codes and edges are drug interaction relationships with interaction types, interaction descriptions, confidence scores and literature sources.
[0134] A graph embedding and training module is configured to apply a graph neural network model to graph structure representation learning of the constructed drug knowledge graph, update node feature vectors through a neighbor aggregation mechanism with relation awareness, introduce a contrast learning mechanism to construct positive and negative sample pairs, train graph neural network parameters by using a noise contrast estimation loss function, and optimize the discriminability of drug embedding features.
[0135] An interaction detection and path reasoning module is configured to perform interaction path retrieval on to-be-detected drug pairs in the drug knowledge graph, if there is an explicit path, perform interaction conflict identification and risk scoring based on interaction types, number, confidence and path depth in the path, and output an explicit path reasoning result.
[0136] The potential interaction semantic reasoning module is used to select a set of similar alternative drugs from the knowledge graph for drug pairs that do not have explicit interaction paths in the graph based on the drug category and chemical composition similarity. The constructed interaction path information of the alternative drug pairs in the graph is used to form structured prompts, which are input into the pre-trained large language model in the medical field to generate potential interaction relationship predictions and confidence scores, and output semantic reasoning results.
[0137] The result fusion and output module is used to integrate the results of explicit path reasoning and semantic reasoning, comprehensively consider the interaction strength and credibility score, and output the compatibility judgment, risk level, interaction type and clinical treatment recommendation for each drug pair, thus realizing comprehensive detection of drug compatibility and intelligent decision-making support.
[0138] If the above functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0139] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present invention, and such modifications or substitutions are intended to be within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the scope of protection of the claims.
Claims
1. A drug incompatibility detection method based on the fusion of graph and large language model, characterized in that: The following steps are involved: Obtaining prescription data to be tested, the prescription data including the names of multiple drugs to be tested for drug incompatibility; Mapping the drug names to unified standard codes and generating all possible drug pair combinations; Constructing a drug knowledge graph based on a graph neural network and contrastive learning mechanism. The drug knowledge graph includes nodes representing drug standard codes and edges representing drug interactions with interaction types, confidence scores, and literature references. Performing structured graph reasoning on drug pairs according to the drug knowledge graph, performing path retrieval on the drug pairs in the knowledge graph, and obtaining graph reasoning results, wherein the graph reasoning results include existing interaction paths, interaction types, interaction descriptions, and corresponding confidence scores; For drug pairs without explicit interaction paths, potential interaction relationship prediction and credibility scoring are performed based on the drug knowledge graph combined with a pre-trained large language model in the medical field to obtain semantic reasoning results. Based on the graph reasoning results and semantic reasoning results, the final incompatibility detection results are generated.
2. The method for detecting drug incompatibility based on the fusion of graph and large language model according to claim 1, characterized in that: Mapping the drug name to a unified drug code specifically includes: Performing standardization preprocessing on the drug names, including removing unit information, unifying Chinese and English formats, normalizing aliases, and cleaning up dosage form labels; Matching the standardized drug names based on a constructed drug name mapping database, wherein the drug name mapping database includes a correspondence between drug names from multiple sources and their corresponding standard codes, wherein the standard code is a national drug entity identifier (ATC) code; For drug names that cannot be directly matched in the drug name mapping database, a semantic similarity calculation method based on a language model is used for fuzzy matching, and candidate matches and corresponding confidence scores are output; Based on a preset confidence threshold, the best item is screened from the candidate matching items, and the standard code corresponding to the best item is used as the mapping result of the drug name.
3. The method for detecting drug incompatibility based on the fusion of graph and large language model according to claim 1, characterized in that: The generating of all possible drug pair combinations specifically includes: combining multiple standard codes obtained by mapping in the prescription data in pairs to form an unordered and non-repetitive drug pair set, wherein the drug pair is a combination relationship between the standard codes of each two different drugs; and encapsulating each drug pair as a structured object to be detected.
4. The method for detecting drug incompatibility based on the fusion of graph and large language model according to claim 1, characterized in that: The construction of a drug knowledge graph based on a graph neural network and a contrastive learning mechanism specifically includes: Obtain pharmaceutical literature data containing drug interaction information from public pharmaceutical databases, journal article platforms, and drug regulatory websites using web crawler technology; Preprocessing the pharmaceutical literature data, including structure standardization, invalid content filtering, drug terminology unification, and entity disambiguation; The medical field large language model is used to perform extractive information recognition on the drug interaction descriptions in the literature to obtain detailed drug interaction information expressed in the form of triples. The triples are expressed as (D1, R, D2), where D1 and D2 represent the standard codes of the drugs involved in the interaction, and R represents the interaction type. Based on the triples, a heterogeneous drug knowledge graph is constructed. The nodes in the graph are mapped drug standard codes, and the edges are different types of drug interactions. The edges are accompanied by interaction descriptions, confidence scores, and corresponding literature sources. The constructed drug knowledge graph is subjected to graph structure representation learning using a graph neural network model, and is trained through a comparative learning mechanism to obtain a trained drug knowledge graph.
5. The method for detecting drug incompatibility based on the fusion of graph and large language model according to claim 4, characterized in that: The constructed drug knowledge graph is subjected to graph structure representation learning using a graph neural network model and trained through a comparative learning mechanism, specifically including: The constructed drug knowledge graph is represented as a graph G = (V, E), where V is a node set consisting of drug standard codes, E is an edge set consisting of drug interaction triplets (D1, R, D2) extracted from pharmaceutical literature, and R represents the interaction type, along with the interaction description, confidence score, and literature source. For each drug node v i ∈V constructs the initial feature vector The initial feature vector is constructed based on the category and chemical composition of the drug, and the category of the drug is ATC classification; In each round of graph neural network propagation, node features are updated through neighbor aggregation and relationship perception mechanisms. The update process is as follows: in, Represents the node v at the lth layer i The embedded feature vector of Represents the drug interaction relationship triple with node v i The set of neighbor nodes with interactive relationships; R represents the set of interaction types, represents the linear transformation matrix corresponding to the interaction type r, is the self-connection weight matrix; After completing the multi-layer graph neural network propagation, the final embedding feature vector of each node is obtained Among them, the parameter linear transformation matrix and self-connection weight matrix of the graph neural network are trained through a contrastive learning mechanism.
6. The method for detecting drug incompatibility based on the fusion of graph and large language model according to claim 5, characterized in that: The parameter linear transformation matrix and self-connection weight matrix of the graph neural network are trained through a contrastive learning mechanism, specifically including: Construct positive and negative sample pairs for supervised training. Positive sample pairs are drug pairs that have interactive relationships in the drug knowledge graph. Negative sample pairs are random drug pairs that do not have an interaction relationship in the graph where v i 、 They are the graph nodes corresponding to the drug standard codes; The contrastive learning loss function is used to optimize the graph neural network parameters, including the parameter linear transformation matrix and self-connection weight matrix of each layer. The loss function is a contrastive loss function based on noise contrast estimation and is defined as follows: in, Node v i 、 The initial feature vector of , N is the number of training samples, is the loss function, K is the number of negative samples corresponding to each positive sample, sim represents the cosine similarity between the initial feature vectors; τ is the temperature hyperparameter; By minimizing the above loss function, the weight parameters of the graph neural network are trained, including the relationship perception transformation matrix and self-connection matrix of each layer, to optimize the discriminative ability of node embedding in the graph.
7. The method for detecting drug incompatibility based on the fusion of graph and large language model according to claim 5, characterized in that: The interaction types include drug efficacy enhancement interaction, drug efficacy antagonism interaction, toxicity enhancement interaction, metabolic competition interaction, carrier occupancy interaction and contraindication interaction; The confidence score is calculated according to the following process: The literature fragments containing drug interaction descriptions are input into the medical field large language model. By extracting the drug interaction types and modeling their credibility, the confidence score S is calculated by integrating the language model prediction confidence, literature source quality and semantic consistency. conf , which is calculated as follows: S conf =α·S llm +β·S src Among them, S cobf is the confidence score, S klm Score the confidence of the interaction relationship extracted by the large language model, based on the probability distribution or classification result confidence score generated by the model; src Scoring the credibility of the document source, assigning graded weights based on the document level, which includes SCI journals, guidelines, pharmacopoeias, and regulatory agency announcements; α and β are preset weighting coefficients.
8. The method for detecting drug incompatibility based on the fusion of graph and large language model according to claim 1, characterized in that: The structured graph reasoning is performed on the drug pairs according to the drug knowledge graph, and the path search is performed on the drug pairs in the knowledge graph to obtain the graph reasoning results, specifically including: Based on the structure of nodes and edges in the drug knowledge graph, a depth-first search or breadth-first search algorithm is used to retrieve all possible interaction paths between the two drug nodes starting from the starting node of a given drug pair. For each interaction path retrieved, the overall path credibility score S is calculated based on the interaction type, confidence score and document source carried by each edge in the path. path , the specific calculation formula is as follows: Where P represents the set of all edges in the retrieved interaction path, M represents the number of edges in the interaction path, e represents a single edge in the path, and S conf (e) represents the confidence score of the edge, W type (e) is the weight of the interaction type corresponding to edge e. Different interaction types have different weights. Specifically, the weight of contraindication interaction is greater than the weight of toxicity enhancement interaction, the weight of toxicity enhancement interaction is greater than the weight of drug efficacy antagonism interaction, the weight of drug efficacy antagonism interaction is greater than the weight of metabolic competition interaction and carrier occupancy interaction, and the weight of drug efficacy enhancement interaction is the lowest. Based on the calculated credibility score S of each path path , the path with the highest credibility is selected as the representative interaction path of the drug pair. If there is no path or the highest credibility score is lower than the preset threshold, it is determined that the drug pair has no explicit interaction relationship in the knowledge graph; When an explicit interaction relationship is determined, the graph inference result of the drug pair is output, including all drug nodes representing the interaction path and the corresponding interaction edge information and the credibility score representing the interaction path. The interaction edge information includes the interaction type, interaction description and confidence score.
9. The method for detecting drug incompatibility based on the fusion of graph and large language model according to claim 1, characterized in that: For drug pairs without explicit interaction paths, potential interaction relationship prediction and credibility scoring are performed based on the drug knowledge graph combined with a pre-trained large language model in the medical field. Specifically, the following steps are performed: For drug pairs (D1, D2) that do not have explicit interaction relationships, similar alternative drug sets are retrieved from the knowledge graph based on the drug categories and chemical components in their node feature vectors. and The screening basis of the set of alternative drugs is the chemical structure similarity score S chem , the screening formula is as follows: in, represents the set of drugs that belong to the same ATC category as drug D; S chem (D,D ′ ) represents drug D and candidate drug D ′ The chemical composition similarity score is calculated based on the similarity of the chemical compositions of two drugs; T chem is the preset structural similarity threshold; For all possible drug pairs in the set of alternative drugs Perform interaction path retrieval and graph reasoning in the drug knowledge graph to obtain its interaction path information, including interaction path, interaction type, and confidence score, and organize the representative path information into structured natural language prompts; The drug pair interaction path information of the original drug pair (D1, D2) and its associated set of alternative drugs is input into the pre-trained medical field large language model to generate potential interaction relationship predictions and credibility scores to obtain semantic reasoning results.
10. The method for detecting drug incompatibility based on the fusion of graph and large language model according to claim 1, characterized in that: The final incompatibility detection result is generated based on the graph reasoning result and the semantic reasoning result, specifically including: According to the results of graph reasoning and semantic reasoning, all drug nodes in the interaction path of each pair of drugs in the prescription data to be tested, the corresponding interaction edge information and the credibility score representing the interaction path are obtained to obtain the final incompatibility detection result.
Citation Information
Patent Citations
Multi-medication management and control method and system based on multi-database backup synchronization
CN119181464A
Cited By
Traditional Chinese medicine intelligent diagnosis and treatment decision-making system fusing knowledge graph and sequence deep learning
CN121545685A
