A method and system for recommending traditional Chinese medicine prescriptions based on a large language model

By using technical means such as feature vector transformation, interactive fusion and deep coding in the traditional Chinese medicine prescription recommendation system, the problems of uncontrollable and non-personalized recommendations in the existing system are solved, and more efficient and personalized traditional Chinese medicine prescription recommendations are achieved, improving the accuracy and standardization of recommendations.

CN119763764APending Publication Date: 2025-04-04HANGZHOU LICORICE TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411818883.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-11
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

The existing Chinese medicine prescription recommendation system based on large language models is uncontrollable when generating text and cannot provide personalized Chinese medicine recommendations, which makes it difficult to guarantee the accuracy and standardization of the results, and the service scenario is single, making it difficult to meet the individual needs of patients.

Method used

By collecting patient text information and recommended drug tags, converting them into prompt word features and feature vectors, using the cross attention mechanism layer for interactive fusion, the self-attention mechanism layer and the feedforward neural network layer for deep encoding, generating model features, and mapping them into soft prompt feature vectors through the soft prompt projection layer, and finally input the model features into the large language model for training and prediction.

Benefits of technology

It has achieved a more controllable and personalized recommendation of traditional Chinese medicine prescriptions, improved the accuracy and standardization of the recommendation results, met the individual needs of patients, reduced the workload of doctors' manual analysis, shortened the time from diagnosis to prescription, and realized personalized medical care.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119763764A_ABST
    Figure CN119763764A_ABST
Patent Text Reader

Abstract

The invention provides a method and system for recommending Chinese medicine prescriptions based on a large language model, and relates to the technical field of intelligent recommendation. The method comprises: collecting patient text information and recommended drug labels; converting the patient text information into prompt word features and feature vectors respectively; interactively fusing the feature vectors through a cross-attention mechanism layer to generate a fused feature vector; splicing each fused feature vector to obtain a total feature vector; encoding the total feature vector through a self-attention mechanism layer and a feedforward neural network layer to generate an output vector; mapping the output vector to a soft prompt feature vector; splicing and fusing the soft prompt feature vector and the prompt word feature to generate a model feature; inputting the model feature into a large language model, and outputting a predicted recommended drug, until a binary cross entropy loss function value is less than a preset value; obtaining the patient text information to be detected; inputting the patient text information to be detected into the trained large language model, and outputting a predicted recommended drug.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of intelligent recommendation technology, and in particular to a method and system for recommending traditional Chinese medicine prescriptions based on a large language model. Background Art

[0002] The big language model is a large-scale natural language processing model based on deep learning technology. It can understand, generate and process natural language text. The Chinese medicine prescription recommendation method based on the big language model combines the powerful text processing capabilities of the big language model with close integration with traditional Chinese medicine theory, converts the patient's multi-dimensional information into feature vectors, and finally realizes intelligent Chinese medicine prescription recommendation after training with a deep learning model.

[0003] Combining a large language model to process patients' complex text information and automatically generate recommended prescriptions is of great significance for reducing the workload of doctors' manual analysis, shortening the time from diagnosis to prescription, realizing personalized medicine, promoting the modernization and intelligence of traditional Chinese medicine, and improving the quality and safety of diagnosis and treatment. It makes an important contribution to building a smart medical ecosystem.

[0004] However, traditional recommendation system algorithms, such as collaborative filtering algorithms, text mining algorithms, and algorithms based on deep learning, require strict structured data as input to the model during complex data preprocessing, resulting in poor versatility and difficulty in promotion. As for algorithms for large language models, there are also studies focusing on large models in the vertical field of traditional Chinese medicine, but these models all serve free medical question-and-answer scenarios, the generated text is uncontrollable, and personalized recommendations for traditional Chinese medicine cannot be generated, making it difficult to ensure the accuracy and standardization of the results. The service scenarios are single and it is difficult to meet the individual needs of patients. Summary of the invention

[0005] In order to solve the technical problems that the algorithms based on large language models in the prior art all serve free medical question-and-answer scenarios, the generated texts are uncontrollable, and personalized Chinese medicine recommendations cannot be generated, which makes it difficult to ensure the accuracy and standardization of the results, the service scenarios are single, and it is difficult to meet the individual needs of patients, the present invention provides a Chinese medicine prescription recommendation method and system based on a large language model.

[0006] The technical solution provided by the embodiment of the present invention is as follows:

[0007] First aspect

[0008] An embodiment of the present invention provides a method for recommending Chinese medicine prescriptions based on a large language model, comprising:

[0009] S1: Collect multiple patient text information and recommended drug labels for each patient text information;

[0010] S2: Convert patient text information into prompt word features and feature vectors respectively;

[0011] S3: Interactively fuse the feature vectors through the cross-attention mechanism layer to generate a fused feature vector;

[0012] S4: horizontally concatenate each fused feature vector to obtain the total feature vector;

[0013] S5: The total feature vector is deeply encoded through the self-attention mechanism layer and the feed-forward neural network layer to generate the output vector;

[0014] S6: The output vector is mapped into multiple soft hint feature vectors consistent with the number of layers of the large language model through the soft hint projection layer;

[0015] S7: concatenate and fuse the soft prompt feature vector and the prompt word feature to generate model features corresponding to the text information of each patient;

