Method for improving traditional Chinese medicine knowledge answering ability of large language model based on Lora fine tuning

By combining Lora fine-tuning technology with traditional Chinese medicine knowledge datasets, the problem of insufficient answering ability of large language models in the field of traditional Chinese medicine has been solved, and the ability to answer traditional Chinese medicine knowledge has been improved while reducing costs, especially the professional ability in the field of kidney disease.

CN120821798APending Publication Date: 2025-10-21JILIN INST OF CHEM TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510883874.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-30
Publication Date
2025-10-21

AI Technical Summary

Technical Problem

Large language models lack the ability to respond in vertical fields, especially when it comes to answering questions about traditional Chinese medicine knowledge, resulting in high computing costs and resource consumption. At the same time, small-parameter models have obvious gaps in professionalism and task generalization capabilities.

Method used

Using Lora fine-tuning technology, by constructing a traditional Chinese medicine knowledge dataset and low-rank matrix decomposition, the weight matrix of the large language model is modified, and only the low-rank matrix parameters are updated, which reduces the training cost and improves the ability to answer traditional Chinese medicine knowledge.

Benefits of technology

While reducing computing costs, the model's ability to answer questions about traditional Chinese medicine kidney disease has been significantly improved, demonstrating semantic coherence and terminology accuracy, surpassing the professional capabilities of large models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure BDA0005473154820000031
    Figure BDA0005473154820000031
  • Figure BDA0005473154820000032
    Figure BDA0005473154820000032
  • Figure BDA0005473154820000041
    Figure BDA0005473154820000041
Patent Text Reader

Abstract

The invention provides a method for modifying model weight by using a Lora fine tuning mode to enable a model to learn traditional Chinese medicine knowledge, which comprises the following steps of: S1, acquiring an original large language base model, and preparing for subsequently modifying weight parameters of the original large language model; s2, in order to train the reply ability of the model to the traditional Chinese medicine knowledge, constructing a traditional Chinese medicine knowledge data set; s3, acquiring Lora fine tuning technical parameter codes, and modifying parameters of the Lora fine tuning technical parameter codes to obtain corresponding training parameter codes; s4, a Lora fine adjustment mode is adopted, the weight matrix of the model after fine adjustment is W1, and the weight of the model after fine adjustment is changed into delta W; s5, performing fine tuning training on the specified large model by using the modified code and the constructed data set; s6, loading the trained Lora module to a weight matrix of the original model; and S7, evaluating the performance of the model, and evaluating the capability of the model by calculating the matching degree of the longest common subsequence between the model generation text and the reference text by adopting two evaluation indexes of BLEU-4 and ROUGE.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] In view of the insufficient response ability of large models in vertical fields, a method of improving model weights by introducing fine-tuning training methods based on classical Chinese medicine knowledge datasets was invented. Background Art

[0002] Large language models (LLMs), with their powerful general understanding and generation capabilities, are rapidly penetrating core processes across various industries. Their potential is increasingly evident, from scientific research and innovation, intelligent customer service, content creation, to financial analysis, biomedicine, and industrial design. However, a significant "base model dilemma" has also emerged: the pursuit of superior response capabilities, such as complex logical reasoning, long-range contextual dependencies, and highly specialized generation, often requires exponential expansion of model parameters, often into the billions or even trillions. This not only poses a severe challenge to training resources, but also faces high GPU costs and power consumption. While models with smaller parameter sizes are more user-friendly in terms of hardware requirements and deployment costs, they often fall short: their depth of language understanding, breadth of knowledge coverage, and task generalization capabilities lag significantly behind those of larger models. This is particularly true when processing complex, novel, or highly specialized queries, and the output quality often fails to meet the high standards required for practical applications. To address these issues, researchers have actively developed a variety of efficient model parameter fine-tuning techniques. These techniques significantly reduce resource consumption while preserving or approximating the core capabilities of large models. Lora technology, in particular, avoids directly updating these high-dimensional parameters by freezing the original weight matrices of pre-trained models. Instead, it introduces paired low-rank matrices A and B for factorized training, approximating the weight updates as low-rank matrix products. By freezing the main body and training only tiny low-rank adapters, it effectively guides large models to improve their ability to accurately adapt to downstream tasks while significantly reducing computational cost, storage overhead, and deployment complexity. Summary of the Invention

[0003] The purpose of the present invention is to use a small parameter model to reduce computational cost and resource consumption, and fine-tune a method with powerful TCM knowledge answering capabilities.

[0004] To achieve the above objectives, the present invention provides a method for modifying model weights using Lora fine-tuning and allowing the model to learn Chinese medicine knowledge, comprising the following steps:

