A boundary-aware drug recommendation method based on the collaboration of deep models and large language models
By combining deep models with large language models and optimizing drug recommendations using fine-grained probability distributions and drug interaction constraints, the problem of coarse decision-making by large language models and insufficient reasoning by deep models in drug recommendation is solved, thus achieving more accurate and safer drug recommendations.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- FUZHOU UNIV
- Filing Date
- 2026-03-25
- Publication Date
- 2026-07-03
AI Technical Summary
In existing drug recommendation methods, large language models make coarse binary decisions when recommending drugs, leading to overprescription and reduced clinical accuracy, while deep models lack the ability to reason about the context of complex cases and have difficulty effectively handling boundary drugs.
By combining deep learning models and large language models, the fine-grained probability distribution of deep learning models is used to segment drug subsets, and the boundary drug prediction of large language models is optimized by retrieving similar electronic health records and drug interaction constraints, resulting in more accurate and safer drug recommendations.
It improves the accuracy and safety of drug recommendations, reduces the risk of drug interactions, and enables more precise and safer personalized medication.
Smart Images

Figure CN121905583B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a boundary-aware drug recommendation method based on the collaboration of deep models and large language models. Background Technology
[0002] Medication recommendation is a crucial step in clinical decision-making, aiming to provide patients with appropriate, accurate, and safe prescriptions based on their electronic health records (EHRs). With the rapid development of large language models (LLMs) such as GPT and LLaMA, recent research has begun to explore their application potential in the medical field (e.g., clinical report generation, medical question answering), fully leveraging the models' powerful semantic reasoning and generalization capabilities. These advantages have prompted researchers to apply large language models to medication recommendation tasks, typically by fine-tuning the models on large-scale clinical corpora to improve their domain adaptability.
[0003] Despite the potential of large language model (LLM)-based methods, significant challenges remain in drug recommendation. Figure 1 As shown in the upper part of (a), large language models like Qwen3-8B typically make a coarse binary prediction about whether a certain drug should be recommended, thus ignoring drugs that are near the decision boundary. Figure 1 As shown in (b), this behavior often leads to overprescribing, reducing clinical accuracy, with large language models recommending more drugs than the actual dataset. In contrast, deep models trained on structured electronic health record (EHR) data (such as SafeDrug) provide fine-grained probability distributions for candidate drugs. Figure 1 (Lower half of (a)). This allows for more precise control over predictions and improves coverage of drugs within the boundary region, which are often missed by large language models. These boundary drugs are often ambiguous but clinically valuable, and their correct identification is crucial for generating safe and effective prescriptions. However, deep models often lack the contextual reasoning capabilities required to handle complex cases, especially when it comes to boundary drugs.
[0004] While large language models possess semantic reasoning capabilities, they are crude in binary decision-making; deep models, though offering fine-grained control, lack the reasoning abilities required for complex clinical scenarios. This complementary model of limitations raises a crucial question: can the precise control of deep models be combined with the semantic reasoning capabilities of large language models to improve drug recommendations, especially in boundary cases? Summary of the Invention
[0005] The purpose of this invention is to provide a boundary-aware drug recommendation method based on the collaboration of deep models and large language models. This method combines the optimized boundary drug probabilities of the large language model with the deterministic prediction results of the deep model to generate more accurate and safer prescriptions. This invention can improve recommendation accuracy while reducing the risk of drug interactions, thus achieving more precise and safer personalized medication recommendations.
[0006] To achieve the above objectives, the technical solution of the present invention is: a boundary-aware drug recommendation method based on the collaboration of deep models and large language models, comprising:
[0007] The trained deep drug recommendation model is used to process the patient's current medical records to obtain the predicted probability distribution of all candidate drugs, and the candidate drugs are divided into a boundary drug subset and a confidence drug subset based on this probability distribution.
[0008] Retrieve historical electronic health records similar to the current medical record, and construct a set of DDI conflicts related to the boundary drug subset based on predefined drug interaction (DDI) constraints to form enhanced contextual information;
[0009] The current medical record, the boundary drug subset and its predicted probability, and enhanced contextual information are synthesized into the prompt words, input into the large language model, obtain the optimized probability of the boundary drug subset, and fuse the optimized probability with the probability of the confidence drug subset to generate the final drug recommendation list.
[0010] Furthermore, the process of obtaining the predicted probability distribution of all candidate drugs and dividing the drug subsets includes:
[0011] Using a deep drug recommendation model to analyze the patient's current medical records The drug probability distribution is obtained through processing. The formula is:
[0012]
[0013] in, and These are multiple heat vectors representing current medical diagnosis information and medical procedure information, respectively. These represent the number of all candidate diagnostic information, candidate diagnostic and treatment procedures, and candidate drugs, respectively. This represents the predicted probability of the i-th drug; For depth model functions;
[0014] Recommendation boundary Define the boundary area at the center ,in The width of the boundary region;
[0015] Based on drug probability distribution Collection of all candidate drugs Divide into two disjoint subsets:
[0016] Boundary drug subset and its corresponding prediction probability set ;
[0017] Confidence drug subset and its corresponding prediction probability set .
[0018] Furthermore, search historical electronic health records similar to the current medical record, specifically:
[0019] Jaccard similarity is calculated based on the degree of overlap in the diagnostic sets, using the following formula:
[0020]
[0021] in, and Let v represent the current medical record and h represent the sets of diagnoses, respectively; based on Select the first with the highest similarity Each historical medical record serves as a historical electronic health record, similar to the current medical record.
[0022] Furthermore, construct the DDI conflict set. The formula is:
[0023]
[0024] in, For a predefined symmetric binary DDI adjacency matrix, Indicates drug With drugs There is an interaction. This is a subset of boundary drugs.
[0025] Furthermore, the optimized probability of obtaining the boundary drug subset is obtained. The prompt words are processed by a large language model. The formula is:
[0026]
[0027] in, This represents the large language model processing function.
[0028] Furthermore, a final list of recommended drugs is generated. The formula is:
[0029]
[0030] in, As the recommended boundary, The probability of the final fused drug. Let i be the i-th drug.
[0031] Furthermore, the recommended boundary The width of the boundary region is set to 0.5. Set it to 0.2.
[0032] Furthermore, the number of searches, k, is set to 3.
[0033] Furthermore, the large language model is Qwen3-8B, LLaMA3.1-8B-Instruct, or LLaMA3.1-Aloe-Beta-8B.
[0034] The present invention also provides a computer-readable storage medium having stored thereon computer program instructions that can be executed by a processor, wherein when the processor executes the computer program instructions, it can implement the steps of the method described above.
[0035] Compared with the prior art, the present invention has the following beneficial effects:
[0036] (1) Boundary-aware drug recommendation formulation introduces a novel formulation method that activates the reasoning ability of large language model (LLM) "giants" for drugs within boundary regions. By focusing on cases that are ambiguous but have clinical information value, this invention alleviates coarse binary decision-making behavior and can provide more refined, accurate and safe recommendations.
[0037] (2) The deep model-guided LLM framework is a hybrid framework that uses predictions from deep models to guide LLM in identifying boundary drugs. These drugs are further optimized through boundary-aware cues, and combined with retrieved electronic health records (EHRs) and integrated drug interaction (DDI) constraints, effectively integrating the advantages of deep models and LLM in drug recommendation. Attached Figure Description
[0038] Figure 1 This contrasts the coarse binary decision-making of traditional Large Language Models (LLM) with the fine-grained probability distribution of deep models. Figure 1 In the middle (a), the probability distribution of drugs visited by patients is derived from Qwen3-8B (LLM) and SafeDrug (deep model). Figure 1 (b) shows a comparison of different methods under MIMIC-III using the average number of recommended drugs (bars) and Jaccard similarity (linear).
[0039] Figure 2 This forms the overall framework of the present invention.
[0040] Figure 3 Optimize prompts for medication boundaries based on patient medical records.
[0041] Figure 4 To test the width of different boundary regions of this invention on the MIMIC-III dataset. Experimental results for hyperparameters (%).
[0042] Figure 5 The results (%) of the hyperparameter experiments of this invention on the MIMIC-III dataset under different numbers of top k similar electronic health records retrieved are shown.
[0043] Figure 6 As a case study based on MIMIC-III, the drug probability distribution of the present invention was compared with that of the deep model through kernel density estimation. The present invention further optimizes the prediction results of boundary drugs by activating the reasoning potential of the large language model.
[0044] Figure 7 The expected calibration error (ECE) (%) for boundary drug prediction on the MIMIC-III dataset is shown. Dark bars represent the present invention, and light bars represent the corresponding baseline method. The lower the ECE, the better the calibration effect and reliability. Detailed Implementation
[0045] The technical solution of the present invention will now be described in detail with reference to the accompanying drawings.
[0046] This invention provides a boundary-aware drug recommendation method based on the collaboration of deep models and large language models, comprising:
[0047] The trained deep drug recommendation model is used to process the patient's current medical records to obtain the predicted probability distribution of all candidate drugs, and the candidate drugs are divided into a boundary drug subset and a confidence drug subset based on this probability distribution.
[0048] Retrieve historical electronic health records similar to the current medical record, and construct a set of DDI conflicts related to the boundary drug subset based on predefined drug interaction (DDI) constraints to form enhanced contextual information;
[0049] The current medical record, the boundary drug subset and its predicted probability, and enhanced contextual information are synthesized into the prompt words, input into the large language model, obtain the optimized probability of the boundary drug subset, and fuse the optimized probability with the probability of the confidence drug subset to generate the final drug recommendation list.
[0050] The following is a detailed implementation process of the present invention.
[0051] This invention provides a boundary-aware drug recommendation method based on the collaboration of deep learning models and large language models. This invention is a boundary-aware drug recommendation framework that activates the potential of the "giant" large language model through deep learning model guidance. Instead of relying on large language models for broad and unguided predictions, this invention strategically directs their attention towards drugs that are ambiguous but clinically important near the decision boundary. Figure 1 As shown in (b), variants of the present invention (e.g., the present invention-SD and the present invention-MA), guided by the SafeDrug and MedAlign deep models respectively, improve recommendation accuracy while also mitigating the problem of over-prescribing.
[0052] This invention comprises three core modules. (1) Boundary drug set identification guided by deep models: using a trained deep model (such as SafeDrug) to predict the fine-grained probability of drugs based on the patient's current medical data, dividing all drugs into boundary drug subsets and confidence drug subsets. (2) Boundary drug information enhancement combining historical electronic health record retrieval and drug interaction constraints: retrieving historical electronic health records that are highly similar to the clinical characteristics of the patient's current medical visit, extracting drug interaction constraints corresponding to the boundary drug subsets, thereby supplementing relevant contextual knowledge and providing support for the subsequent fine-grained optimization of boundary drugs by the large language model. (3) Boundary-aware drug recommendation based on the large language model: constructing synthetic boundary-aware prompts, activating the semantic reasoning potential of the large language model (such as Qwen3-8B), enabling it to fine-grainedly correct the predicted probability of boundary drugs, and generating the final drug recommendation scheme. Figure 2 As shown, this invention, through the synergistic operation of the above-mentioned technical solutions, combines the optimized boundary drug probability of the large language model with the deterministic prediction results of the deep model to generate more accurate and safer prescriptions. Figure 2 As shown, the objective of this invention is achieved through the following technical solutions:
[0053] Step one, deep model-guided boundary drug set identification, includes the following sub-steps:
[0054] 1.1 Drug Probability Prediction. The backbone network of the deep drug recommendation model can be viewed as a trained multi-label classifier. Given a patient's medical records Drug probability distribution The prediction method is as follows:
[0055]
[0056] in, and These are multiple heat vectors representing the diagnostic information and treatment procedure information for this medical visit, respectively. These represent the number of all candidate diagnoses, treatment procedures, and medications, respectively. Specifically, the predicted probability... These medications will be directly included in prescriptions and recommended, among which This is the decision boundary, typically set to 0.5.
[0057] 1.2 Extraction of Boundary Drug Set and Confidence Drug Set. Although large language models possess powerful semantic understanding capabilities, they are often prone to over-prescribing due to their coarse-grained decision control methods and vast candidate drug space. This reduces the accuracy of recommendations and prevents the model's reasoning potential from being fully realized. Inspired by the ability of deep models to capture drugs near the boundary region based on fine-grained prediction probabilities (as shown in Figure 1(a)), the most worthy subset of drugs for fine-grained optimization by large language models is selected with the guidance of deep models.
[0058] Specifically, the first step will be to use the recommendation boundary. The boundary region centered on is defined as in This represents the width of the boundary region. Subsequently, based on the predicted probabilities output by the deep model, all candidate drugs are assembled. Divide into two disjoint subsets:
[0059] Boundary drug set and its corresponding prediction probability set
[0060] Confidence drug set and its corresponding prediction probability set
[0061] It is worth noting that when a certain drug Predicted probability When a drug falls within this boundary area, it is classified as part of the boundary drug set. These types of drugs are difficult to handle accurately due to the limited contextual understanding capabilities of deep models, requiring further semantic reasoning analysis. Therefore, they become ideal candidates for refined optimization of large language models. Finally, the boundary drug set is determined by prompt words. Each drug and its predicted probability are converted into text form (see Figure 2, lower left for relevant prompts).
[0062] Step two, combining historical electronic health record retrieval with boundary drug information enhancement based on drug interaction constraints, includes the following sub-steps:
[0063] 2.1 Clinically Enhanced Electronic Health Record Search. To provide relevant clinical knowledge, the system searches for the most similar electronic health records found during the patient's current visit. An electronic health record. This operation enriches the contextual information available to the large language model, providing more targeted guidance for further refined optimization of boundary drug recommendations. Jaccard similarity is calculated based on the degree of overlap in diagnostic sets to quantify patient medical records. Each historical medical record in the training set The correlation between them is calculated using the following formula:
[0064]
[0065] in and These represent the sets of diagnoses from the current medical visit and those from past medical visits, respectively. Then, based on... Sort all historical medical records and select the records with the highest similarity. The search results serve as a source of enhanced contextual knowledge. Furthermore, similar patient visits (EHRs) retrieved are textualized using simplified prompt templates (as shown in the upper part of Figure 2). Notably, only information overlapping with the patient's current visit (i.e., shared diagnoses, treatments, and borderline medications) is retained, ensuring concise prompts while highlighting relevant contextual knowledge.
[0066] 2.2 Construction of DDI Constraints for Boundary-Oriented Drug Interactions. To ensure the safety of recommended drugs, a predefined symmetric binary drug interaction (DDI) adjacency matrix is used. This further facilitates the construction of DDI constraints for large language models. Indicates drug With drugs There are interactions between them. Given the extracted boundary drug set... Adjacency matrix with DDI Match all potential DDI conflict sets: Finally, the obtained DDI constraints are converted into text form using prompt words (as shown in the lower part of Figure 2).
[0067] Step 3, boundary-aware drug recommendation based on a large language model, includes the following sub-steps:
[0068] 3.1 Boundary Drug Probability Optimization. The following simplified template is used to synthesize drug probabilities for patient visit records. Boundary drug optimization prompts (like Figure 3 (As shown). Then, the large language model processes the prompt word and outputs the optimized boundary drug probability, as shown in the following formula:
[0069]
[0070] The large language model will re-evaluate the output based on the patient's health status and relevant clinical knowledge to ensure that the optimization process is targeted and interpretable.
[0071] 3.2 Drug Recommendation Based on a Large Language Model. The optimized boundary drug probabilities from the large language model are then used... The confidence drug probability output by the deep model (See step one) The mixture is then fused to generate the final recommended drug set, as shown in the following formula:
[0072]
[0073] in The threshold is used for recommendation. By guiding the activation of a large language model through a deep model, this invention effectively and efficiently utilizes its powerful semantic reasoning capabilities to achieve accurate, safe, and boundary-aware drug recommendations.
[0074] Furthermore, to evaluate the performance of the method described in this invention on the drug recommendation task, two real-world electronic health record (EHR) datasets, MIMIC-III and MIMIC-IV, were used. Before use, both datasets underwent complete anonymization and rigorous cleaning. Patients with at least two medical visits were selected, and the target labels were the three-level codes of the International Standard Drug Classification (ATC) system established by the World Health Organization. The MIMIC-III dataset contains 6350 patients, 15031 medical records, 1903 diagnoses, 1409 surgeries, and 131 drugs. The MIMIC-IV dataset contains 61264 patients, 163877 medical records, 2000 diagnoses, 11056 surgeries, and 131 drugs. The training, validation, and test sets were divided into 2 / 3, 1 / 6, and 1 / 6 ratios, respectively, for the same experiments.
[0075] This invention uses similarity score (Jaccard), average F1 score (F1), area under the precision-recall curve (PRAUC), drug interaction rate (DDI), and average number of medications used (#Med.) to evaluate the fit between the model and real-world prescriptions.
[0076] This invention uses Qwen3-8B as the backbone large language model by default. The maximum input length of the large language model is set to 4096, and the temperature coefficient is fixed at 0.7. This invention defines the decision boundary... Set to 0.5, boundary area width Set to 0.2. For each patient's each visit, retrieve the top results with the highest similarity. One electronic health record ( To enrich the contextual information in the prompts, all models were evaluated using 5-fold cross-validation, and the mean and standard deviation of the test results were reported. All experiments were performed on two NVIDIA RTX 3090 Ti GPUs. For methods based on Large Language Models (LLM), their pre-trained weights were loaded from HuggingFace. Notably, the PRAUC of LLM-based methods is denoted as "-", as they only output binary decision results and do not provide probability scores, thus making precision-recall evaluation impossible. For instance- and temporal modeling-based methods, the baseline models were optimized using the standard Adam optimizer, and their hyperparameters were carefully tuned strictly according to the original paper's recommendations, with the embedding dimension set to 64 and the batch size set to 32.
[0077] To comprehensively evaluate the effectiveness of this invention, 14 representative state-of-the-art methods were selected as baseline models, which were divided into three categories: (1) Methods based on large language models: general large language models and domain-adaptive large language models were compared, including Qwen3-8B, LLaMA3.1-8B-Instruct (abbreviated as LLaMA3.1) and LLaMA3.1-Aloe-Beta-8B (abbreviated as Aloe-Beta). (2) Instance-based methods: logistic regression (LR) and classifier ensemble (ECC) were selected as comparison methods. (3) Temporal modeling methods: RETAIN, LEAP, GAMENet, MICRON, VITA, SafeDrug, MoleRec, DEPOT and MedAlign were selected as comparison methods.
[0078] Table 1 shows the Jaccard, F1 score, PRAUC, drug interaction (DDI) rate, and average number of medications on the MIMIC-III and MIMIC-IV datasets. The actual average number of treatments in the test sets of the two datasets are 19.7937 and 11.9788, respectively. Overall, this invention demonstrates superior performance, thanks to combining the fine-grained prediction guidance of deep models with the advanced semantic reasoning capabilities of large language models. As shown in Table 1, this invention consistently outperforms all baseline models: achieving an average improvement of 3.74% in accuracy metrics and an average reduction of 4.10% in the incidence of drug interactions (DDIs). By focusing on optimizing for clinically ambiguous but information-rich boundary drugs, this invention effectively achieves a balance between prediction accuracy and medication safety.
[0079] Table 1: Experimental results on the MIMIC-III and MIMIC-IV datasets
[0080]
[0081] (Best performance is indicated in bold, and second-best performance is indicated by underline.)
[0082] Compared to methods based on large language models, which often exhibit coarse binary decision-making behavior (such as Qwen3-8B and Aloe-Beta), resulting in low accuracy and frequent overprescription, this invention demonstrates superior performance. For example, Qwen3-8B recommended an average of over 35 medications per patient in MIMIC-III, nearly double the actual number of medications used (19.79), while also achieving a drug dispensing rate (DDI) of 8.67%. In contrast, this invention utilizes deep model guidance to direct LLMs to focus on clinically ambiguous boundary medications, providing fine-grained probabilities and improving performance by up to 187.32% in both accuracy and safety metrics.
[0083] Compared to instance-based methods, instance-based models (such as logistic regression (LR) and classifier ensembles (ECC)) rely solely on static features from a single visit, making it difficult to capture temporal and contextual dependencies. This often results in a limited number of recommended drugs (e.g., in the MIMIC-III dataset, LR only recommended 16.27 drugs), leading to lower overall accuracy. In contrast, this invention achieves a better balance between recommendation coverage and accuracy.
[0084] Compared with temporal modeling methods, while temporal models such as SafeDrug and MedAlign utilize sequence information to model patient medical history, they still have shortcomings in handling the contextual reasoning required for complex clinical scenarios, especially for drugs near the decision boundary. Compared to these deep models, this invention combines their precise predictive control capabilities with the semantic reasoning capabilities of a large language model. This hybrid strategy enables the invention to achieve superior performance in both accuracy and safety across all evaluation settings. Furthermore, several variants of this invention are guided by different deep models: Invention-SD, Invention-MR, Invention-DP, and Invention-MA are guided by SafeDrug, MoleRec, DEPOT, and MedAlign, respectively. Direct comparison of these variants with their corresponding deep model baselines reveals stable and significant performance improvements: compared to SafeDrug, Jaccard similarity is improved by up to 11.87%; compared to MedAlign, Jaccard similarity is improved by 5.06%. These results validate the effectiveness of the boundary-aware large model activation mechanism guided by a deep model proposed in this paper. It is worth noting that this invention focuses on using fine-grained probability output to identify clinically ambiguous drugs, rather than relying on a specific deep model. This allows for flexible integration of various models and strong adaptability in diverse clinical scenarios.
[0085] To evaluate the generalization ability of this invention across different backbone large language models, a fixed underlying deep model was used, and three representative large models were employed for performance comparison: the general large model Qwen3-8B, LLaMA3.1, and the domain-adaptive model Aloe-Beta. Table 2 shows the results of these large models under the guidance of SafeDrug, MoleRec, DEPOT, and MedAlign. Under the guidance of SafeDrug and MedAlign, the performance of different backbone LLMs varied, with Qwen3-8B consistently achieving the best results across all metrics. For example, under MedAlign guidance, Qwen3-8B's PRAUC metric showed a maximum improvement of 3.82% compared to Aloe Beta, demonstrating its superior reasoning and instruction compliance capabilities. This makes it highly suitable for complex clinical decision-making scenarios, especially in boundary drug optimization tasks. Furthermore, the consistent improvement trend observed across different LLMs demonstrates the good flexibility and generalization of this invention.
[0086] Table 2: Ablation experiment results of this invention using different backbone large language models on the MIMIC-III dataset (%)
[0087]
[0088] To evaluate the impact of two key hyperparameters on model performance, namely the width of the boundary region... Most similar Search for the number of electronic health records. Figure 4 Showing different The effect of the selected value on the similarity (Jaccard) and drug interaction rate (DDI) of the present invention-SD and present invention-MA. When When the value is increased from 0.1 to 0.5, the model performance first increases and then decreases, with both variants showing improvement. The peak Jaccard score is achieved at 0.2. Smaller values result in lower Jaccard scores. A value of 0.1 (e.g., 0.1) would result in the deep model identifying too few boundary drugs, limiting the semantic reasoning capabilities of the large language model. Conversely, an excessively large value... Setting it to 0.5 would excessively expand the boundary area and include many less ambiguous drugs, thus weakening the optimized focusing effect. =0.2, to achieve a balance between the optimization area and accuracy. For example... Figure 5 As shown, the overall model performance varies with The increase in size leads to improvements; both the present invention-SD and the present invention-MA are in... It reaches its optimal state at that time. When the size is too small, large language models lack sufficient contextual information; If the value is too large, it may introduce irrelevant or redundant information, leading to a slight performance decrease. Therefore, the default value should be set to... This allows the large language model to obtain sufficient clinical context.
[0089] To investigate the impact of different boundary drug enhancement strategies in this invention, including retrieval-based clinical enhancement based on similar electronic health records (EHRs) and fusion of drug interaction (DDI) constraints, four strategies were tested: diagnostic overlap only, treatment overlap only, diagnosis + operation overlap, and no retrieval. As shown in Table 3, in all variants of this invention, all retrieval-based strategies significantly outperformed no retrieval, demonstrating that external clinical context is crucial for effective optimization of large language models. Retrieval based solely on diagnostic overlap achieved the best results across all accuracy metrics and various deep model variants. For example, this invention-MA achieved the highest Jaccard score of 56.63% under this strategy. Conversely, adding treatment information alone or in combination led to performance degradation, possibly due to increased variability in operation encoding and less stable clinical similarity signals. The significant performance degradation observed in the no-retrieval setting further indicates that large language models struggle to effectively optimize boundary drugs without contextual support. Therefore, diagnostic-based retrieval was adopted as the default strategy for clinical enhancement.
[0090] Table 3: Ablation experimental results of this invention using different retrieval strategies on the MIMIC-III dataset (%)
[0091]
[0092] To evaluate the role of explicit DDI-constrained pharmacological knowledge, the performance of this invention was compared with and without DDI constraints. As shown in Table 4, the drug interaction (DDI) rate of all variants of this invention consistently decreased after incorporating DDI constraints. For example, in this invention-MA, the DDI rate decreased from 7.41% to 7.19%, demonstrating improved medication safety. Furthermore, the accuracy was slightly higher without DDI constraints, which is expected, as real-world prescriptions inherently contain non-negligible drug interactions (e.g., 8.15% in the MIMIC III dataset), reflecting a good trade-off between safety and accuracy. By explicitly injecting drug interaction (DDI) knowledge, the large language model is guided to maintain competitive recommendation performance while avoiding potentially harmful drug combinations. These results confirm that DDI constraint fusion is a key module for generating clinically safe and reliable medication recommendations.
[0093] Table 4: Ablation experimental results of this invention with and without DDI constraints on the MIMIC-III dataset (%)
[0094]
[0095] To evaluate the computational efficiency of this invention, the average inference time was measured on the MIMIC-III test set, as shown in Table 5. While introducing a large language model (LLM) naturally incurs additional computational overhead compared to traditional deep models, this invention maintains a practical balance between model performance and efficiency. Compared to pure LLM methods with high inference costs (such as Qwen3-8B requiring 284.26 seconds), this invention enables the LLM for only a small number of boundary drugs, achieving an inference speed improvement of over 20 times. Although this invention is slightly slower than some deep models (such as SafeDrug), it significantly improves accuracy and safety, while enhancing interpretability through the advanced semantic reasoning capabilities of the LLM. Notably, all variants of this invention outperform their corresponding base deep models with only a slight increase in runtime, demonstrating its clinical applicability.
[0096] Table 5: Comparison of different methods and average inference time on the MIMIC-III dataset
[0097]
[0098] To quantify the difference between the model's prediction confidence and the actual accuracy, the expected calibration error (ECE) is introduced. The formula for calculating this metric is as follows: ,in Indicates the quantity of drugs at the boundary. Figure 7 This invention demonstrates that it can reduce ECE by up to 50.27%, exhibiting superior boundary correction and higher reliability.
[0099] To qualitatively explain how this invention activates a large language model to optimize medication recommendations, in Figure 6The following two case studies from the MIMIC III test set are presented. From a probability distribution perspective, baseline deep models such as SafeDrug and MedAlign (grey curves) typically concentrate probability density near the decision boundary (e.g., around 0.5), indicating decision ambiguity in drug selection. In contrast, the present invention (cyan curves) redistributes these probabilities to high-confidence regions (close to 0 or 1), thereby reducing clinical ambiguity and improving the accuracy of the final recommendation. At the instance level, these case studies demonstrate how the present invention optimizes prediction results through fine-grained clinical reasoning. In Figure 6(a), the model identifies that although the patient has cardiovascular disease, sodium nitroprusside is only suitable for hypertensive emergencies, thus reducing its recommendation probability from 0.53 to 0.10. Furthermore, in Figure 6(b), the model, by referencing similar electronic health records (EHRs) showing that the drug had been effectively used to treat methicillin-resistant Staphylococcus aureus (MRSA) infections, increased the probability of piperacillin / tazobactam from 0.42 to 0.70, thereby achieving context-based, high-confidence rational drug use adjustments. These examples demonstrate that the present invention can combine pharmacological knowledge with enhanced clinical context to optimize ambiguous boundary drugs and effectively activate the reasoning ability of large language models to make more accurate and interpretable decisions.
[0100] This invention presents a novel large language model framework guided by a deep model for boundary-aware drug recommendation. First, fine-grained probabilities from the output of a trained deep model are used to identify boundary-aware drugs. Then, boundary-aware cues incorporating retrieved historical electronic health records (EHRs) and drug interaction (DDI) constraints are used to optimize the prediction results for these drugs. Experimental results on the MIMIC III and MIMIC IV datasets demonstrate that this invention consistently outperforms the current state-of-the-art baseline model in both accuracy and safety. Further analysis validates the flexibility and efficiency of this framework, demonstrating its practical value in real-world clinical scenarios.
[0101] The present invention also provides a computer-readable storage medium having stored thereon computer program instructions that can be executed by a processor, wherein when the processor executes the computer program instructions, it can implement the steps of the method described above.
[0102] The above are preferred embodiments of the present invention. Any changes made to the technical solution of the present invention that do not exceed the scope of the technical solution of the present invention shall fall within the protection scope of the present invention.
Claims
1. A boundary-aware drug recommendation method based on the collaboration of deep models and large language models, characterized in that, include: The trained deep drug recommendation model is used to process the patient's current medical records to obtain the predicted probability distribution of all candidate drugs, and the candidate drugs are divided into a boundary drug subset and a confidence drug subset based on this probability distribution. Retrieve historical electronic health records similar to the current medical record, and construct a set of DDI conflicts related to the boundary drug subset based on predefined drug interaction (DDI) constraints to form enhanced contextual information; The current medical record, the boundary drug subset and its predicted probability, and the enhanced context information are synthesized into the prompt words, input into the large language model, obtain the optimized probability of the boundary drug subset, and fuse the optimized probability with the probability of the confidence drug subset to generate the final drug recommendation list. The process of obtaining the predicted probability distribution of all candidate drugs and dividing them into drug subsets includes: Using a deep drug recommendation model to analyze the patient's current medical records The drug probability distribution is obtained through processing. The formula is: in, and These are multiple heat vectors representing current medical diagnosis information and medical procedure information, respectively. These represent the number of all candidate diagnostic information, candidate diagnostic and treatment procedures, and candidate drugs, respectively. This represents the predicted probability of the i-th drug; For depth model functions; Recommendation boundary Define the boundary area at the center ,in The width of the boundary region; Based on drug probability distribution Collection of all candidate drugs Divide into two disjoint subsets: Boundary drug subset and its corresponding prediction probability set ; Confidence Drug Subset and its corresponding prediction probability set .
2. The boundary-aware drug recommendation method based on the collaboration of deep models and large language models according to claim 1, characterized in that, To retrieve historical electronic health records similar to the current medical record, specifically: Jaccard similarity is calculated based on the degree of overlap in the diagnostic sets, using the following formula: in, and Let v represent the current medical record and h represent the sets of diagnoses, respectively; based on Select the first with the highest similarity Each historical medical record serves as a historical electronic health record, similar to the current medical record.
3. The boundary-aware drug recommendation method based on the collaboration of deep models and large language models according to claim 1, characterized in that, Constructing a DDI conflict set The formula is: in, For a predefined symmetric binary DDI adjacency matrix, Indicates drug With drugs There is an interaction. This is a subset of boundary drugs.
4. The boundary-aware drug recommendation method based on the collaboration of deep models and large language models according to claim 1, characterized in that, Optimized probability of obtaining the boundary drug subset The prompt words are processed by a large language model. The formula is: in, This represents the large language model processing function.
5. The boundary-aware drug recommendation method based on the collaboration of deep models and large language models according to claim 1, characterized in that, Generate the final drug recommendation list. The formula is: in, As the recommended boundary, The probability of the final fused drug. Let i be the i-th drug.
6. The boundary-aware drug recommendation method based on the collaboration of deep models and large language models according to claim 1, characterized in that, The recommended boundary The width of the boundary region is set to 0.
5. Set it to 0.
2.
7. The boundary-aware drug recommendation method based on the collaboration of deep models and large language models according to claim 2, characterized in that, The number of searches, k, is set to 3.
8. The boundary-aware drug recommendation method based on the collaboration of deep models and large language models according to claim 1, characterized in that, The large language model is Qwen3-8B, LLaMA3.1-8B-Instruct, or LLaMA3.1-Aloe-Beta-8B.
9. A computer-readable storage medium, characterized in that, It stores computer program instructions that can be executed by a processor, and when the processor executes the computer program instructions, it can implement the steps of the method as described in any one of claims 1-8.