[0016] S8: Input each model feature into the large language model respectively, output the predicted recommended drugs corresponding to each model feature respectively, and calculate the binary cross entropy loss function value of the predicted recommended drugs until the binary cross entropy loss function value is less than the preset binary cross entropy loss function value, thereby completing the training of the large language model;

[0017] S9: Obtain text information of the patient to be tested;

[0018] S10: Input the text information of the patient to be tested into the trained large language model, and output the predicted recommended drugs.

[0019] Second aspect

[0020] The embodiment of the present invention provides a Chinese medicine prescription recommendation system based on a large language model, comprising:

[0021] processor;

[0022] A memory having computer-readable instructions stored therein, which, when executed by a processor, implements the method for recommending Chinese medicine prescriptions based on a large language model as described in the first aspect.

[0023] The third aspect

[0024] An embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the method for recommending traditional Chinese medicine prescriptions based on a large language model as described in the first aspect is implemented.

[0025] The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:

[0026] In the present invention, by collecting patient information and corresponding recommended drug labels, and converting patient text information into prompt word features and feature vectors respectively, the feature vectors are then interactively fused, and the generated fused feature vectors are horizontally spliced ​​to obtain a total feature vector, and the total feature vector is further deeply encoded through a self-attention mechanism layer and a feedforward neural network layer, and then mapped to a soft prompt feature vector through a soft prompt projection layer, and the soft prompt feature vector and the prompt word feature are spliced ​​and fused again to generate model features, and the model features are input into a large language model, and the predicted recommended drugs are output until the binary cross entropy loss function value is less than the preset binary cross entropy loss function value, and the training process of the large language model is terminated. Finally, the actual patient information is obtained and input into the trained model, and the predicted recommended drugs are output, so that the model output is more controllable, the patient's own situation is better integrated, and personalized traditional Chinese medicine recommendations are achieved, so that the recommended traditional Chinese medicine prescription results are controllable and clear, meet the individualized needs of patients, improve the accuracy and standardization of recommendation results, reduce the workload of doctors' manual analysis, shorten the time from diagnosis to prescription, and realize personalized medicine. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0028] Figure 1 A schematic diagram of a flow chart of a method for recommending Chinese medicine prescriptions based on a large language model provided by an embodiment of the present invention;

[0029] Figure 2 A schematic diagram of the structure of a Chinese medicine prescription recommendation system based on a large language model provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0030] The technical solution of the present invention is described below in conjunction with the accompanying drawings.

[0031] In the embodiments of the present invention, words such as "exemplarily" and "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "example" in the present invention should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of the word "example" is intended to present the concept in a specific way. In addition, in the embodiments of the present invention, the meaning expressed by "and / or" can be both, or it can be either of the two.

[0032] In order to make the technical problems, technical solutions and advantages to be solved by the present invention more clear, a detailed description will be given below with reference to the accompanying drawings and specific embodiments.

[0033] Reference Manual Attached Figure 1 , showing a flow chart of a method for recommending traditional Chinese medicine prescriptions based on a large language model provided in an embodiment of the present invention.

[0034] The embodiment of the present invention provides a method for recommending Chinese medicine prescriptions based on a large language model, which can be implemented by a Chinese medicine prescription recommendation device based on a large language model, and the Chinese medicine prescription recommendation device based on a large language model can be a terminal or a server. The processing flow of the method for recommending Chinese medicine prescriptions based on a large language model can include the following steps:

[0035] S1: Collect multiple patient text information and recommended drug labels for each patient text information.

[0036] Among them, patient text information refers to the patient's condition description and related medical records, usually including symptoms, syndromes, diagnosis information, and the patient's basic information (such as age, gender, medical history, etc.). Recommended drug labels refer to traditional Chinese medicine prescriptions or drug lists that match the patient's condition, usually provided by doctors as the target output of model training.

[0037] It should be noted that by systematically collecting patients' multi-dimensional text information and corresponding recommended drug labels, a comprehensive training dataset was constructed, which can comprehensively cover the diverse characteristics of TCM diagnosis and treatment, and provide real-scene data support for subsequent model learning.

[0038] In a possible implementation, the patient text information specifically includes: a text description of symptoms, a text description of syndromes, a text description of diagnosis, and a text description of basic conditions.

[0039] Among them, symptom text description refers to the textual information describing the patient's subjective discomfort or disease manifestations; syndrome text description refers to the description of the comprehensive manifestations of the disease under the theory of TCM syndrome differentiation, including the summary results of symptoms, signs and etiology and pathogenesis; diagnosis text description refers to the clear diagnosis information given by the doctor based on the patient's condition and treatment results; basic situation text description refers to the record of the patient's basic background information, including physiological and medical history characteristics.

[0040] S2: Convert the patient text information into prompt word features and feature vectors respectively.

[0041] Among them, the prompt word feature refers to the key words or phrases extracted from the patient's text information, which are used to construct prompt information that is instructive to the model. The feature vector refers to the patient's text information represented by a mathematical method as a numerical multidimensional vector, which is used to input the model for calculation and analysis.

[0042] Specifically, the prompt word feature is a task instruction, such as "the patient's basic condition is..., the symptoms are..., the syndrome is..., the final diagnosis is..., please give a recommended Chinese medicine prescription."