[0005] S1. To solve the above problems, the present invention proposes a method for fine-tuning a large language model based on Lora, which modifies the weights of the large language model;

[0006] S2. To train the model’s ability to respond to TCM knowledge, a TCM knowledge dataset was constructed.

[0007] S3. Get the Lora fine-tuning technical parameter code, modify the parameters, and obtain the corresponding training parameter code;

[0008] S4. Fine-tune the specified large model using the modified code and constructed dataset, and load the trained Lora module into the weight matrix of the original model;

[0009] S5. Use Lora fine-tuning technology. After fine-tuning, the weight matrix of the model is W1. The fine-tuning technology is to change the weight of the model to ΔW, as shown in Formula 1:

[0010] W1=W0+ΔW (1)

[0011] where W0∈R d×k , W1∈R d×k , ΔW∈R d×k .

[0012] S6. Usually, the same matrix computation cost is required when adjusting the model weight parameters, but the Lora fine-tuning technique decomposes the parameter update ΔW of the model during fine-tuning into the product of two low-rank matrices: A and B, as shown in Formula 2:

[0013] ΔW=BA (2)

[0014] where B∈R d×r , A∈R r×k , r<<min(d,k) is a low-rank dimension. During training, only the size of r is updated to reduce training cost. Finally, the weight matrix W1 of the model is obtained, as shown in Formula 3:

[0015] W1=W0+ΔW=W0+BA (3)

[0016] By using Lora fine-tuning technology to update a small number of parameters, not only can the original knowledge structure of the model be retained, but the training cost can also be greatly reduced. The model's weight matrix can be changed to improve its ability to answer questions about traditional Chinese medicine kidney disease.

[0017] S7. The performance of the model was evaluated using two evaluation metrics: BLEU-4 and ROUGE. By calculating the degree of match between the longest common subsequence of the model-generated text and the reference text, the accuracy and fluency of the model-generated content were comprehensively measured. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 .Schematic diagram of the method framework flow chart;

[0019] Figure 2 . Schematic diagram of the process of building a dataset framework; DETAILED DESCRIPTION

[0020] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0021] like Figure 1 As shown in the figure, in the implementation process of the present invention, a method for training a large model by introducing a classical Chinese medicine knowledge dataset using the Lora fine-tuning method is proposed, including the following steps:

[0022] S1. In order to solve the above problems, the present invention reconstructs the weight increment through low-rank decomposition, and achieves high parameter efficiency in the field of traditional Chinese medicine by structurally modifying the model weight matrix while retaining the general knowledge of the large language model.

[0023] S2. In order to train the model's ability to respond to TCM knowledge, a TCM knowledge dataset was constructed. The dataset was constructed by collecting ShenNong-TCM. The specific process is as follows: Figure 2 As shown in the figure, the original dataset consisted of over 110,000 data points, including Chinese herbal prescriptions, syndrome classifications, and medicinal material properties. It integrated classic prescription compatibility patterns from 12 TCM classics, including the Shennong Bencao Jing. Clinical records from tertiary hospitals for various diseases, including lung disease, diabetes, and liver disease, were integrated, including fields such as symptom descriptions, syndrome differentiation, and treatment plans, to form a standardized TCM case library. To enhance the model's ability to answer questions about kidney disease, over 10,000 high-quality relevant data cases were screened. This was then combined with terminology from ancient TCM texts and the cMcdQA2 medical dataset to produce an initial dataset of over 20,000 entries.

[0024] S3. Obtain the Lora fine-tuning technical parameter code, modify the parameters, and obtain the corresponding training parameter code. The relevant parameters are shown in Table 1.

[0025] Table 1 Lora fine-tuning parameters

[0026]

[0027] S4. Fine-tune the specified large model using the modified code and constructed dataset, and load the trained Lora module into the weight matrix of the original model;

[0028] S5. For the Lora fine-tuning technology, the weight matrix of the model after fine-tuning is W1. The fine-tuning technology is to change the weight of the model to ΔW, as shown in Formula 1:

[0029] W1=W0+ΔW (1)

[0030] where W0∈R d×k , W1∈R d×k , ΔW∈R d×k .

[0031] S6. Usually, the same matrix computation cost is required when adjusting the model weight parameters, but the Lora fine-tuning technique decomposes the parameter update ΔW of the model during fine-tuning into the product of two low-rank matrices: A and B, as shown in Formula 2:

[0032] ΔW=BA (2)

[0033] where B∈R d×r , A∈R r×k , r<<min(d,k) is a low-rank dimension. During training, only the size of r is updated to reduce training cost. Finally, the weight matrix W1 of the model is obtained, as shown in Formula 3:

