Dual-granularity drug recommendation method based on large-scale language model driven causal reasoning
By employing a large-scale language model-driven causal reasoning and two-granularity drug recommendation method, this approach addresses the shortcomings of existing systems in causal reasoning, multi-granularity representation, and long-sequence modeling. It enables personalized and safe drug combination recommendations, improving the accuracy and interpretability of the recommendations.
Patent Information
- Application Number
- CN202511223388.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-29
- Publication Date
- 2026-01-02
AI Technical Summary
Existing drug recommendation systems have shortcomings in medical knowledge-driven causal reasoning, fusion of multi-granular drug representations based on patient perception, and long-sequence time-series modeling, resulting in insufficient recommendation accuracy and safety, and making it difficult to meet the needs of personalized and real-time clinical decision-making.
We employ a causal reasoning method driven by a large language model, constructing a causal graph through LLM, combining drug molecule structure dual-domain mapping, heterogeneous effect graph network, and isomorphic relationship graph network for drug recommendation, using Medical Sequence Encoder for temporal modeling, and correcting biases through a causal review mechanism.
It significantly improves the accuracy and safety of drug recommendations, provides personalized drug combination recommendations, meets the real-time needs of clinical decision-making, and enhances the interpretability of recommendation results.
Smart Images

Figure CN121260352A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of medical artificial intelligence and drug recommendation technology, specifically to an intelligent drug recommendation method based on large-scale language models and causal reasoning technology. By analyzing electronic health record (EHR) data through deep learning and causal reasoning methods, it provides patients with personalized and safe drug combination recommendations to assist in clinical medical decision-making. Background Technology
[0002] With the aging global population and the increasing burden of chronic diseases, modern healthcare systems face challenges such as uneven resource allocation, increasingly complex clinical decision-making, and growing demand for personalized treatment. Against this backdrop, AI-powered drug recommendation systems, as a key component of precision medicine, offer new avenues for improving diagnostic and treatment efficiency and resource utilization.
[0003] Drug recommendation systems must be based on a patient's complete medical history to provide safe, accurate, and personalized medication plans. Unlike e-commerce or social media recommendations, drug recommendations need to integrate the complex relationships between multiple medical entities such as diseases, drugs, and treatment procedures, and incorporate professional information such as pharmacological knowledge and molecular structures. At the same time, medication safety must be given high priority to avoid adverse reactions caused by drug-drug interactions (DDIs). Furthermore, it is necessary to address the temporal nature of medical data and individual patient differences to achieve highly personalized modeling.
[0004] Early studies primarily relied on static recommendations based on the patient's current state, neglecting dynamic and historical information about the disease progression. With the widespread adoption of electronic medical records, dynamic recommendation methods based on recurrent neural networks and attention mechanisms have gradually emerged. In recent years, graph neural networks have further aided in modeling drug molecular structures and multi-level medical relationships, improving recommendation performance. However, existing methods still have significant limitations: I. Insufficient Causal Reasoning Ability Driven by Medical Knowledge: Existing methods largely rely on the mining of statistical correlations, lacking a deep understanding of medical semantics and clinical logic. They struggle to accurately capture the matching relationship between pathological mechanisms, drug effects, and treatment, and are prone to bias in complex disease combinations.
[0005] Second, the lack of patient-perceived multi-granularity drug characterization mechanisms: Existing methods often model drugs as a whole, ignoring the differences in their internal substructures; molecular coding lacks personalized perception capabilities, making it difficult to dynamically adjust the importance of different substructures according to the patient's condition, and also failing to achieve effective integration of global and local features.
[0006] Third, information loss and inefficiency exist in long-sequence time-series modeling: Traditional models such as GRU suffer from information forgetting when dealing with long-range dependencies, making it difficult to balance the preservation of history and the integration of new information, and key medical history and drug response patterns are easily lost; their sequential computation mode also limits parallelization capabilities, making it difficult to meet the needs of real-time clinical decision-making. Summary of the Invention
[0007] The purpose of this invention is to address the key limitations of existing drug recommendation systems in areas such as medical knowledge-driven causal reasoning, fusion of multi-granularity drug representations based on patient perception, and long-sequence temporal modeling. This invention provides a dual-granularity drug recommendation method based on large-scale language model-driven causal reasoning. Through LLM-driven causal graph construction, dual-domain mapping of drug molecule structures, fusion of heterogeneous effect graph networks and isomorphic relation graph networks, disease learning based on causal graphs, and temporal modeling using a MedicalSequence Encoder, combined with a causal review mechanism for bias correction, the accuracy, safety, and interpretability of drug recommendations are significantly improved without increasing model complexity.
[0008] The technical solution of the present invention is as follows: A two-granularity drug recommendation method based on large-scale language model-driven causal reasoning includes the following steps: Electronic health records are acquired and preprocessed, and medical information is encoded and converted to form a structured dataset that includes disease, surgical procedure, and drug information. A causal graph is constructed based on a large language model. LLM augmentation is performed on all medical entities in the structured dataset. The medical knowledge and reasoning ability of LLM are used to identify causal relationships between medical entities through causal inference prompts. To quantify the strength of causal relationships, a discretized generalized linear model is used to model the causal effects between disease / surgery and drugs, resulting in causal effect matrices for disease-drug and surgery-drug relationships. The drug substructure dual-domain mapping mechanism decomposes the drug's SMILES string using the BRICS algorithm to construct a substructure vocabulary. In the global domain mapping, a network isomorphism network is used to process the drug's molecular graph data to obtain a global drug representation. In the local mapping, an aggregated attention block is used to handle the interactions between substructures, and a patient-perceived contribution network is set up to determine the importance of different substructures based on the patient's condition. The global and local representations are then fused through a multi-head attention mechanism. Drug dual-granularity information fusion is achieved by processing the relationships between different types of medical entities through a heterogeneous effect graph network, fusing coarse-grained medical entity information with fine-grained molecular information; and isomorphic relationship graph network is used to model diseases, surgeries, and drugs separately, and a causal weighting mechanism is used to assign weights based on the position of nodes in the causal graph. Disease learning based on causal graphs classifies diseases into causal diseases, effect diseases, intermediate diseases, and independent diseases according to their position in the causal graph through a dynamic adaptive classification mechanism. Personalized representations are achieved through learnable weight allocation, and the same mechanism is applied to surgery and drugs. Patient learning is performed using a Medical Sequence Encoder, which constructs the patient's historical access records into disease sequences, surgical sequences, and drug sequences. Information flow is controlled through a gating mechanism, and local and global temporal patterns are captured by combining self-attention and cross-attention mechanisms. Encoders are configured for the three types of medical entities, and a complete patient representation is constructed by fusing information at the sequence level and access level. The bias correction mechanism uses a multilayer perceptron to generate preliminary drug recommendation probabilities based on the constructed patient representation. It then uses a causal review mechanism to correct bias by leveraging causal relationships, sets dynamic thresholds based on the distribution characteristics of the causal effect matrix, and integrates drug-drug interaction constraints to ensure recommendation safety, ultimately outputting personalized drug recommendation results.
[0009] Furthermore, the drug substructure dual-domain mapping mechanism includes: Constructing a substructure vocabulary using the BRISC algorithm: , in, A vocabulary list representing word structure. Indicates inclusion A collection of different substructure segments, Indicates the dataset All drugs Perform a union operation. Indicates the drug Perform BRICS decomposition on the SMILES string; In the global mapping, the graph isomorphic network GIN is used to process the molecular graph data of the drug; The global drug representation is obtained through weighted aggregation operations: , in, It is the number of atoms in the molecule. It is an atom Importance weights It was through Atoms after layer GIN treatment The final expression, It is a global representation of the drug; In the local domain mapping, the substructure index of the drug is obtained, the initial representation of the substructure is obtained through the substructure embedding layer, and the ensemble attention block (SAB) is set to handle the interaction between substructures. , in, It is the initial embedded representation of the substructure. It is an enhanced substructure representation; The calculation process is as follows: .
[0010] Furthermore, the update rule for GIN is as follows: , in, , These are learnable parameters. , It is the first Multilayer perceptron.
[0011] Furthermore, the drug substructure dual-domain mapping mechanism includes: setting up a patient-perceived contribution network and dynamically adjusting the importance of different substructures according to the patient's specific situation. , in The patient stated that Patient-perceived contribution weight vector It is the weight matrix that contributes to the network; Apply contribution weights to the enhanced substructure representation: , in It is the first Weighted representation of substructures It is the first Enhanced representation of substructures, Is the patient's response to the first Perceptual weights of individual substructures; Finally, the local domain representation is obtained through aggregation using a masking mechanism: , in It is a local domain representation of the drug. It is a mask scalar used to filter the padding substructure. It is the maximum number of substructures; Dual-domain fusion is achieved through a multi-head attention mechanism: , in It is a global representation of the drug. It is a local domain representation of the drug.
[0012] This paper innovatively proposes a dual-domain mapping mechanism for drug substructures. BRICS decomposition technology breaks down complex drug molecules into meaningful functional groups, while simultaneously incorporating a patient-perceived contribution network to achieve personalized drug characterization. This mechanism captures global molecular features of the drug through a graph isomorphism network, handles local substructure interactions through focused attention blocks, and dynamically adjusts the importance weights of different substructures based on the patient's specific condition. Building upon this, a heterogeneous effect graph network fuses coarse-grained medical entity and fine-grained molecular information, while an isomorphic relationship graph network models the relationships between similar entities. This dual-domain mapping and dual-granularity fusion strategy effectively combines the global and local features of the drug, addressing the lack of personalized mechanisms in existing methods and enabling precise individualized drug recommendations.
[0013] Furthermore, the drug dual-granularity information fusion mechanism achieves effective fusion of coarse-grained and fine-grained information through heterogeneous effect graph networks and isomorphic relation graph networks; the drug dual-granularity information fusion mechanism includes: Heterogeneous effect graph networks handle relationships between different types of medical entities: Disease-Molecular Heterogeneous Fusion: = , , Surgical-Molecular Heterogeneous Fusion: = , , in , These are the initial embeddings of disease and surgical entities, respectively. It is an embedded representation of molecular structure. It is a disease-molecular correlation matrix. It is a surgery-molecular correlation matrix. It is a drug-molecule relationship matrix; Heterogeneous graph networks use weighted RGCN for message passing: , in It is a collection of relational classes. It is a node In relation The set of neighboring nodes, It is a relationship In the Layer weight matrix; Isomorphic graph networks are used to model diseases, surgeries, and drugs using isomorphic models: , in They are respectively , , Corresponding input They are respectively , , ; These represent the causes and effects graphs respectively. Causal graph between disease entities extracted from Cause-and-effect graph between surgical entities Causal diagram between drug entities ; Corresponding to , , .in It is a drug representation obtained through two-domain mapping; Homogeneous graph networks employ a causal weighting mechanism, assigning weights to nodes based on their positions within the causal graph: , in It is the first Learnable mask weights for class nodes, It is the first Representation of class nodes.
[0014] Furthermore, the disease learning based on causal graphs employs a dynamic adaptive classification mechanism, classifying diseases into four sets based on the causal position of entities in the causal graph and the in-degree and out-degree of nodes: , The classification function Classify nodes based on their degree characteristics: Cause and effect disease : Diseases that can cause other diseases play a fundamental role in the causal path; Effect diseases : Diseases affected by other diseases play a role as outcomes in the causal path; intermediate disease : Diseases that can both cause and be affected by other diseases play the role of intermediate nodes in the causal path; Independent disease : The disease that existed independently during this visit; A learnable weighting mechanism enhances user personalization by dynamically adjusting the impact of diseases on patients. , in It is the first The representation of similar diseases, and These are trainable weight parameters; The final disease representation is obtained through weighted summation: , in It is the first Learnable mask weights corresponding to disease categories It is the final manifestation of disease; The same mechanism was used in surgery and medication, respectively, to obtain and The final access representation is obtained by concatenating three types of medical entity representations: .
[0015] Furthermore, the Medical Sequence Encoder patient learning mechanism constructs the patient's historical visit records into three parallel sequences: a disease sequence, a surgical sequence, and a drug sequence, each sequence maintaining a temporal order; The Medical Sequence Encoder controls the flow of information through gating functions: , Calculate three types of gating signals: , , , in It is an update gate that controls the degree to which new information is integrated; It is an input gate that controls the effect of the current input; It is the forgetting gate, which controls the degree to which historical information is retained; Combining self-attention and cross-attention mechanisms, self-attention is used to capture dependencies within a sequence, while cross-attention is used to capture the interaction between the current input and the historical state. The multi-sequence parallel encoding process is as follows: , in Corresponding to , , Correspondingly Corresponding to , , ;in This represents the output sequence at each time step. This indicates the final hidden state; The patient stated that the fusion employed two information fusion strategies to extract sequence-level information: , Extract access level information: , The patient ultimately stated that the results were obtained through splicing: .
[0016] Using the methods described above, a dynamic adaptive classification mechanism based on causal graphs and a Medical Sequence Encoder are employed for patient learning. Diseases are categorized into four types—causal diseases, effect diseases, intermediate diseases, and independent diseases—based on their position in the causal graph, and a learnable weight allocation mechanism is designed for each category, achieving truly personalized medical modeling. The Medical Sequence Encoder combines gating and dual attention mechanisms for long-term temporal modeling. By designing a collaborative control mechanism for update, input, and forget gates, it effectively balances the long-term preservation of historical information with the timely integration of new information, solving the information loss problem of traditional GRUs when handling complex long-term temporal dependencies. This significantly improves the modeling capability and parallel processing efficiency of long-term patient historical data.
[0017] Furthermore, the deviation correction mechanism includes: Based on the constructed patient representation, a multilayer perceptron is used to generate preliminary drug recommendation probabilities: , , in It is the Sigmoid activation function, which converts the original scores into probability values; The causal review mechanism uses learned causal relationships to correct biases, sets dynamic thresholds based on the distribution characteristics of the causal effect matrix, and calculates the 97th and 90th percentiles of the causal effect matrix as high thresholds. and low threshold ; For each drug Calculate its maximum causal effect on the current patient's disease and surgery, and correct for bias based on the effect strength: , in and It is a learnable correction parameter that can be adaptively adjusted according to the specific strength of the causal effect; Safety constraints are achieved through integrated drug-drug interaction constraints, and the correction strength is dynamically adjusted by monitoring the DDI rate of the recommendation results during the deviation correction process. The multi-task loss function is set as follows: , Among them is Binary cross-entropy loss, It is the marginal loss of multiple labels. It is DDI loss.
[0018] Furthermore, the construction of the causal graph based on the large-scale language model includes: A complete medical entity information dictionary is constructed, with accurate medical descriptions provided by the LLM through prompt templates. The enhanced entity information includes: concise Chinese medical names, detailed clinical descriptions, and official medical codes or standard terms. The causal edge inference process is as follows: , in, To improve causal inference, It is a medical knowledge base. and These are the source and target entity sets, respectively. A hierarchical inference strategy is employed to decompose large sets of entities into smaller batches for processing. The structure of each batch is integrated into a complete causal graph; a loop removal mechanism is used to detect and remove any possible cyclic edges, ensuring that the final causal graph meets the basic requirements of causal inference.
[0019] By employing the methods described above, LLM-driven causal reasoning technology is introduced, fully leveraging the deep knowledge and powerful reasoning capabilities of large-scale language models in the medical field. Compared to traditional methods relying on statistical algorithms, LLM can understand complex medical terminology and concepts, and based on pre-trained medical knowledge, comprehend deep medical principles such as drug action mechanisms and disease progression. Through the design of specialized causal inference prompts and hierarchical inference strategies, combined with the quantification of causal relationship strength using a GLM model, complex causal relationships between diseases, surgeries, and drugs can be accurately identified. This provides more reliable and comprehensive theoretical support for causal relationship identification, significantly improving the rationality and interpretability of drug recommendations.
[0020] Furthermore, the quantification of causal strength includes: A discretized generalized linear model is used to model the causal effects between disease / surgery and drugs: , in, This refers to the logit linker function. Represents the probability of a binary variable. The intercept is... These are the corresponding coefficients. The independent variables of the model cover records of diseases, surgeries, and medications; The causal effect matrices of disease-drug and surgery-drug are obtained, denoted as follows: and .
[0021] Compared with existing technologies, the advantages of this invention are: This method addresses key limitations of existing drug recommendation systems in areas such as medical knowledge-driven causal reasoning, fusion of multi-granular drug representations based on patient perception, and long-sequence temporal modeling. It innovatively proposes a solution comprising three core modules: an LLM-driven causal graph construction module that leverages the medical knowledge and reasoning capabilities of a large-scale language model to identify causal relationships between medical entities; a drug substructure dual-domain mapping module that combines BRICS decomposition and a Set Attention mechanism with a patient-perceived contribution network to effectively fuse global and local drug representations; and a Medical Sequence Encoder module that integrates gating and dual attention mechanisms to enhance long-sequence modeling capabilities. Based on the causal graph construction, it achieves dual-granularity drug information fusion through heterogeneous effect graph networks and isomorphic relation graph networks, employs a dynamic adaptive classification mechanism for disease learning based on the causal graph, and finally corrects biases through a causal review mechanism. Experimental results demonstrate that this method significantly outperforms existing methods in terms of accuracy, safety, and computational efficiency, providing more reliable intelligent support for clinical decision-making. Attached Figure Description
[0022] Figure 1 This is a flowchart of a two-granularity drug recommendation method based on causal reasoning driven by a large language model.
[0023] Figure 2 This is an overall architecture diagram of a two-granularity drug recommendation method based on large-scale language model-driven causal reasoning.
[0024] Figure 3 A schematic diagram of a prompt template design for enhancing LLM medical entities.
[0025] Figure 4 A schematic diagram of a prompt template for LLM causal inference. Detailed Implementation
[0026] It should be noted that relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. 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 said element.
[0027] The features and performance of the present invention will be further described in detail below with reference to embodiments.
[0028] Existing methods have the following significant limitations: Addressing the issue of insufficient causal reasoning capabilities driven by medical knowledge: Existing causal reasoning methods primarily rely on statistical algorithms to uncover causal relationships, lacking a deep understanding of medical expertise and semantic reasoning capabilities. While these methods can identify statistical dependencies, they struggle to accurately capture the complex semantic relationships and clinical logic between medical entities. Although causal reasoning methods based on statistical algorithms can identify causal chains, the lack of medical knowledge guidance makes it difficult to accurately determine the pathological mechanisms of diseases, the mechanisms of drug action, and the treatment matching relationships between them through semantic reasoning. Furthermore, they may still lead to inaccurate recommendations when encountering complex disease combinations.
[0029] Addressing the lack of a multi-granularity drug representation fusion mechanism based on patient perception: Existing methods lack an effective mechanism for integrating multi-granularity information based on patient perception in drug representation learning. On the one hand, traditional methods treat the drug as a whole for modeling, ignoring the differences in substructures within the molecule; on the other hand, existing molecular representation methods employ a uniform encoding strategy, lacking a personalized mechanism based on patient perception, making it difficult to dynamically adjust the importance weights of different drug substructures according to the patient's specific state. Furthermore, the lack of an effective dual-domain mapping mechanism between global drug features and local substructure features prevents synergistic fusion, leading to biases in drug representation learning.
[0030] Addressing the shortcomings of information preservation and parallel processing capabilities in long-term time series modeling: Existing methods face significant challenges when processing long-term patient historical information. While the traditional GRU alleviates the vanishing gradient problem through gating mechanisms, its simplified dual-gating structure still suffers from information loss when handling complex long-term temporal dependencies. Specifically, GRU struggles to effectively balance the long-term preservation of historical information with the timely integration of new information; crucial historical disease information and drug response patterns are easily forgotten. Furthermore, a single gating mechanism cannot simultaneously capture multi-level temporal patterns, and the sequential processing nature of GRU limits its parallelization capabilities, resulting in low computational efficiency when processing large-scale patient historical data, making it difficult to meet the needs of real-time clinical decision-making.
[0031] Please see Figure 1-4 A two-granularity drug recommendation method based on causal reasoning driven by a large language model, such as... Figure 1 and Figure 2 As shown, it includes: Acquire and organize Electronic Health Record (EHR) data, encoding and converting patient medical information according to a pre-defined medical coding system (e.g., ICD-9 and ICD-10 for diseases, ATC-3 for medications) to form a dataset format suitable for subsequent processing. Each patient's record uses... It indicates that it includes longitudinal medical records. }, each medical visit record Includes diseases Surgical procedure and medicine The three elements are encoded using multi-hot encoding technology. Simultaneously, the data undergoes cleaning and standardization to ensure data quality and consistency. A causal graph of medical entities is constructed based on a large-scale language model. First, all entities to be processed are collected from a vocabulary file, including diagnostic, surgical, and drug entities. For each entity, a specific prompt template is set to require the LLM to provide an accurate medical description. The enhanced entity information includes three key components: a concise Chinese medical name, a detailed clinical description (including key features, symptoms, or pathological manifestations), and an official medical code or standard terminology. This comprehensive information enhancement provides a rich semantic foundation for subsequent causal relationship inference.
[0032] Then, the medical knowledge and reasoning abilities of an LLM are used to identify causal relationships, such as... Figure 3 and Figure 4As shown, specific causal inference prompts are set up to guide LLM in identifying causal relationships between entities. Given a set of source entities and a set of target entities, detailed medical context prompts are constructed, including complete medical descriptions of each entity. System instructions emphasize the role of LLM as a senior clinical medical expert, requiring them to identify possible causal relationships between source and target entities based on medical knowledge, with a focus on direct causal associations in clinical pathways.
[0033]
[0034] in It is a specially designed prompt for causal inference. It is a medical knowledge base. and These are the source and target entity sets, respectively. The system instructions emphasize the role of LLM as a senior clinical medical expert, requiring them to identify possible causal relationships between source and target entities based on medical knowledge, with a focus on direct causal associations in clinical pathways.
[0035] A hierarchical inference strategy is employed to decompose large sets of entities into smaller batches for processing, and the results of each batch are subsequently integrated into the complete causal graph. A cycle removal mechanism is used to detect and remove any possible cyclic edges, ensuring that the final causal graph meets the basic requirements of causal inference.
[0036] Quantifying the strength of causal relationships is crucial, as significant causal relationships also exist between different types of medical entities, in addition to those between homogeneous medical entities. A causal inference approach is employed to quantify the causal effects of drugs on diseases or surgical procedures. The causal graph is represented as a binary variable, and then a discretized generalized linear model (GLM) is used to model the causal effects between diseases / surgeries and drugs.
[0037] in, This refers to the logit linker function. Represents the probability of a binary variable. The intercept is... These are the corresponding coefficients. The independent variables of the model cover records of diseases, surgeries, and medications. Probability of a binary variable This demonstrates the likelihood of a drug producing a positive response in patients with specific diseases or undergoing specific surgeries, thus elucidating the causal effect of specific diseases or surgeries on drugs. Ultimately, disease-drug and surgery-drug causal effect matrices are obtained, denoted as follows: and .
[0038] Establish medical entity representations, focusing on the actual medical entities appearing in patient records during the entity representation learning phase. Create embedding tables for diseases and surgeries, with each row corresponding to a specific disease or surgery.
[0039]
[0040] in , Indicates a specific medical entity, and Representing entities respectively and Embedded.
[0041] To implement a drug substructure dual-domain mapping mechanism, the BRICS algorithm is first used to decompose the drug's SMILES string and construct a substructure vocabulary.
[0042] in A vocabulary list representing word structure. Indicates inclusion A collection of different substructure segments, Indicates the dataset All drugs Perform a union operation. Indicates the drug The SMILES string is decomposed using BRICS. The BRICS algorithm can decompose complex drug molecule structures into meaningful substructure fragments, which usually correspond to functional groups of the drug and have important pharmacological significance.
[0043] In global domain mapping, graph isomorphic networks (GINs) are used to process the molecular graph data of the drug to obtain a global drug representation. The update rule for GINs is as follows:
[0044] in , These are learnable parameters. , It is the first Multilayer perceptron.
[0045] The global drug representation is obtained through weighted aggregation operations:
[0046] in It is the number of atoms in the molecule. It is an atom Importance weights It was through Atoms after layer GIN treatment The final expression, It is a global representation of the drug.
[0047] In local domain mapping, the substructure index of the drug is first obtained, the initial representation of the substructure is obtained through the substructure embedding layer, and then the ensemble attention block (SAB) is set to handle the interaction between substructures:
[0048] in It is the initial embedded representation of the substructure. It is an enhanced substructure representation.
[0049] The calculation process for SAB is as follows:
[0050] Configure a patient-perceived contribution network, adjusting the importance of different substructures based on the patient's specific situation:
[0051] in The patient stated that Patient-perceived contribution weight vector It is the weight matrix that contributes to the network.
[0052] Apply contribution weights to the enhanced substructure representation:
[0053] in It is the first Weighted representation of substructures It is the first Enhanced representation of substructures, Is the patient's response to the first Perceived weights of individual structures.
[0054] Finally, the local domain representation is obtained through aggregation using a masking mechanism:
[0055] in It is a local domain representation of the drug. It is a mask scalar used to filter the padding substructure. It is the maximum number of substructures.
[0056] Dual-domain fusion is achieved through a multi-head attention mechanism:
[0057] in It is a global representation of the drug. It is a local domain representation of the drug.
[0058] To achieve dual-granularity information fusion for drugs, after obtaining the dual-domain mapping results of drug substructures, coarse-grained (medical entity level) and fine-grained (molecular level) information are effectively fused through heterogeneous effect graph network and isomorphic relationship graph network.
[0059] Heterogeneous effect graph networks handle the relationships between different types of medical entities, achieving the fusion of coarse-grained medical entity information and fine-grained molecular information: Disease-Molecular Heterogeneous Fusion:
[0060]
[0061] Surgical-Molecular Heterogeneous Fusion:
[0062]
[0063] in , These are the initial embeddings of disease and surgical entities, respectively. It is an embedded representation of molecular structure. It is a disease-molecular correlation matrix. It is a surgery-molecular correlation matrix. It is a drug-molecule relationship matrix.
[0064] Heterogeneous graph networks employ weighted RGCN (W-RGCN) for message passing, dividing relationships into multiple levels based on the correlation matrix:
[0065] in It is a collection of relational classes. It is a node In relation The set of neighboring nodes, It is a relationship In the Layer weight matrix.
[0066] Based on heterogeneous fusion, homogeneous modeling of diseases, surgeries, and drugs is performed separately using a homogeneous relational graph network:
[0067] in They are respectively , , Corresponding input They are respectively , , ; These represent the causes and effects graphs respectively. Causal graph between disease entities extracted from Cause-and-effect graph between surgical entities Causal diagram between drug entities ; Corresponding to , , .in The drug representation is obtained through two-domain mapping.
[0068] Homogeneous graph networks employ a causal weighting mechanism, assigning weights to nodes based on their positions within the causal graph:
[0069] in It is the first Learnable mask weights for class nodes, It is the first Representation of class nodes (source node, sink node, intermediate node, orphan node).
[0070] Disease learning based on causal graphs addresses the fact that the same disease has varying effects on different individuals due to differences in their physical constitutions. Furthermore, different diseases also influence each other, with these effects varying from person to person. Therefore, a dynamic adaptive classification (DAC) mechanism is employed to learn the impact of diseases in various clinical settings, thereby enhancing personalized learning for patients.
[0071] Causal Location Classification Mechanism: DAC learns the interactions between similar medical entities from the causal graph and integrates them into the clinical visit representation. Based on the causal location of entities in the causal graph, diseases are divided into four sets by the in-degree and out-degree of nodes:
[0072] The classification function Classify nodes based on their degree characteristics: Cause and effect disease : Diseases that can cause other diseases play a fundamental role in the causal path; Effect diseases : Diseases affected by other diseases play a role as outcomes in the causal path; intermediate disease : Diseases that can both cause and be affected by other diseases play the role of intermediate nodes in the causal path; Independent disease : The disease that existed independently during this visit; Learnable weight allocation mechanism: Since the same disease occupies different positions in the causal graphs of different patients, leading to different DAC classification results, this mechanism enhances user personalization by dynamically adjusting the impact of diseases on patients. A learnable mask layer is designed for each type of disease category, assigning different weights to different types of diseases.
[0073] in It is the first The representation of similar diseases, and These are trainable weight parameters.
[0074] Access representation aggregation: Each disease category is weighted using its corresponding learnable mask weights, and the final weighted sum is used to obtain a comprehensive representation of the disease.
[0075] in It is the first Learnable mask weights corresponding to disease categories It is the final manifestation of disease.
[0076] Similarly, the same mechanisms of action were applied to both surgery and medication, yielding different results. and The final access representation is obtained by concatenating three types of medical entity representations:
[0077] Patient learning is performed using a Medical Sequence Encoder. After learning the representation for a single visit, the patient's historical medical records are integrated to construct a complete patient representation. The patient's historical visit records are constructed as three parallel sequences: disease sequence... , and drug sequence .
[0078] The core of the Medical Sequence Encoder is the gating mechanism, which controls the flow of information through gating functions:
[0079] Calculate three types of gating signals:
[0080]
[0081]
[0082] in It is an update gate that controls the degree to which new information is integrated; It is an input gate that controls the effect of the current input; It is the forgetting gate, which controls the degree to which historical information is retained.
[0083] Combining self-attention and cross-attention mechanisms, self-attention is used to capture dependencies within a sequence, while cross-attention is used to capture the interaction between the current input and the historical state.
[0084] Configure a separate Medical Sequence Encoder for each of the three types of medical entities:
[0085] in Corresponding to , , Correspondingly Corresponding to , , .in This represents the output sequence at each time step. This represents the final hidden state, which encodes information about the entire sequence.
[0086] The patient stated that the fusion employed two information fusion strategies. First, sequence-level information was extracted, namely the final hidden state of each encoder:
[0087] Secondly, access level information is extracted, specifically the output of the last time step of each sequence, which represents the patient's current medical status:
[0088] The final patient's statement was obtained by piecing together these two pieces of information:
[0089] A bias correction mechanism is implemented, using a multilayer perceptron (MLP) based on the constructed patient representation to generate preliminary drug recommendation probabilities:
[0090]
[0091] in It's the Sigmoid activation function, which converts the raw scores into probability values. These initial probabilities... This reflects a tendency to recommend medications based on the patient's history and current condition.
[0092] Causal review mechanism: Since biases inevitably occur during model training, a bias correction mechanism based on causal relationships is implemented. This mechanism uses the causal relationships learned during the relationship mining phase to correct the model's prediction bias.
[0093] First, dynamic thresholds are set based on the distribution characteristics of the causal effect matrix. These thresholds are determined according to the actual distribution of the data to ensure the adaptability of the correction mechanism. The 97th and 90th quantiles of the causal effect matrix are calculated as high thresholds. and low threshold . For each drug Calculate its maximum causal effect on the current patient's disease and surgery, and correct for bias based on the effect strength:
[0094] in and It is a learnable correction parameter that can be adaptively adjusted according to the specific causal effect strength.
[0095] Safety constraints are achieved through integrated drug-drug interaction (DDI) constraints, with the correction strength dynamically adjusted by monitoring the DDI rate of the recommended results during the deviation correction process.
[0096] The multi-task loss function is designed as follows: (48) Among them is Binary cross-entropy loss, It is the marginal loss of multiple labels. It is DDI loss.
[0097] Experimental verification The test platform and experimental environment are as follows: The experimental environment uses the Ubuntu 22.04 operating system, a 24GB NVIDIA RTX 3090 GPU for computing, a 12-core CPU (single-core utilization of 64.3%), 30GB of memory (3.4GB used), and software dependencies including PyTorch version 2.0.0 and CUDA version 11.7, and Python language environment.
[0098] The dataset used is from the MIMIC public dataset: The MIMIC-III dataset contains 6350 patients, 15032 visits, 1958 diseases, 1430 surgeries, and 131 medications, with an average of 2.37 visits and an average of 11.44 medications. The data covers clinical records, physiological monitoring data, laboratory test results, and medication records from the Intensive Care Unit (ICU). The same data preprocessing methods as previous studies were used, with ICD-9 codes used to record diseases and surgeries, and medications mapped to ATC-3 codes. Only visit records containing disease, surgery, and medication information were retained.
[0099] Evaluation indicators: Jaccard (Jaccard Similarity Score): Used to measure the similarity between two sets. In drug recommendation, a higher Jaccard score indicates that the predicted prescription is more consistent with the actual medication regimen, i.e., higher accuracy.
[0100]
[0101]
[0102] in, Indicates the prediction result. Indicates the true label, Indicates the patient Total number of medical visits.
[0103] DDI (Drug-Drug Interaction Rate): Measures the likelihood of drug interactions in a recommended combination. The lower the rate, the safer the drugs are.
[0104] in, and These respectively represent medical visits Real-time and predictive multi-label, express The One entry, It is the previous DDI relationship matrix. It is an indicator function, when Returns 1 if the condition is met, otherwise returns 0.
[0105] F1 (F1 score): Combines precision and recall, reflecting the model's ability to accurately identify the correct drug while ensuring comprehensive coverage.
[0106]
[0107]
[0108]
[0109]
[0110] PRAUC (Area Under the Precision-Recall Curve): Evaluates the performance of a model at different recall levels, indicating its ability to maintain precision as recall increases.
[0111]
[0112]
[0113] in, Indicates the quantity of medicine. It is the ranking within the retrieved drug sequence. Indicates the end of the ordered search list The accuracy rate The drug rankings are from arrive The recall rate changes. We take the average PRAUC for all patient visits:
[0114] Avg.#Med (Average Number of Medications): Represents the average number of medications recommended per treatment. A higher value indicates a more complex combination, which may increase the risk of adverse reactions; a lower value indicates a safer and simpler treatment plan. This indicator is for reference only and should not be used as a strict evaluation standard.
[0115]
[0116] in, Indicates the patient The The number of medications predicted during the first visit.
[0117] Configuration parameters: For all entity embeddings, the optimal dimension is set to 64. GIN has only 1 layer, and W-RGCN has 2 layers. The activation function of the MLP in this application is the Sigmoid function, with a dropout rate of 0.5. In the bias correction module, the upper bound... Set to 0.97, lower bound Set it to 0.90. In the loss function, Set to 0.95, kp to 0.05, acceptance rate Set to 0.06. Training epochs=10, using the Adam optimizer, learning rate lr=0.0005, regularization factor Reg=0.05, and no batch processing during training.
[0118] Performance comparison results: Through comparative experiments with multiple baseline models (including LR, ECC, RETAIN, GAMENet, SafeDrug, MICRON, COGNet, MoleRec, CausalMed, CIDGMed, BiMoRec, AMGNet, MKAF, etc.), LLM-CIDGMed achieved superior performance on the MIMIC-III dataset. The results are shown in the table below.
[0119] Table 1 Model Performance Comparison
[0120] In efficacy analyses, LR and ECC, using traditional machine learning methods, showed moderate accuracy but still faced high drug-drug interaction (DDI) rates. Sequence-based models employing advanced deep learning techniques failed to outperform these traditional methods in terms of efficacy. RETAIN, which incorporates sequence models, neglects drug-drug interactions, thus increasing the DDI rate. In contrast, LLM-CIDGMed, through the synergistic effect of LLM-driven causal inference, dual-domain mapping of drug substructures, and temporal modeling using a Medical Sequence Encoder, significantly improved the Jaccard index in accuracy compared to the best baseline model, significantly reduced the DDI rate in terms of safety, and also achieved comprehensive superiority in F1 score and PRAUC metrics.
[0121] Case studies validated the interpretability and clinical applicability of the method. LLM-driven causal reasoning can provide clear medical logic explanations, the drug substructure dual-domain mapping mechanism can identify key pharmacologically active groups, and the disease classification based on causal graphs can reflect the different roles of diseases in treatment.
[0122] This application, through the synergistic effect of LLM-driven causal graph construction, dual-domain mapping of drug substructures, fusion of heterogeneous effect graph networks and isomorphic relation graph networks, causal graph-based disease learning, medical sequence encoder temporal modeling, and causal review bias correction mechanisms, not only improves the accuracy and safety of drug recommendations, but more importantly, enhances the interpretability and medical rationality of the recommendations. This method can provide more reliable intelligent support for clinical decision-making, and has significant academic value and practical significance in promoting the development of precision medicine and improving the level of intelligent medical decision-making.
[0123] The embodiments described above merely illustrate specific implementation methods of this application, and while the descriptions are detailed and specific, they should not be construed as limiting the scope of protection of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the technical solution of this application, and these modifications and improvements all fall within the scope of protection of this application.
Claims
1. A two-granularity drug recommendation method based on causal reasoning driven by a large language model, characterized in that, Includes the following steps: Electronic health records are acquired and preprocessed, and medical information is encoded and converted to form a structured dataset that includes disease, surgical procedure, and drug information. A causal graph is constructed based on a large language model. LLM augmentation is performed on all medical entities in the structured dataset. The medical knowledge and reasoning ability of LLM are used to identify causal relationships between medical entities through causal inference prompts. To quantify the strength of causal relationships, a discretized generalized linear model is used to model the causal effects between disease / surgery and drugs, resulting in causal effect matrices for disease-drug and surgery-drug relationships. The drug substructure dual-domain mapping mechanism decomposes the drug's SMILES string using the BRICS algorithm to construct a substructure vocabulary; in the global domain mapping, a network isomorphism network is used to process the drug's molecular graph data to obtain a global drug representation. In local mapping, the interaction between substructures is handled by ensemble attention blocks, and the contribution network of patient perception is set according to the importance of different substructures based on the patient's condition. Global and local representations are fused through a multi-head attention mechanism. Drug dual-granularity information fusion is achieved by processing the relationships between different types of medical entities through a heterogeneous effect graph network, fusing coarse-grained medical entity information with fine-grained molecular information; and isomorphic relationship graph network is used to model diseases, surgeries, and drugs separately, and a causal weighting mechanism is used to assign weights based on the position of nodes in the causal graph. Disease learning based on causal graphs classifies diseases into causal diseases, effect diseases, intermediate diseases, and independent diseases according to their position in the causal graph through a dynamic adaptive classification mechanism. Personalized representations are achieved through learnable weight allocation, and the same mechanism is applied to surgery and drugs. Patient learning is performed using a Medical Sequence Encoder, which constructs the patient's historical access records into disease sequences, surgical sequences, and drug sequences. Information flow is controlled through a gating mechanism, and local and global temporal patterns are captured by combining self-attention and cross-attention mechanisms. Encoders are configured for the three types of medical entities, and a complete patient representation is constructed by fusing information at the sequence level and access level. The bias correction mechanism uses a multilayer perceptron to generate preliminary drug recommendation probabilities based on the constructed patient representation. It then uses a causal review mechanism to correct bias by leveraging causal relationships, sets dynamic thresholds based on the distribution characteristics of the causal effect matrix, and integrates drug-drug interaction constraints to ensure recommendation safety, ultimately outputting personalized drug recommendation results.
2. The two-granularity drug recommendation method based on large-scale language model-driven causal reasoning according to claim 1, characterized in that, The drug substructure dual-domain mapping mechanism includes: Constructing a substructure vocabulary using the BRISC algorithm: , in, A vocabulary list representing word structure. Indicates inclusion A collection of different substructure segments, Indicates the dataset All drugs Perform a union operation. Indicates the drug Perform BRICS decomposition on the SMILES string; In the global mapping, the graph isomorphic network GIN is used to process the molecular graph data of the drug; The global drug representation is obtained through weighted aggregation operations: , in, It is the number of atoms in the molecule. It is an atom Importance weight, It was through Atoms after layer GIN treatment The final expression, It is a global representation of the drug; In the local domain mapping, the substructure index of the drug is obtained, the initial representation of the substructure is obtained through the substructure embedding layer, and the ensemble attention block (SAB) is set to handle the interaction between substructures. , in, It is the initial embedded representation of the substructure. It is an enhanced substructure representation; The calculation process is as follows: 。 3. The two-granularity drug recommendation method based on large-scale language model-driven causal reasoning according to claim 2, characterized in that, The update rules for GIN are as follows: , in, , These are learnable parameters. , It is the first Multilayer perceptron.
4. The two-granularity drug recommendation method based on large-scale language model-driven causal reasoning according to claim 2, characterized in that, The drug substructure dual-domain mapping mechanism also includes: Configure a patient-perceived contribution network and dynamically adjust the importance of different substructures based on the patient's specific situation: , in The patient stated that Patient-perceived contribution weight vector It is the weight matrix that contributes to the network; Apply contribution weights to the enhanced substructure representation: , in It is the first Weighted representation of substructures It is the first Enhanced representation of substructures, Is the patient's response to the first Perceptual weights of individual substructures; Finally, the local domain representation is obtained through aggregation using a masking mechanism: , in It is a local domain representation of the drug. It is a mask scalar used to filter the padding substructure. It is the maximum number of substructures; Dual-domain fusion is achieved through a multi-head attention mechanism: , in It is a global representation of the drug. It is a local domain representation of the drug.
5. The two-granularity drug recommendation method based on large-scale language model-driven causal reasoning according to claim 1, characterized in that, The drug dual-granularity information fusion mechanism achieves effective fusion of coarse-grained and fine-grained information through heterogeneous effect graph networks and isomorphic relation graph networks; the drug dual-granularity information fusion mechanism includes: Heterogeneous effect graph networks handle relationships between different types of medical entities: Disease-Molecular Heterogeneous Fusion: = , , Surgical-Molecular Heterogeneous Fusion: = , , in , These are the initial embeddings of disease and surgical entities, respectively. It is an embedded representation of molecular structure. It is a disease-molecular correlation matrix. It is a surgery-molecular correlation matrix. It is a drug-molecule relationship matrix; Heterogeneous graph networks use weighted RGCN for message passing: , in It is a collection of relational classes. It is a node In relation The set of neighboring nodes below, It is a relationship In the Layer weight matrix; Isomorphic graph networks are used to model diseases, surgeries, and drugs using isomorphic models: , in They are respectively , , Corresponding input They are respectively , , ; These represent the causes and effects graphs. Causal graph between disease entities extracted from Causal graph between surgical entities Causal diagram between drug entities ; Corresponding to , , ;in It is a drug representation obtained through two-domain mapping; Homogeneous graph networks employ a causal weighting mechanism, assigning weights to nodes based on their positions within the causal graph: , in It is the first Learnable mask weights for class nodes, It is the first Representation of class nodes.
6. The two-granularity drug recommendation method based on large-scale language model-driven causal reasoning according to claim 1, characterized in that, The disease learning based on causal graphs employs a dynamic adaptive classification mechanism, which divides diseases into four sets based on the causal position of entities in the causal graph and the in-degree and out-degree of nodes: , The classification function Classify nodes based on their degree characteristics: Cause and effect disease : Diseases that can cause other diseases play a fundamental role in the causal path; Effect diseases : Diseases affected by other diseases play a role as outcomes in the causal path; intermediate disease : Diseases that can both cause and be affected by other diseases play the role of intermediate nodes in the causal path; Independent disease : The disease that existed independently during this visit; A learnable weighting mechanism enhances user personalization by dynamically adjusting the impact of diseases on patients. , in It is the first The representation of similar diseases, and These are trainable weight parameters; The final disease representation is obtained through weighted summation: , in It is the first Learnable mask weights corresponding to disease categories It is the final manifestation of disease; The same mechanism was used in surgery and medication, respectively, to obtain and The final access representation is obtained by concatenating three types of medical entity representations: 。 7. The two-granularity drug recommendation method based on large-scale language model-driven causal reasoning according to claim 1, characterized in that, The Medical Sequence Encoder patient learning mechanism constructs the patient's historical visit records into three parallel sequences: disease sequence, surgical sequence, and drug sequence, each of which maintains a chronological order. The Medical Sequence Encoder controls the flow of information through gating functions: , Calculate three types of gating signals: , , , in It is an update gate that controls the degree to which new information is integrated; It is an input gate that controls the effect of the current input; It is the forgetting gate, which controls the degree to which historical information is retained; Combining self-attention and cross-attention mechanisms, self-attention is used to capture dependencies within a sequence, while cross-attention is used to capture the interaction between the current input and the historical state. The multi-sequence parallel encoding process is as follows: , in Corresponding to , , Correspondingly Corresponding to , , ;in This represents the output sequence at each time step. This indicates the final hidden state; The patient stated that the fusion employed two information fusion strategies to extract sequence-level information: , Extract access level information: , The patient ultimately stated that the results were obtained through splicing: 。 8. The two-granularity drug recommendation method based on large-scale language model-driven causal reasoning according to claim 1, characterized in that, The deviation correction mechanism includes: Based on the constructed patient representation, a multilayer perceptron is used to generate preliminary drug recommendation probabilities: , , in It is the Sigmoid activation function, which converts the original scores into probability values; The causal review mechanism uses learned causal relationships to correct biases, sets dynamic thresholds based on the distribution characteristics of the causal effect matrix, and calculates the 97th and 90th percentiles of the causal effect matrix as high thresholds. and low threshold ; For each drug Calculate its maximum causal effect on the current patient's disease and surgery, and correct for bias based on the effect strength: , in and It is a learnable correction parameter that can be adaptively adjusted according to the specific strength of the causal effect; Safety constraints are achieved through integrated drug-drug interaction constraints, and the correction strength is dynamically adjusted by monitoring the DDI rate of the recommendation results during the deviation correction process. The multi-task loss function is set as follows: , Among them is Binary cross-entropy loss, It is the marginal loss of multiple labels. It is DDI loss.
9. The two-granularity drug recommendation method based on large-scale language model-driven causal reasoning according to claim 1, characterized in that, The construction of causal graphs based on large-scale language models includes: A complete medical entity information dictionary is constructed, with accurate medical descriptions provided by the LLM through prompt templates. The enhanced entity information includes: concise Chinese medical names, detailed clinical descriptions, and official medical codes or standard terms. The causal edge inference process is as follows: , in, To improve causal inference, It is a medical knowledge base. and These are the source and target entity sets, respectively. A hierarchical inference strategy is adopted to decompose large sets of entities into small batches for processing; the structure of each batch is integrated into a complete causal graph; and any possible cyclic edges are detected and removed through a cyclic removal mechanism to ensure that the final causal graph meets the basic requirements of causal inference.
10. A two-granularity drug recommendation method based on large-scale language model-driven causal reasoning according to claim 1, characterized in that, The quantification of causal relationship strength includes: A discretized generalized linear model is used to model the causal effects between disease / surgery and drugs: , in, This refers to the logit linker function. Represents the probability of a binary variable. The intercept is... These are the corresponding coefficients. The independent variables of the model cover records of diseases, surgeries, and medications; The causal effect matrices of disease-drug and surgery-drug are obtained, denoted as follows: and .