[0043] It should be noted that by converting the patient's text information into prompt word features and feature vectors, the conversion of unstructured data to structured data is effectively realized, the semantics of the text information is retained, and it can be efficiently processed by the machine learning model. This feature representation method can extract key content, reduce the interference of irrelevant redundant information, and improve the model's ability to understand input data.

[0044] In a possible implementation, the feature vector is specifically:

[0045] X 症状 =W 症状 ·A 症状 +b 症状

[0046] X 证候 =W 证候 ·A 证候 +b 证候

[0047] X 诊断 =W 诊断 ·A 诊断 +b 诊断

[0048] X 基本情况 =W 基本情况 ·A 基本情况 +b 基本情况

[0049] Among them, X 症状 represents the symptom feature vector, W 症状 represents the symptom embedding weight matrix, A 症状 represents the one-hot encoding matrix of the symptom input sequence, b 症状 represents the symptom bias vector, X 证候 represents the syndrome feature vector, W 证候 represents the syndrome embedding weight matrix, A 证候 represents the one-hot encoding matrix of the syndrome input sequence, b 证候 represents the syndrome bias vector, X 诊断 represents the diagnostic feature vector, W 诊断 represents the diagnosis embedding weight matrix, A 诊断 represents the one-hot encoding matrix of the diagnostic input sequence, b 诊断 represents the diagnostic bias vector, X 基本情况 represents the base case eigenvector, W 基本情况 represents the base case embedding weight matrix, A基本情况 represents the one-hot encoding matrix of the base case input sequence, b 基本情况 Represents the base case bias vector.

[0050] It should be noted that through feature vectorization, the representation of data is consistent and scalable, providing a strong foundation for subsequent model learning and reasoning.

[0051] S3: The feature vectors are interactively fused through the cross-attention mechanism layer to generate a fused feature vector.

[0052] Among them, the cross-attention mechanism layer is an attention mechanism used in the model, which can analyze and emphasize the relationship and importance between features from different sources, usually involving the interactive processing of queries, keys, and values. The fused feature vector refers to the new feature vector after fusion processing through the attention mechanism. It combines the information of multiple input feature vectors to generate a comprehensive representation.

[0053] It should be noted that the cross-attention mechanism layer used allows the model to effectively integrate data features from different sources, such as symptoms, syndromes, diagnostic information, etc. The advantage of this method is that it can automatically identify and emphasize the interrelationships and key information between different features in the complex TCM diagnosis and treatment process.

[0054] In a possible implementation, S3 specifically includes:

[0055] S301: Linear projection and layer normalization processing of feature vectors:

[0056] Q 症状 ,K 症状 ,V 症状 =LP(Norm(X 症状 ))

[0057] Q 证候 ,K 证候 ,V 证候 =LP(Norm(X 证候 ))

[0058] Q 诊断 ,K 诊断 ,V 诊断 =LP(Norm(X 诊断 ))

[0059] Q 基本情况 ,K 基本情况 ,V 基本情况 =LP(Norm(X 基本情况 ))

[0060] Among them, Q症状 represents the symptom query vector, K 症状 represents the symptom key vector, V 症状 represents the symptom value vector, LP represents the linear projection operation, Norm represents the layer normalization operation, Q 证候 represents the syndrome query vector, K 证候 represents the syndrome key vector, V 证候 represents the syndrome value vector, Q 诊断 represents the diagnostic query vector, K 诊断 represents the diagnostic key vector, V 诊断 represents the diagnostic value vector, Q 基本情况 represents the basic query vector, K 基本情况 represents the base case key vector, V 基本情况 Represents a vector of base case values.

[0061] S302: Interactively fuse the processed feature vectors through the cross attention mechanism layer to generate a fused feature vector:

[0062] O 症状 =Atention(Q 症状 ,K 症状 ,V 症状 )+λ 证候 Atention(Q 症状 ,K 证候 ,V 证候 )+

[0063] λ 诊断 Atention(Q 症状 ,K 诊断 ,V 诊断 )+λ 基本情况 Atention(Q 症状 ,K 基本情况 ,V 基本情况 )

[0064] O 证候 =Atention(Q 证候 ,K 证候 ,V 证候 )+λ 症状 Atention(Q 证候 ,K 症状 ,V 症状 )+

[0065] λ 诊断 Atention(Q 证候 ,K 诊断 ,V 诊断 )+λ 基本情况 Atention(Q 证候 ,K 基本情况,V 基本情况 )

[0066] O 诊断 =Atention(Q 诊断 ,K 诊断 ,V 诊断 )+λ 症状 Atention(Q 诊断 ,K 症状 ,V 症状 )+

[0067] λ 证候 Atention(Q 诊断 ,K 证候 ,V 证候 )+λ 基本情况 Atention(Q 诊断 ,K 基本情况 ,V 基本情况 )

[0068] O 基本情况 =Atention(Q 基本情况 ,K 基本情况 ,V 基本情况 )+λ 症状 Atention(Q 基本情况 ,K 症状 ,V 症状 )+

[0069] λ 证候 Atention(Q 基本情况 ,K 证候 ,V 证候 )+λ 诊断 Atention(Q 基本情况 ,K 诊断 ,V 诊断 )