[0034] W1=W0+ΔW=W0+BA (3)

[0035] By using Lora fine-tuning technology to update a small number of parameters, not only can the original knowledge structure of the model be retained, but the training cost can also be greatly reduced. The model's weight matrix can be changed to improve its ability to answer questions about traditional Chinese medicine kidney disease.

[0036] S7. The performance of the model was evaluated using two evaluation metrics: BLEU-4 and ROUGE. By calculating the degree of match between the longest common subsequence of the model-generated text and the reference text, the accuracy and fluency of the model-generated content were comprehensively measured.

[0037] S7.1BLEU is a widely used metric for evaluating the quality of machine translation and natural language generation tasks. The BLEU-4 score is a weighted geometric mean of four n-gram matches, measuring the similarity between the generated text and the reference text. For each n-gram (n=1, 2, 3, 4), the n-gram precision calculates the proportion of the n-gram in the generated text that appears in the reference text. The geometric mean of these four n-gram accuracies is taken to obtain a comprehensive score, where the geometric mean can prevent a certain n-gram from having too much influence on the overall score when the match is extremely low. As shown in formula (4):

[0038]

[0039] where p n Indicates the accuracy of n-grams. To prevent generating too short texts from getting high scores, BLEU introduces a length penalty term, BP (Brevity Penalty). Its formula is shown in Figure 5:

[0040]

[0041] Where c is the length of the generated text, r is the length of the reference text closest to the generated text length. The final BLEU-4 score formula is shown in 6:

[0042]

[0043] S7.2 ROUGE is a type of evaluation metric used for automatic summarization, measuring the similarity between machine-generated text and human-generated reference text. ROUGE calculations are based on the overlap between the generated text and the reference text while focusing on recall. The most common ROUGE algorithms are ROUGE-N and ROUGE-L. ROUGE-1 calculates the overlap of single words, while ROUGE-2 calculates the overlap of bigrams, as shown in Formula 7:

[0044]

[0045] The denominator is the total number of n-grams in the reference summary, and the numerator is the number of n-grams shared by the model-generated summary and the reference summary. Rouge-N is the corresponding Rouge-1: 1-gram, Rouge-2: 2-gram, and Rouge-3: 3-gram. ROUGE-L is shown in Formula 8:

[0046]

[0047] Where LCS(generated, reference) is the longest common subsequence between the generated text and the reference text, and lengthofreference is the length of the reference text.

[0048] S7.3 According to the data comparison in Table 2, the fine-tuned model comprehensively surpasses the base model with a larger parameter scale in terms of its ability to recover knowledge about TCM kidney disease. Taking DeepSeek1.5B (Lora) as an example, its BLEU-4 score reached 22.09, an increase of 14.85 compared to DeepSeek7B; the ROUGE-1 score also jumped significantly from 28.08 to 43.14, an increase of 15.06. This trend is also significant in the Qwen series. The BLEU-4 and ROUGE scores of the fine-tuned Qwen1.5B (Lora) increased by 7.46, 6.03, 6.15, and 8.43 respectively compared to Qwen7B. These data show that the 1.5B parameter model, after fine-tuning on TCM kidney disease professional data, can not only break through the limitation of parameter scale, but also significantly improve semantic coherence and terminology accuracy, verifying the decisive role of domain-specific fine-tuning in improving the professional capabilities of small-parameter models.

[0049] Table 2 Comparison of scores after model fine-tuning

[0050]

[0051] Obviously, the above embodiments of the present invention are merely examples for the purpose of clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. Those skilled in the art will appreciate that other variations or modifications can be made based on the above description. It is not necessary and impossible to enumerate all embodiments here. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention shall be included within the scope of protection of the claims of the present invention.

Claims