[0070] Among them, O 症状 represents the symptom fusion feature vector, O 证候 represents the syndrome fusion feature vector, O 诊断 represents the diagnostic fusion feature vector, O 基本情况 represents the basic situation fusion feature vector, Atention represents the attention operation, λ 症状 represents the weighting coefficient of the symptom, λ 证候 represents the weighting coefficient of syndrome, λ 诊断 represents the weighting coefficient of diagnosis, λ 基本情况 Represents the weighting coefficient of the base case.

[0071] It should be noted that through this mechanism, the model can not only capture the decisive feature combination more accurately, but also provide deeper personalized suggestions in the prediction and recommendation process. In addition, the cross-attention layer improves the interpretability of the model, allowing doctors and researchers to better understand the decision-making basis of the model, thereby increasing the reliability and trust of the model in practical applications.

[0072] S4: Horizontally concatenate each fused feature vector to obtain the total feature vector.

[0073] Among them, the total feature vector is a comprehensive feature vector formed by horizontally splicing fused feature vectors from multiple different sources. It contains information from all relevant data sources. The total feature vector is obtained by horizontally splicing each fused feature vector. This processing method effectively integrates data from different health indicators and medical information sources, providing a comprehensive data perspective for the model. This integrated feature representation enhances the model's ability to process complex and multidimensional data, enabling the model to use richer and more detailed information when making predictions and analyses.

[0074] S5: The total feature vector is deeply encoded through the self-attention mechanism layer and the feedforward neural network layer to generate the output vector.

[0075] Among them, the self-attention mechanism layer is a deep learning mechanism used to learn the correlation between elements within a single input sequence. The feedforward neural network layer is a standard neural network structure, which is mainly used to further process data after the self-attention mechanism to enhance the learning and expression capabilities of the model. The output vector is the final feature representation generated by the model after a series of processing, which is usually used to make the final decision or prediction.

[0076] It should be noted that by using the self-attention mechanism layer and the feedforward neural network layer to deeply encode the total feature vector, the model's ability to process complex medical data is greatly enhanced. The self-attention mechanism allows the model to adaptively learn the dependencies between features, allowing the model to focus more on the information that is most critical to the final prediction results. This mechanism enables the model to not only capture linear relationships, but also grasp more complex, long-distance dependencies, thereby improving the accuracy of the prediction. At the same time, the feedforward neural network layer can further process this information, increase the model's nonlinear processing capabilities and depth, and enable the model to give more accurate and personalized results when recommending Chinese medicine prescriptions.

[0077] In a possible implementation, the output vector is specifically:

[0078] Output1 = LayerNorm( 总 +Attention(LayerNorm(O总 )))

[0079] Output2=LayerNorm(Output1+FFN(Outputput1))

[0080] Among them, Output1 represents the input vector of the feedforward neural network layer, LayerNorm represents the layer normalization function, and O 总 represents the total feature vector, Attention represents the self-attention mechanism, Output2 represents the output vector, and FFN represents the feedforward neural network layer.

[0081] It should be noted that the deep coding strategy significantly improved the comprehensive performance and application value of the model, making it more effective and reliable in processing complex TCM diagnosis and treatment data.

[0082] S6: The output vector is mapped into multiple soft hint feature vectors consistent with the number of layers of the large language model through the soft hint projection layer.

[0083] Among them, the soft hint projection layer is a layer specially designed to map the output vector of the neural network into a feature vector consistent with the model hierarchy. The soft hint feature vector is a feature vector generated by the soft hint projection layer, which is designed to match the specific hierarchy in the large language model and is used to improve the performance and adaptability of the model on specific tasks.

[0084] It should be noted that by introducing the soft prompt projection layer, the model can convert general output vectors into customized feature vectors for specific tasks (such as Chinese medicine prescription recommendations). These feature vectors are more in line with the hierarchical structure of the large language model. This conversion makes the model more accurate and effective when performing specific tasks, because the soft prompt feature vectors are directly associated with the key nodes predicted by the model, enhancing the model's goal orientation and task-related information processing capabilities.

[0085] In a possible implementation, the soft prompt feature vector is specifically:

[0086] u (l) =W (l) U+b (l)

[0087] Among them, u (l) represents the soft hint feature vector of layer l, W (l) represents the weight matrix of layer l, U represents the output vector, b (l) Represents the bias vector of layer l.

[0088] It should be noted that soft prompts can be adjusted according to different application requirements to adapt to different decision-making scenarios, which improves the flexibility and scalability of the model, thereby improving the treatment effect and patient satisfaction.

[0089] S7: Concatenate and fuse the soft prompt feature vector and the prompt word feature to generate model features corresponding to the text information of each patient.

[0090] Among them, the model features are generated by combining the soft prompt feature vector and the prompt word feature, which are finally input into the large language model to generate predictive recommendations. By splicing and fusing the soft prompt feature vector with the prompt word feature, richer and more multi-dimensional model features are created. These features provide more comprehensive contextual information for the large language model. This comprehensive feature representation method not only improves the model's depth of understanding of the disease, but also enables the model to prescribe the right medicine more accurately, thereby generating Chinese medicine prescriptions that are more in line with the patient's specific needs.

[0091] In a possible implementation, the model features are specifically:

[0092] d (l) =c (l) |‖u (l)

[0093] Among them, d (l) represents the model features of layer l, c (l) represents the prompt word feature of the layer, ‖ represents the concatenation operation, u (l) Represents the soft hint feature vector of the layer.

[0094] It should be noted that by integrating information from multiple dimensions, the model has higher accuracy and reliability when dealing with complex medical decisions, effectively utilizing the powerful processing capabilities of the large language model, enabling it to provide treatment plans that are more in line with the patient's actual situation in practical applications, significantly improving the practicality and effectiveness of the traditional Chinese medicine recommendation system.

[0095] S8: Input each model feature into the large language model respectively, output the predicted recommended drugs corresponding to each model feature respectively, and calculate the binary cross entropy loss function value of the predicted recommended drugs until the binary cross entropy loss function value is less than the preset binary cross entropy loss function value, thereby completing the training of the large language model.

[0096] Among them, the big language model is a deep learning model with powerful natural language processing capabilities. It can generate prediction results through contextual information. The predicted recommended drugs are the traditional Chinese medicine recommendation results that match the patient's condition based on the input model features of the big language model. The binary cross entropy loss function is a loss function used to evaluate the difference between the model prediction value and the true value in the binary classification problem. The preset binary cross entropy loss function value is a predefined threshold used to determine the optimization target of the model. When the training loss function value is lower than this threshold, the training process stops.

[0097] Specifically, in the supervised fine-tuning (SFT) process, the most common loss function is usually the cross-entropy loss function. However, the binary cross-entropy loss function can independently calculate the degree of match between the recommendation probability of each drug and the true label, without forcing only one drug to be predicted each time. It is suitable for multi-label tasks. This probabilistic output is more intuitive, which is convenient for doctors to understand and judge the rationality of the recommendation. In addition, the binary cross-entropy loss function can calculate the loss value for each drug separately, and can adjust the loss weights of different categories by weighting to reduce the impact of unbalanced data on model training. Compared with other loss functions, the binary cross-entropy is sensitive to the gradient changes of the predicted values, which helps to update the model parameters more efficiently, thereby quickly improving the recommendation accuracy.

[0098] It should be noted that the corresponding drug recommendations are generated through the input of model features, and the binary cross entropy loss is calculated to evaluate the model performance. During the continuous optimization of the model, when the loss function value is lower than the preset threshold, the training process is completed, indicating that the model has a high prediction accuracy. This training method ensures that the model can generate accurate Chinese medicine recommendations based on the patient's personalized information, laying the foundation for actual clinical applications.

[0099] In a possible implementation, S8 specifically includes:

[0100] S801: Input each model feature into the large language model respectively.

[0101] S802: Combine the linear layer and the sigmoid function to output the predicted recommended drugs corresponding to each model feature.

[0102] Among them, the linear layer is the basic component unit in the deep learning model, which mainly maps the input features to the new space through linear transformation. The sigmoid function is an activation function that maps the input value to the interval (0,1) and is often used for probability output in binary classification tasks. By combining the linear layer with the sigmoid function, the pre-trained word generation layer is replaced, so that the output result of the model is the probability of each drug, and the output is more controllable.

[0103] S803: Calculate the binary cross entropy loss function value of the predicted recommended drugs and recommended drug labels:

[0104]

[0105] Among them, L bce Represents the binary cross entropy loss function value, y (i) represents the recommended drug label for the ith patient, y (i) represents the predicted recommended drug for the i-th patient, N represents the total number of patients, and log represents the logarithm.

[0106] S804: According to the binary cross entropy loss function value, the loss weight and bias of the large language model are adjusted by the chain rule until the binary cross entropy loss function value of the large language model is less than the preset binary cross entropy loss function value, thereby completing the training of the large language model.

[0107] Among them, the chain rule is a gradient propagation method in deep learning, which is used to calculate the derivative of the loss function with respect to the model parameters. The loss weight is a learnable parameter in the model, which determines the impact of the input features on the output prediction. The bias is a learnable parameter in the model, which is used to adjust the baseline value of the output and provide better flexibility.

[0108] It should be noted that those skilled in the art can set the size of the preset binary cross entropy loss function value according to actual needs, and the present invention is not limited here.

[0109] It should be noted that modifying the SFT (Supervised Fine-Tuning) loss function to a binary cross entropy loss function can better adapt to the multi-label classification requirements of the Chinese medicine recommendation task, provide probabilistic output, handle data imbalance problems, and efficiently optimize the recommendation performance. It not only improves the prediction accuracy and applicability of the model, but also enhances the interpretability and reliability of the recommendation system in actual clinical scenarios.

[0110] S9: Obtain text information of the patient to be tested.

[0111] Among them, the text information of patients to be tested refers to the condition description and related information of new patients that have not yet been analyzed by the model, including symptoms, syndromes, diagnosis and basic conditions. By inputting the text information of patients to be tested into the trained large language model, a rapid conversion from patient data to drug recommendations is achieved. This is because the model has been optimized through training with a large amount of historical data, and can efficiently perform personalized analysis of new patient information and generate accurate Chinese medicine prescription recommendations.

[0112] S10: Input the text information of the patient to be tested into the trained large language model, and output the predicted recommended drugs.