1. A method for training a large model using a Lora fine-tuning method to introduce a classical Chinese medicine knowledge dataset, comprising the following steps: S1. In order to solve the above problems, the present invention reconstructs the weight increment through low-rank decomposition, and achieves high parameter efficiency in the field of traditional Chinese medicine by structurally modifying the model weight matrix while retaining the general knowledge of the large language model. S2. To train the model's ability to respond to Traditional Chinese Medicine (TCM) knowledge, a TCM knowledge dataset was constructed. The dataset was constructed by collecting the ShenNong-TCM dataset. The specific process is shown in Figure 2. The original dataset contained over 110,000 entries, including TCM prescriptions, syndrome classifications, and medicinal material properties. It incorporated classic prescription compatibility patterns from 12 TCM classics, including the Shennong Bencao Jing. Clinical records from tertiary hospitals for various diseases, including lung disease, diabetes, and liver disease, were integrated, including fields such as symptom descriptions, syndrome differentiation, and treatment plans, to form a standardized TCM case library. Over 10,000 high-quality, relevant data cases were screened and then combined with terminology from ancient TCM texts and the cMcdQA2 medical dataset to produce an initial dataset of over 20,000 entries. S3. Obtain the Lora fine-tuning technical parameter code, modify the parameters, and obtain the corresponding training parameter code. The relevant parameters are shown in Table 1. Table 1 Lora fine-tuning parameters S4. Fine-tune the specified large model using the modified code and constructed dataset, and load the trained Lora module into the weight matrix of the original model; S5. For the Lora fine-tuning technology, the weight matrix of the model after fine-tuning is W1. The fine-tuning technology is to change the weight of the model to ΔW, as shown in Formula 1: W1=W0+ΔW(1) Among them, W0∈Rd×k, W1∈Rd×k, ΔW∈Rd×k. S6. Usually, the same matrix computation cost is required when adjusting the model weight parameters, but the Lora fine-tuning technique decomposes the parameter update ΔW of the model during fine-tuning into the product of two low-rank matrices: A and B, as shown in Formula 2: ΔW=BA(2) Where B∈Rd×r and A∈Rr×k, r<<min(d,k) is a low-rank dimension. During training, only the size of r is updated to reduce training cost. Finally, the model weight matrix W1 is obtained, as shown in Formula 3: W1=W0+ΔW=W0+BA(3) By using Lora fine-tuning technology to update a small number of parameters, not only can the original knowledge structure of the model be retained, but the training cost can also be greatly reduced. The model's weight matrix can be changed to improve its ability to answer questions about traditional Chinese medicine kidney disease. S7. The performance of the model was evaluated using two evaluation metrics: BLEU-4 and ROUGE. By calculating the degree of match between the longest common subsequence of the model-generated text and the reference text, the accuracy and fluency of the model-generated content were comprehensively measured. S7.1BLEU is a widely used metric for evaluating the quality of machine translation and natural language generation tasks. The BLEU-4 score is a weighted geometric mean of four n-gram matches, measuring the similarity between the generated text and the reference text. For each n-gram (n=1, 2, 3, 4), the n-gram precision calculates the proportion of the n-gram in the generated text that appears in the reference text. The geometric mean of these four n-gram accuracies is taken to obtain a comprehensive score, where the geometric mean can prevent a certain n-gram from having too much influence on the overall score when the match is extremely low. As shown in formula (4): Where pn represents the accuracy of n-gram. To prevent generating too short texts from getting high scores, BLEU introduces a length penalty term BP (Brevity Penalty). Its formula is shown in Figure 5: Where c is the length of the generated text, r is the length of the reference text closest to the generated text length. The final BLEU-4 score formula is shown in 6: S7.2 ROUGE is a type of evaluation metric used for automatic summarization, measuring the similarity between machine-generated text and human-generated reference text. ROUGE calculations are based on the overlap between the generated text and the reference text while focusing on recall. The most common ROUGE algorithms are ROUGE-N and ROUGE-L. ROUGE-1 calculates the overlap of single words, while ROUGE-2 calculates the overlap of bigrams, as shown in Formula 7: The denominator is the total number of n-grams in the reference summary, and the numerator is the number of n-grams shared by the model-generated summary and the reference summary. Rouge-N is the corresponding Rouge-1: 1-gram, Rouge-2: 2-gram, and Rouge-3: 3-gram. ROUGE-L is shown in Formula 8: Where LCS(generated, reference) is the longest common subsequence between the generated text and the reference text, and lengthofreference is the length of the reference text. S7.3 According to the data comparison in Table 2, the fine-tuned model comprehensively surpasses the base model with a larger parameter scale in terms of its ability to recover knowledge about TCM kidney disease. Taking DeepSeek1.5B (Lora) as an example, its BLEU-4 score reached 22.09, an increase of 14.85 compared to DeepSeek7B; the ROUGE-1 score also jumped significantly from 28.08 to 43.14, an increase of 15.

06. This trend is also significant in the Qwen series. The BLEU-4 and ROUGE scores of the fine-tuned Qwen1.5B (Lora) increased by 7.46, 6.03, 6.15, and 8.43 respectively compared to Qwen7B. These data show that the 1.5B parameter model, after fine-tuning on TCM kidney disease professional data, can not only break through the limitation of parameter scale, but also significantly improve semantic coherence and terminology accuracy, verifying the decisive role of domain-specific fine-tuning in improving the professional capabilities of small-parameter models. Table 2 Comparison of scores after model fine-tuning