[0113] Among them, the trained large language model refers to a large natural language processing model with the ability to recommend drugs after supervised fine-tuning (SFT) and specific task optimization. The predicted recommended drugs are a list of recommended Chinese medicines generated by the model based on the input patient information, which is used to support doctors' decision-making.

[0114] It should be noted that by using the trained large language model to generate predicted recommended drugs for the tested patients, the accuracy and efficiency of Chinese medicine recommendations have been significantly improved. This process does not require additional model debugging, and efficient personalized drug recommendations can be achieved directly using the trained model. At the same time, the large language model's ability to understand complex natural languages ​​is fully utilized, and the patient's unstructured text input is seamlessly processed, and TCM symptom descriptions, syndrome information, etc. are directly converted into recommendation results. In addition, this method is extremely flexible and versatile, and can be used to assist doctors in decision-making, and provide patients with intelligent preliminary diagnostic support, which is especially important in telemedicine and primary care scenarios.

[0115] The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:

[0116] In the present invention, by collecting patient information and corresponding recommended drug labels, and converting patient text information into prompt word features and feature vectors respectively, the feature vectors are then interactively fused, and the generated fused feature vectors are horizontally spliced ​​to obtain a total feature vector, and the total feature vector is further deeply encoded through a self-attention mechanism layer and a feedforward neural network layer, and then mapped to a soft prompt feature vector through a soft prompt projection layer, and the soft prompt feature vector and the prompt word feature are spliced ​​and fused again to generate model features, and the model features are input into a large language model, and the predicted recommended drugs are output until the binary cross entropy loss function value is less than the preset binary cross entropy loss function value, and the training process of the large language model is terminated. Finally, the actual patient information is obtained and input into the trained model, and the predicted recommended drugs are output, so that the model output is more controllable, the patient's own situation is better integrated, and personalized traditional Chinese medicine recommendations are achieved, so that the recommended traditional Chinese medicine prescription results are controllable and clear, meet the individualized needs of patients, improve the accuracy and standardization of recommendation results, reduce the workload of doctors' manual analysis, shorten the time from diagnosis to prescription, and realize personalized medicine.

[0117] Reference Manual Attached Figure 2 , showing a structural schematic diagram of a traditional Chinese medicine prescription recommendation system based on a large language model provided by the present invention.

[0118] The present invention also provides a Chinese medicine prescription recommendation system 20 based on a large language model, which is applied to the above-mentioned Chinese medicine prescription recommendation method based on a large language model, comprising:

[0119] Processor 201.

[0120] The memory 202 stores computer-readable instructions. When the computer-readable instructions are executed by the processor 201, the method for recommending Chinese medicine prescriptions based on a large language model as in the method embodiment is implemented.

[0121] The Chinese medicine prescription recommendation system 20 based on a large language model provided by the present invention can execute the above-mentioned Chinese medicine prescription recommendation method based on a large language model and achieve the same or similar technical effects. To avoid repetition, the present invention will not go into details.

[0122] The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:

[0123] In the present invention, by collecting patient information and corresponding recommended drug labels, and converting patient text information into prompt word features and feature vectors respectively, the feature vectors are then interactively fused, and the generated fused feature vectors are horizontally spliced ​​to obtain a total feature vector, and the total feature vector is further deeply encoded through a self-attention mechanism layer and a feedforward neural network layer, and then mapped to a soft prompt feature vector through a soft prompt projection layer, and the soft prompt feature vector and the prompt word feature are spliced ​​and fused again to generate model features, and the model features are input into a large language model, and the predicted recommended drugs are output until the binary cross entropy loss function value is less than the preset binary cross entropy loss function value, and the training process of the large language model is terminated. Finally, the actual patient information is obtained and input into the trained model, and the predicted recommended drugs are output, so that the model output is more controllable, the patient's own situation is better integrated, and personalized traditional Chinese medicine recommendations are achieved, so that the recommended traditional Chinese medicine prescription results are controllable and clear, meet the individualized needs of patients, improve the accuracy and standardization of recommendation results, reduce the workload of doctors' manual analysis, shorten the time from diagnosis to prescription, and realize personalized medicine.

[0124] It should be understood that the processor in the embodiment of the present invention may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0125] It should also be understood that the memory in the embodiments of the present invention may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct rambus RAM (DR RAM).

[0126] The above embodiments can be implemented in whole or in part by software, hardware (such as circuits), firmware or any other combination. When implemented using software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions or computer programs. When a computer instruction or computer program is loaded or executed on a computer, a process or function according to an embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. Computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that contains one or more available media sets. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a tape), an optical medium (for example, a DVD), or a semiconductor medium. The semiconductor medium can be a solid-state hard disk.

[0127] It should be understood that the term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. A and B can be singular or plural. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship, but it may also indicate an "and / or" relationship. Please refer to the context for specific understanding.

[0128] In the present invention, "at least one" means one or more, and "more than one" means two or more. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can be represented by: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.

[0129] It should be understood that in various embodiments of the present invention, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0130] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0131] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described equipment, devices and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0132] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0133] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0134] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0135] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of various embodiments of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store program codes.

[0136] An embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, the method for recommending Chinese medicine prescriptions based on a large language model as described in the method embodiment is implemented.

[0137] A computer-readable storage medium provided by the present invention can implement the steps and effects of the traditional Chinese medicine prescription recommendation method based on a large language model in the above-mentioned method embodiment. To avoid repetition, the present invention will not go into details.

[0138] The beneficial effects brought about by the technical solution provided by the embodiment of the present invention include at least:

[0139] In the present invention, by collecting patient information and corresponding recommended drug labels, and converting patient text information into prompt word features and feature vectors respectively, the feature vectors are then interactively fused, and the generated fused feature vectors are horizontally spliced ​​to obtain a total feature vector, and the total feature vector is further deeply encoded through a self-attention mechanism layer and a feedforward neural network layer, and then mapped to a soft prompt feature vector through a soft prompt projection layer, and the soft prompt feature vector and the prompt word feature are spliced ​​and fused again to generate model features, and the model features are input into a large language model, and the predicted recommended drugs are output until the binary cross entropy loss function value is less than the preset binary cross entropy loss function value, and the training process of the large language model is terminated. Finally, the actual patient information is obtained and input into the trained model, and the predicted recommended drugs are output, so that the model output is more controllable, the patient's own situation is better integrated, and personalized traditional Chinese medicine recommendations are achieved, so that the recommended traditional Chinese medicine prescription results are controllable and clear, meet the individualized needs of patients, improve the accuracy and standardization of recommendation results, reduce the workload of doctors' manual analysis, shorten the time from diagnosis to prescription, and realize personalized medicine.

[0140] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

[0141] There are a few points to note:

[0142] (1) The drawings of the embodiments of the present invention only relate to the structures related to the embodiments of the present invention, and other structures may refer to the general design.

[0143] (2) For the sake of clarity, in the drawings used to describe the embodiments of the present invention, the thickness of the layers or regions is exaggerated or reduced, that is, these drawings are not drawn according to the actual scale. It is understood that when an element such as a layer, film, region or substrate is referred to as being "on" or "under" another element, the element may be "directly" "on" or "under" the other element or there may be intermediate elements.

[0144] (3) In the absence of conflict, the embodiments of the present invention and the features therein may be combined with each other to obtain new embodiments.

[0145] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. The protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A method for recommending Chinese medicine prescriptions based on a large language model, characterized in that: include: S1: Collect multiple patient text information and recommended drug labels for each patient text information; S2: converting the patient text information into prompt word features and feature vectors respectively; S3: interactively fuse the feature vectors through a cross attention mechanism layer to generate a fused feature vector; S4: horizontally concatenate each fused feature vector to obtain the total feature vector; S5: Deeply encode the total feature vector through a self-attention mechanism layer and a feedforward neural network layer to generate an output vector; S6: Mapping the output vector into a plurality of soft prompt feature vectors consistent with the number of layers of the large language model through a soft prompt projection layer; S7: concatenating and fusing the soft prompt feature vector and the prompt word feature to generate a model feature corresponding to each patient's text information; S8: Inputting each model feature into the large language model respectively, outputting the predicted recommended drugs corresponding to each model feature respectively, and calculating the binary cross entropy loss function value of the predicted recommended drugs until the binary cross entropy loss function value is less than the preset binary cross entropy loss function value, thereby completing the training of the large language model; S9: Obtain text information of the patient to be tested; S10: Input the text information of the patient to be tested into the trained large language model, and output the predicted recommended drugs.

2. The method for recommending Chinese medicine prescriptions based on a large language model according to claim 1, characterized in that: The patient text information specifically includes: a text description of symptoms, a text description of syndromes, a text description of diagnosis, and a text description of basic conditions.

3. The method for recommending Chinese medicine prescriptions based on a large language model according to claim 1, characterized in that: The characteristic vector is specifically: X 症状 =W 症状 ·A 症状 +b 症状 X 证候 =W 证候 ·A 证候 +b 证候 X 诊断 =W 诊断 ·A 诊断 +b 诊断 X 基本情况 =W 基本情况 ·A 基本情况 +b 基本情况 Among them, X 症状 represents the symptom feature vector, W 症状 represents the symptom embedding weight matrix, A 症状 represents the one-hot encoding matrix of the symptom input sequence, b 症状 represents the symptom bias vector, X 证候 represents the syndrome feature vector, W 证候 represents the syndrome embedding weight matrix, A 证候 represents the one-hot encoding matrix of the syndrome input sequence, b 证候 represents the syndrome bias vector, X 诊断 represents the diagnostic feature vector, W 诊断 represents the diagnosis embedding weight matrix, A 诊断 represents the one-hot encoding matrix of the diagnostic input sequence, b 诊断 represents the diagnostic bias vector, X 基本情况 represents the base case eigenvector, W 基本情况 represents the base case embedding weight matrix, A 基本情况 represents the one-hot encoding matrix of the base case input sequence, b 基本情况 Represents the base case bias vector.

4. The method for recommending Chinese medicine prescriptions based on a large language model according to claim 1, characterized in that: The S3 specifically includes: S301: Perform linear projection and layer normalization processing on the feature vector: Q 症状 ,K 症状 ,V 症状 =LP(Norm(X 症状 )) Q 证候 ,K 证候 ,V 证候 =LP(Norm(X 证候 )) Q 诊断 ,K 诊断 ,V 诊断 =LP(Norm(X 诊断 )) Q 基本情况 ,K 基本情况 ,V 基本情况 =LP(Norm(X 基本情况 )) Among them, Q 症状 represents the symptom query vector, K 症状 represents the symptom key vector, V 症状 represents the symptom value vector, LP represents the linear projection operation, Norm represents the layer normalization operation, Q 证候 represents the syndrome query vector, K 证候 represents the syndrome key vector, V 证候 represents the syndrome value vector, Q 诊断 represents the diagnostic query vector, K 诊断 represents the diagnostic key vector, V 诊断 represents the diagnostic value vector, Q 基本情况 represents the basic query vector, K 基本情况 represents the base case key vector, V 基本情况 represents the base case value vector; S302: Interactively fuse the processed feature vectors through the cross attention mechanism layer to generate a fused feature vector: O 症状 =Attention(Q 症状 ,K 症状 ,V 症状 )+λ 证候 Attention(Q 症状 ,K 证候 ,V 证候 )+ λ 诊断 Attention(Q 症状 ,K 诊断 ,V 诊断 )+λ 基本情况 Attention(Q 症状 ,K 基本情况 ,V 基本情况 ) O 证候 =Attention(Q 证候 ,K 证候 ,V 证候 )+λ 症状 Attention(Q 证候 ,K 症状 ,V 症状 )+ λ 诊断 Attention(Q 证候 ,K 诊断 ,V 诊断 )+λ 基本情况 Attention(Q 证候 ,K 基本情况 ,V 基本情况 ) O 诊断 =Attention(Q 诊断 ,K 诊断 ,V 诊断 )+λ 症状 Attention(Q 诊断 ,K 症状 ,V 症状 )+ λ 证候 Attention(Q 诊断 ,K 证候 ,V 证候 )+λ 基本情况 Attention(Q 诊断 ,K 基本情况 ,V 基本情况 ) O 基本情况 =Attention(Q 基本情况 ,K 基本情况 ,V 基本情况 )+λ 症状 Attention(Q 基本情况 ,K 症状 ,V 症状 )+ λ 证候 Attention(Q 基本情况 ,K 证候 ,V 证候 )+λ 诊断 Attention(Q 基本情况 ,K 诊断 ,V 诊断 ) Among them, O 症状 represents the symptom fusion feature vector, O 证候 represents the syndrome fusion feature vector, O 诊断 represents the diagnostic fusion feature vector, O 基本情况 represents the basic situation fusion feature vector, Atention represents the attention operation, λ 症状 represents the weighting coefficient of the symptom, λ 证候 represents the weighting coefficient of syndrome, λ 诊断 represents the weighting coefficient of diagnosis, λ 基本情况 Represents the weighting coefficient of the base case.

5. The method for recommending Chinese medicine prescriptions based on a large language model according to claim 1, characterized in that: The output vector is specifically: Output1=LayerNorm(O 总 +Attention(LayerNorm(O 总 ))) Output2=LayerNorm(Output1+FFN(Outputput1)) Among them, Output1 represents the input vector of the feedforward neural network layer, LayerNorm represents the layer normalization function, and O 总 represents the total feature vector, Attention represents the self-attention mechanism, Output2 represents the output vector, and FFN represents the feedforward neural network layer.

6. The method for recommending Chinese medicine prescriptions based on a large language model according to claim 1, characterized in that: The soft prompt feature vector is specifically: u (l) =W (l) U+b (l) Among them, u (l) represents the soft hint feature vector of layer l, W (l) represents the weight matrix of layer l, U represents the output vector, b (l) Represents the bias vector of layer l.

7. The method for recommending Chinese medicine prescriptions based on a large language model according to claim 1, characterized in that: The model features are specifically: d (l) =c (l) ‖u (l) Among them, d (l) represents the model features of layer l, c (l) represents the clue word feature of layer l, ‖ represents the concatenation operation, u (l) Represents the soft hint feature vector of layer l.

8. The method for recommending Chinese medicine prescriptions based on a large language model according to claim 1, characterized in that: The S8 specifically includes: S801: Inputting each model feature into the large language model respectively; S802: Combine the linear layer and the sigmoid function to output the predicted recommended drugs corresponding to each model feature; S803: Calculate the binary cross entropy loss function value of the predicted recommended drug and the recommended drug label: Among them, L bce Represents the binary cross entropy loss function value, y (i) represents the recommended drug for the i-th patient (i) Label, y represents the predicted recommended drug for the i-th patient, N represents the total number of patients, and log represents the logarithm; S804: According to the binary cross entropy loss function value, the loss weight and bias of the large language model are adjusted by the chain rule until the binary cross entropy loss function value of the large language model is less than the preset binary cross entropy loss function value, thereby completing the training of the large language model.

9. A Chinese medicine prescription recommendation system based on a large language model, characterized in that: include: processor; A memory having computer-readable instructions stored thereon, wherein when the computer-readable instructions are executed by the processor, the method for recommending traditional Chinese medicine prescriptions based on a large language model as described in any one of claims 1 to 8 is implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method for recommending traditional Chinese medicine prescriptions based on a large language model as described in any one of claims 1 to 8 is implemented.

Citation Information

Cited By

  • AI-based traditional Chinese medicine nursing recommendation system

    CN120878096A

  • Traditional Chinese medicine syndrome differentiation intelligent recommendation model and personalized health care method and system

    CN122266665A