Traditional Chinese medicine classification method based on large model

Through the large-model-based traditional Chinese medicine classification method, and the use of entity recognition and adaptive fine-tuning technology, a classification model in the field of traditional Chinese medicine was constructed, which solved the problem of inconsistent standards and automation of traditional Chinese medicine classification methods, and achieved efficient and accurate classification of traditional Chinese medicine.

CN120337029APending Publication Date: 2025-07-18HUNAN ACAD OF CHINESE MEDICINE
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510382410.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-28
Publication Date
2025-07-18

AI Technical Summary

Technical Problem

Traditional Chinese medicine classification methods rely on expert experience, the classification standards are not unified, it is difficult to achieve automation, and it is difficult to identify new medicinal materials or drug effects, there are limitations and difficulties in processing redundant information.

Method used

A large-model-based traditional Chinese medicine classification method is adopted to construct a classification model in the field of traditional Chinese medicine through entity recognition, entity mapping association and adaptive fine-tuning, using text and image entity recognition data, combining traditional Chinese medicine pharmacological dictionary to establish mapping associations, and using adaptive fine-tuning to optimize model parameters to achieve efficient and accurate classification of traditional Chinese medicine.

Benefits of technology

It improves the accuracy and automation of traditional Chinese medicine classification, reduces calculation overhead, reduces training and reasoning complexity, and solves the limitations of traditional methods and the redundant information processing problems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120337029A_ABST
    Figure CN120337029A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of traditional Chinese medicine classification, and discloses a traditional Chinese medicine classification method based on a large model, and the method comprises the steps: carrying out the entity recognition of multi-source traditional Chinese medicine data, and obtaining multi-source entity recognition data; performing entity mapping association on the multi-source entity identification data; a traditional Chinese medicine field classification model based on the pre-trained large model is constructed, and self-adaptive fine tuning is carried out; and receiving the multi-source entity identification data and the mapping association pair between the traditional Chinese medicine and the modern pharmacological indexes by using the traditional Chinese medicine field classification model after self-adaptive fine adjustment, and classifying the traditional Chinese medicine. Based on semantic similarity parameters and co-occurrence parameters between the text entity tags, the dynamic transition probability between the different text entity tags is calculated, text entity recognition is carried out, a self-adaptive fine adjustment and optimization mode is adopted, fine adjustment parameters are added on the basis of a pre-trained large model for training, and the training efficiency is improved. Large model self-adaptive fine tuning in the traditional Chinese medicine field is realized, and traditional Chinese medicine classification accuracy is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of traditional Chinese medicine classification, and particularly to a traditional Chinese medicine classification method based on a large model. Background Art

[0002] Traditional Chinese medicine classification refers to grouping traditional Chinese medicines according to certain criteria based on factors such as the nature and flavor, efficacy, and pharmacological effects of traditional Chinese medicines. Traditional traditional Chinese medicine classification methods mostly rely on the records in traditional Chinese medicine classic literatures, such as "Compendium of Materia Medica" and the works of Li Shizhen, and classify traditional Chinese medicines based on the nature and flavor, meridian tropism, functions, etc. Such methods usually rely on expert experience, the classification process is highly subjective, it is difficult to achieve automation, and it is relatively difficult to identify new medicinal materials or drug effects. With the continuous development of traditional Chinese medicine, the traditional classification methods have the following problems: First, the classification criteria are not unified. Different traditional Chinese medicine scholars classify from different perspectives, resulting in inconsistent classification criteria and easy confusion; second, manual classification has limitations. The knowledge of traditional Chinese medicine is complex and extensive, and there are great limitations in relying on manual experience and subjective judgment for classification; third, the traditional Chinese medicine knowledge system contains a large amount of redundant information, and it is difficult for traditional classification methods to process efficiently. Summary of the Invention

[0003] In view of this, the present invention provides a traditional Chinese medicine classification method based on a large model, which can efficiently and accurately process various complex data in the field of traditional Chinese medicine based on the large model for adaptive fine-tuning in the field of traditional Chinese medicine, and provide support for the efficacy analysis, medicinal material identification, and classification of traditional Chinese medicines.

[0004] To achieve the above object, a traditional Chinese medicine classification method based on a large model provided by the present invention includes the following steps:

[0005] S1: Collect multi-source traditional Chinese medicine data and perform preprocessing, perform entity recognition on the multi-source traditional Chinese medicine data to obtain text entity recognition data and image entity recognition data, and form multi-source entity recognition data;

[0006] S2: Perform entity mapping association on the multi-source entity recognition data to construct a mapping association pair between traditional Chinese medicines and modern pharmacological indicators;

[0007] S3: Construct a traditional Chinese medicine field classification model based on a pre-trained large model and perform adaptive fine-tuning to obtain an adaptive fine-tuned traditional Chinese medicine field classification model;

[0008] S4: Use the adaptive fine-tuned traditional Chinese medicine field classification model to receive the multi-source entity recognition data and the mapping association pair between traditional Chinese medicines and modern pharmacological indicators to classify traditional Chinese medicines.

[0009] As a further improvement method of the present invention:

[0010] Optionally, preprocess the multi-source traditional Chinese medicine data, including:

[0011] Segment the traditional Chinese medicine classic data and clinical literature data to obtain the segmented phrase sequences of the traditional Chinese medicine classic data and clinical literature data;

[0012] Use a BERT encoder to represent the segmented phrases in the segmented phrase sequence as word vectors, obtain the word vectors of each segmented phrase, and use a linear layer to map the word vectors to obtain the scores of the word vectors under different text entity labels;

[0013] Take the word vectors and the score sequence of the word vectors as the preprocessing results of the traditional Chinese medicine classic data and clinical literature data;

[0014] The categories of the text entity labels include traditional Chinese medicine name labels, pharmacological description labels, efficacy labels, and other entity labels;

[0015] The preprocessing method for the traditional Chinese medicine image data is grayscale processing to obtain the preprocessed traditional Chinese medicine image data.

[0016] Optionally, perform text entity recognition on the preprocessing results of the traditional Chinese medicine classic data and clinical literature data, including:

[0017] Calculate the dynamic transition probability between different text entity labels, where the dynamic transition probability between the nth text entity label and the pth text entity label is:

[0018] G(n,p) = G0(n,p) + Sim(n,p)·Cor(n,p)

[0019]

[0020]

[0021] Where:

[0022] G(n,p) represents the dynamic transition probability between the nth text entity label and the pth text entity label, p ∈ [1,N];

[0023] G0(n,p) represents the initial transition probability between the nth text entity label and the pth text entity label;

[0024] Sim(n,p)·Cor(n,p) represents the dynamic transition parameter between the nth text entity label and the pth text entity label, Cor(n,p) represents the co-occurrence parameter between the nth text entity label and the pth text entity label, and Sim(n,p) represents the semantic similarity parameter between the nth text entity label and the pth text entity label;

[0025] count(n) represents the number of word vectors whose scores of the nth text entity label are greater than a preset score threshold, and count(n,p) represents the number of word vectors whose scores of the nth text entity label and the pth text entity label are both greater than the preset score threshold;

[0026] mean n represents the mean value of word vectors whose scores of the nth text entity label are greater than the preset score threshold, mean p represents the mean value of word vectors whose scores of the pth text entity label are greater than the preset score threshold, and ||·||2 represents the L2 norm;

[0027] Based on the score sequence of word vectors and the dynamic transition probability between different text entity labels, the Viterbi algorithm is used to solve the optimal text entity label for each word vector. If the score of the word vector in the optimal text entity label is higher than the preset score threshold, the segmented word group associated with the word vector and the optimal text entity label are extracted to form a set of entity recognition results;

[0028] Select the entity recognition result with the optimal text entity label as the traditional Chinese medicine name label, and traverse to obtain the set of entity recognition results whose distances from this entity recognition result are less than the preset distance threshold. The set of entity recognition results and the entity recognition result with the optimal text entity label as the traditional Chinese medicine name label are used as a set of text entity recognition data.

[0029] Optionally, perform image entity recognition on the preprocessed traditional Chinese medicine image data, including:

[0030] Perform Gaussian filtering on the preprocessed traditional Chinese medicine image data to remove image noise, and use the Sobel operator to calculate the gradient of the pixels in the image after Gaussian filtering. Mark the image pixels with gradients higher than the preset gradient threshold as edge candidate pixels, and calculate the contrast of the 5×5 pixel region centered on the edge candidate pixels;

[0031] Generate a dynamic gradient threshold for the 5×5 pixel region centered on the edge candidate pixels in combination with the contrast;

[0032] Mark the pixels in the 5×5 pixel region with gradients higher than the dynamic gradient threshold as edge pixels, and mark the edge candidate pixels as edge pixels;

[0033] Connect the edge pixels, take the closed image region surrounded by the edge pixels as the image entity to be recognized, extract the structural features of the image entity to be recognized, and use the YOLO object detection model to receive the structural features of the image entity to be recognized and output the image entity label corresponding to the image entity to be recognized;

[0034] All the image entities to be recognized, structural features, and corresponding image entity labels in a set of preprocessed traditional Chinese medicine image data are used as a set of image entity recognition data.

[0035] Optionally, the text entity recognition data and the image entity recognition data are combined to form multi-source entity recognition data, including:

[0036] The representation form of the multi-source entity recognition data is data:

[0037] data = {data1, data2}

[0038]

[0039] Where:

[0040] data1 represents the set of text entity recognition data, represents the r-th set of text entity recognition data, and R represents the total number of text entity recognition data;

[0041] data2 represents the set of image entity recognition data, represents the q-th set of image entity recognition data, and Q represents the total number of image entity recognition data.

[0042] Optionally, entity mapping association is performed on the multi-source entity recognition data, including:

[0043] Obtain a traditional Chinese medicine pharmacology dictionary, which stores data in the form of a dictionary. The representation form of the traditional Chinese medicine pharmacology dictionary is:

[0044]

[0045] Where:

[0046] dict represents the traditional Chinese medicine pharmacology dictionary, which describes the corresponding relationship between traditional Chinese medicine pharmacology description phrases and modern pharmacology indicators, B e represents the e-th group of traditional Chinese medicine pharmacology description phrases in the traditional Chinese medicine pharmacology dictionary, and E represents the total number of traditional Chinese medicine pharmacology description phrases in the traditional Chinese medicine pharmacology dictionary, represents the traditional Chinese medicine pharmacology description phrase B e corresponding modern pharmacology indicator;

[0047] Match the entity recognition result with the optimal text entity label as the pharmacology description label in the text entity recognition data with the traditional Chinese medicine pharmacology description phrases in the traditional Chinese medicine pharmacology dictionary;

[0048] Establish a mapping association pair between the modern pharmacological indicators corresponding to the successfully matched traditional Chinese medicine pharmacological description phrases and the text entity recognition data where the selected entity recognition result is located. Among them, the modern pharmacological indicators that have a mapping association pair with the traditional Chinese medicine corresponding to the r-th group of text entity recognition data are T r 。

[0049] Optionally, construct a classification model for the traditional Chinese medicine field based on a pre-trained large model, including:

[0050] The classification model for the traditional Chinese medicine field uses the pre-trained large model as the base model. The pre-trained large model is of the Decoder-only structure. The Decoder-only structure generates text step by step in an autoregressive manner according to the input text. The autoregressive manner means that when generating text, the output of each step is used as part of the input to generate the next word, and each generated word will affect the subsequent generation result;

[0051] The classification model for the traditional Chinese medicine field includes an input layer, a text entity completion layer, a multi-source entity matching layer, and a traditional Chinese medicine classification layer. The input layer is used to receive multi-source entity recognition data and the mapping association pair between traditional Chinese medicine and modern pharmacological indicators. The text entity completion layer is used to extract the text entity recognition data and the modern pharmacological indicators that have a mapping association pair with the traditional Chinese medicine corresponding to the text entity recognition data, and use the extracted text content as the input of the pre-trained large model. The pre-trained large model outputs the completion information of the text entity recognition data, and the completion information includes the source and shape of the traditional Chinese medicine;

[0052] The multi-source entity matching layer is used to use the shape of the traditional Chinese medicine as the input of the pre-trained large model to obtain the root, stem, and leaf structure features corresponding to the shape, as the structure features of the text entity recognition data, and match the image entity recognition data with the structure feature similarity and the text entity recognition data;

[0053] The traditional Chinese medicine classification layer is of the support vector machine structure and is used to receive the text entity recognition data, the mapped and associated modern pharmacological indicators, the completion information of the text entity recognition data, and the image entity recognition data matched by the text entity recognition data, and classify the traditional Chinese medicine corresponding to the text entity recognition data.

[0054] In an embodiment of the present invention, the pre-trained large model is the LLaMA-2 model.

[0055] Optionally, perform adaptive fine-tuning on the classification model for the traditional Chinese medicine field, including:

[0056] Collect fine-tuning training data, construct the collected fine-tuning training data into a fine-tuning training set, and add a prefix sequence with a length of Len before each group of fine-tuning training data. The prefix sequence is the fine-tuning parameter to be trained;

[0057] Use the fine-tuning training data with the prefix sequence added as the input to the pre-trained large model, generate text step by step in an autoregressive manner, and construct an adaptive fine-tuning loss function:

[0058]

[0059] Where:

[0060] Loss(θ) represents the adaptive fine-tuning loss function, θ represents the fine-tuning parameters to be trained, and δ h represents the h-th group of fine-tuning training data, ((θ,δ h ),1:t) represents the first t sequence values of the sequence (θ,δ h ), represents the t-th sequence value of the pre-trained large model target output sequence of the h-th group of fine-tuning training data, represents the conditional probability that the pre-trained large model outputs h based on the sequence ((θ,δ ),1:t), and t h represents the sequence length of the pre-trained large model target output sequence of the h-th group of fine-tuning training data, h ∈ [1, H], and H represents the number of fine-tuning training data;

[0061] Adopt adaptive optimization iteration for the fine-tuning parameters based on the adaptive fine-tuning loss function, and embed the fine-tuning parameters obtained by the adaptive optimization iteration into the pre-trained large model. After receiving the text content, the pre-trained large model automatically adds the fine-tuning parameters before the text content and generates the output content.

[0062] Optionally, the classified model in the field of traditional Chinese medicine after adaptive fine-tuning receives multi-source entity recognition data and the mapping correlation pairs between traditional Chinese medicine and modern pharmacological indicators, and classifies traditional Chinese medicine, including:

[0063] The input layer receives multi-source entity recognition data and the mapping correlation pairs between traditional Chinese medicine and modern pharmacological indicators. The text entity completion layer extracts the modern pharmacological indicators that have mapping correlation pairs with the text entity recognition data and the traditional Chinese medicine corresponding to the text entity recognition data, and uses the extracted text content as the input to the pre-trained large model. The pre-trained large model outputs the completion information of the text entity recognition data, and the completion information includes the source, efficacy, shape, properties, and uses of traditional Chinese medicine;

[0064] The multi-source entity matching layer uses the shape in the completion information as the input to the pre-trained large model to obtain the structural features of the roots, stems, and leaves corresponding to the shape, as the structural features of the text entity recognition data, and matches the image entity recognition data with structural feature similarity and the text entity recognition data;

[0065] The traditional Chinese medicine classification layer receives the text entity recognition data, the mapped and associated modern pharmacological indicators, the complementary information of the text entity recognition data, and the image entity recognition data matched by the text entity recognition data. It extracts the optimal text entity label from the text entity recognition data as the entity recognition result of the traditional Chinese medicine name label, which is used as the traditional Chinese medicine name. It also extracts the other entity recognition results, the mapped and associated modern pharmacological indicators, and the complementary information except the traditional Chinese medicine name, performs word vectorization representation, merges the word vectorization representation result with the structural features of the matched image entity recognition data into a classification vector, and uses a support vector machine to classify the classification vector to obtain the classification results of the traditional Chinese medicine in terms of efficacy and uses.

[0066] To solve the above problems, the present invention provides an electronic device, which includes:

[0067] A memory that stores at least one instruction;

[0068] A communication interface that enables the communication of the electronic device; and

[0069] A processor that executes the instructions stored in the memory to implement the above-mentioned traditional Chinese medicine classification method based on a large model.

[0070] To solve the above problems, the present invention also provides a computer-readable storage medium, in which at least one instruction is stored, and the at least one instruction is executed by a processor in an electronic device to implement the above-mentioned traditional Chinese medicine classification method based on a large model.

[0071] Compared with the prior art, the present invention proposes a traditional Chinese medicine classification method based on a large model, and this technology has the following advantages:

[0072] First, this solution proposes an entity recognition method. Based on the semantic similarity parameter and co-occurrence parameter between text entity tags, the dynamic transition probability between different text entity tags is calculated. The dynamic transition probability is used to characterize the smoothness of the text entity tag sequence corresponding to the word vector sequence. The Viterbi algorithm is used to solve the optimal text entity tag for each word vector, realizing the entity recognition of text data. Based on the gradient information, the edge candidate pixels in the image data are selected. Based on the pixel value standard deviation in the neighborhood of the edge candidate pixels, the contrast of the neighborhood of the edge candidate pixels is measured, and a dynamic gradient threshold for the neighborhood is generated for edge pixel detection. Among them, the local contrast reflects the change of pixel gray level in the region. For high-contrast regions, a higher threshold is required, while for low-contrast regions, a lower threshold is required. The closed image region surrounded by the edge pixels is used as the image entity to be recognized, and the structural features of the image entity to be recognized are extracted to realize the image entity recognition. Furthermore, the entity recognition in the case of sparse traditional Chinese medicine data is solved. By using the traditional Chinese medicine pharmacology dictionary, a mapping association pair is established between the traditional Chinese medicine descriptions in the text data and modern pharmacological indicators, improving the understanding of the characteristics of traditional Chinese medicine by the subsequent pre-trained large model and the accuracy of the text output content.

[0073] Meanwhile, this solution proposes a large model fine-tuning method. An adaptive fine-tuning optimization method is adopted. On the basis of the pre-trained large model, fine-tuning parameters are added, and only the fine-tuning parameters are fine-tuned. This significantly reduces the computational overhead and avoids updating a large number of parameters, greatly reducing the computational complexity in the training and inference processes, enabling it to perform efficient fine-tuning even when the computing resources are limited. During the adaptive iterative optimization process of the fine-tuning parameters, a method of fusing gradient information and training stage information to dynamically adjust the learning rate is proposed. The magnitude of the gradient is combined with the training steps to help use a larger learning rate for rapid search at the initial stage of training and a smaller learning rate for fine adjustment in the later stage. And through the method of gradient clipping, the problem of unstable training or explosion caused by too large gradients of the fine-tuning parameters in the pre-trained large model is effectively avoided. By using the gradient clipping coefficient to limit the maximum value of the gradient, the stability in the optimization process is improved, and the violent oscillation during the training process is avoided. Brief Description of the Drawings

[0074] Figure 1 It is a schematic flowchart of a traditional Chinese medicine classification method based on a large model provided by an embodiment of the present invention.

[0075] The realization, functional characteristics and advantages of the object of the present invention will be further described with reference to the embodiments and the accompanying drawings. Detailed Embodiments

[0076] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0077] An embodiment of the present application provides a traditional Chinese medicine classification method based on a large model. The execution subject of the traditional Chinese medicine classification method based on the large model includes, but is not limited to, at least one of electronic devices such as a server, a terminal, etc. that can be configured to execute the method provided in the embodiment of the present application. In other words, the traditional Chinese medicine classification method based on the large model can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes, but is not limited to: a single server, a server cluster, a cloud server, or a cloud server cluster, etc.

[0078] Referring to Figure 1 , Embodiment 1 of the present invention is:

[0079] A traditional Chinese medicine classification method based on a large model, comprising the following steps:

[0080] S1: Collect multi-source traditional Chinese medicine data and perform preprocessing, perform entity recognition on the multi-source traditional Chinese medicine data to obtain text entity recognition data and image entity recognition data, and form multi-source entity recognition data.

[0081] Performing preprocessing on the multi-source traditional Chinese medicine data includes:

[0082] Performing word segmentation on the traditional Chinese medicine classic data and clinical literature data to obtain the word segmentation phrase sequences of the traditional Chinese medicine classic data and clinical literature data;

[0083] Using a BERT encoder to perform word vector representation on the word segmentation phrases in the word segmentation phrase sequence to obtain the word vectors of each word segmentation phrase, and using a linear layer to map the word vectors to obtain the scores of the word vectors in different text entity labels; the formula for the linear layer to map the word vectors is:

[0084] score(c) = (score1(c), score2(c),..., score n (c),..., score N (c)) = c·W + b

[0085] Where:

[0086] score(c) represents the score sequence of the word vector c, score1(c), score2(c),..., score n (c),..., score N (c) represents the scores of the word vector c in N text entity labels, score n (c) represents the score of the word vector c in the nth text entity label, n ∈ [1, N];

[0087] W represents the weight matrix parameter of the linear layer, and b represents the bias parameter of the linear layer;

[0088] Take the word vector and the score sequence of the word vector as the preprocessing results of the traditional Chinese medicine classic data and the clinical literature data;

[0089] The text entity labels include traditional Chinese medicine name labels, pharmacological description labels, efficacy labels, and other entity labels;

[0090] The preprocessing method of the traditional Chinese medicine image data is grayscale processing to obtain the preprocessed traditional Chinese medicine image data.

[0091] Perform text entity recognition on the preprocessing results of the traditional Chinese medicine classic data and the clinical literature data, including:

[0092] Calculate the dynamic transition probability between different text entity labels. The dynamic transition probability between the nth text entity label and the pth text entity label is:

[0093] G(n,p) = G0(n,p) + Sim(n,p)·Cor(n,p)

[0094]

[0095] Where:

[0096] G(n,p) represents the dynamic transition probability between the nth text entity label and the pth text entity label, p ∈ [1,N];

[0097] G0(n,p) represents the initial transition probability between the nth text entity label and the pth text entity label;

[0098] Sim(n,p)·Cor(n,p) represents the dynamic transition parameter between the nth text entity label and the pth text entity label. Cor(n,p) represents the co-occurrence parameter between the nth text entity label and the pth text entity label, and Sim(n,p) represents the semantic similarity parameter between the nth text entity label and the pth text entity label;

[0099] count(n) represents the number of word vectors whose scores of the nth text entity label are greater than the preset score threshold, and count(n,p) represents the number of word vectors whose scores of both the nth text entity label and the pth text entity label are greater than the preset score threshold;

[0100] mean n represents the mean value of the word vectors whose scores of the nth text entity label are greater than the preset score threshold, mean p represents the mean value of the word vectors whose scores of the pth text entity label are greater than the preset score threshold, ||·||2 represents the L2 norm;

[0101] Based on the score sequence of word vectors and the dynamic transition probability between different text entity tags, the Viterbi algorithm is used to solve for the optimal text entity tag of each word vector. If the score of the word vector for the optimal text entity tag is higher than the preset score threshold, the segmented phrase associated with the word vector and the optimal text entity tag are extracted to form a set of entity recognition results;

[0102] Select the entity recognition results with the optimal text entity tag being the traditional Chinese medicine name tag, and traverse to obtain the set of entity recognition results whose distance from this entity recognition result is less than the preset distance threshold. The set of entity recognition results and the entity recognition results with the optimal text entity tag being the traditional Chinese medicine name tag are used as a set of text entity recognition data. Specifically, the distance between the entity recognition results is the distance of the phrases associated with the entity recognition results in the text data.

[0103] Perform image entity recognition on the preprocessed traditional Chinese medicine image data, including:

[0104] Perform Gaussian filtering on the preprocessed traditional Chinese medicine image data to remove image noise, and use the Sobel operator to calculate the gradient of the image pixels after Gaussian filtering. Mark the image pixels with a gradient higher than the preset gradient threshold as edge candidate pixels, and calculate the contrast of the 5×5 pixel region centered on the edge candidate pixels. The formula for the contrast of the 5×5 pixel region centered on the edge candidate pixel (x,y) is:

[0105]

[0106] Where:

[0107] I(x,y) represents the contrast of the 5×5 pixel region centered on the edge candidate pixel (x,y), the edge candidate pixel (x,y) is the pixel at the x-th row and y-th column in the image data, and d(x,y) represents the pixel value of the edge candidate pixel (x,y) after Gaussian filtering;

[0108] Generate a dynamic gradient threshold for the 5×5 pixel region centered on the edge candidate pixel in combination with the contrast. The dynamic gradient threshold for the 5×5 pixel region centered on the edge candidate pixel (x,y) is grad(x,y):

[0109] grad(x,y) = α(x,y)·I(x,y) + β

[0110] α(x,y) = α0·(1 + ε·I(x,y))

[0111] Where:

[0112] α(x, y) represents the dynamic weight coefficient of a 5×5 pixel region centered on the edge candidate pixel (x, y), β represents the threshold offset, α0 represents the initial weight coefficient, and ε represents the control factor;

[0113] Mark the pixels in the 5×5 pixel region centered on the edge candidate pixel with gradients higher than the dynamic gradient threshold as edge pixels, and mark the edge candidate pixel as an edge pixel;

[0114] Connect the edge pixels, take the closed image region surrounded by the edge pixels as the image entity to be recognized, extract the structural features of the image entity to be recognized, and use the YOLO object detection model to receive the structural features of the image entity to be recognized, and output the image entity label corresponding to the image entity to be recognized, where the image entity label includes roots, stems, and leaves;

[0115] Take all the image entities to be recognized, structural features, and corresponding image entity labels in a set of preprocessed traditional Chinese medicine image data as a set of image entity recognition data.

[0116] Construct the multi-source entity recognition data from the text entity recognition data and the image entity recognition data, including:

[0117] The representation form of the multi-source entity recognition data is data:

[0118] data = {data1, data2}

[0119]

[0120] Where:

[0121] data1 represents the text entity recognition data set, represents the r-th group of text entity recognition data, and R represents the total number of text entity recognition data;

[0122] data2 represents the image entity recognition data set, represents the q-th group of image entity recognition data, and Q represents the total number of image entity recognition data.

[0123] S2: Perform entity mapping association on the multi-source entity recognition data to construct a mapping association pair between traditional Chinese medicine and modern pharmacological indicators.

[0124] Performing entity mapping association on the multi-source entity recognition data includes:

[0125] Obtain a traditional Chinese medicine pharmacology dictionary, which stores data in dictionary form, and the representation form of the traditional Chinese medicine pharmacology dictionary is:

[0126]

[0127] Wherein:

[0128] dict represents a traditional Chinese medicine pharmacology dictionary, which describes the corresponding relationship between traditional Chinese medicine pharmacology description phrases and modern pharmacological indicators, B e represents the e-th group of traditional Chinese medicine pharmacology description phrases in the traditional Chinese medicine pharmacology dictionary, E represents the total number of traditional Chinese medicine pharmacology description phrases in the traditional Chinese medicine pharmacology dictionary, represents the traditional Chinese medicine pharmacology description phrase B e corresponding modern pharmacological indicator;

[0129] Match the entity recognition result with the optimal text entity label as the pharmacological description label in the text entity recognition data with the traditional Chinese medicine pharmacology description phrases in the traditional Chinese medicine pharmacology dictionary;

[0130] Establish a mapping association pair between the modern pharmacological indicators corresponding to the successfully matched traditional Chinese medicine pharmacology description phrases and the text entity recognition data where the selected entity recognition result is located. The modern pharmacological indicator that has a mapping association pair with the traditional Chinese medicine corresponding to the r-th group of text entity recognition data is T r .

[0131] S3: Construct a traditional Chinese medicine domain classification model based on a pre-trained large model and perform adaptive fine-tuning to obtain an adaptive fine-tuned traditional Chinese medicine domain classification model.

[0132] Constructing a traditional Chinese medicine domain classification model based on a pre-trained large model includes:

[0133] The traditional Chinese medicine domain classification model uses the pre-trained large model as the base model. The pre-trained large model is of the Decoder-only structure. The Decoder-only structure generates text step by step in an autoregressive manner according to the input text. The autoregressive manner is that when generating text, the output of each step is used as part of the input to generate the next word, and each generated word will affect the subsequent generation result;

[0134] The traditional Chinese medicine domain classification model includes an input layer, a text entity completion layer, a multi-source entity matching layer, and a traditional Chinese medicine classification layer. The input layer is used to receive multi-source entity recognition data and the mapping association pair between traditional Chinese medicine and modern pharmacological indicators. The text entity completion layer is used to extract the text entity recognition data and the modern pharmacological indicators that have a mapping association pair with the traditional Chinese medicine corresponding to the text entity recognition data, and use the extracted text content as the input of the pre-trained large model. The pre-trained large model outputs the completion information of the text entity recognition data. The completion information includes the source and shape of the traditional Chinese medicine. Specifically, the source includes plant medicine, animal medicine, and mineral medicine;

[0135] The multi-source entity matching layer is used to take the shape of the traditional Chinese medicine as the input of the pre-trained large model, obtain the root, stem, and leaf structure features corresponding to the shape, and use them as the structure features of the text entity recognition data, and match the image entity recognition data and the text entity recognition data with the structure feature similarity; As an embodiment of the present invention, the calculation method of the structure feature similarity is the cosine similarity algorithm;

[0136] The traditional Chinese medicine classification layer is a support vector machine structure, which is used to receive the text entity recognition data, the mapped and associated modern pharmacological indicators, the completion information of the text entity recognition data, and the image entity recognition data matched by the text entity recognition data, and classify the traditional Chinese medicine corresponding to the text entity recognition data.

[0137] In an embodiment of the present invention, the pre-trained large model is the LLaMA-2 model.

[0138] Adaptive fine-tuning of the traditional Chinese medicine field classification model includes:

[0139] Collect fine-tuning training data, construct the collected fine-tuning training data into a fine-tuning training set, and add a prefix sequence with a length of Len before each group of fine-tuning training data. The prefix sequence is the fine-tuning parameter to be trained;

[0140] Take the fine-tuning training data with the added prefix sequence as the input of the pre-trained large model, gradually generate text in an autoregressive manner, and construct an adaptive fine-tuning loss function:

[0141]

[0142] Where:

[0143] Loss(θ) represents the adaptive fine-tuning loss function, θ represents the fine-tuning parameter to be trained, and δ h represents the h-th group of fine-tuning training data, ((θ,δ h ),1:t) represents the first t sequence values of the sequence (θ,δ h ), represents the t-th sequence value of the pre-trained large model target output sequence of the h-th group of fine-tuning training data, represents the conditional probability that the pre-trained large model outputs h based on the sequence ((θ,δ ),1:t), and t h represents the sequence length of the pre-trained large model target output sequence of the h-th group of fine-tuning training data, h ∈ [1, H], and H represents the number of fine-tuning training data;

[0144] The fine-tuning parameters are adaptively optimized and iterated based on the adaptive fine-tuning loss function, and the fine-tuning parameters obtained through the adaptive optimization iteration are embedded into the pre-trained large model. After receiving the text content, the pre-trained large model automatically adds the fine-tuning parameters before the text content and generates the output content.

[0145] As a preferred embodiment of the present invention, the adaptive optimization iteration formula for the fine-tuning parameters is:

[0146]

[0147] Where:

[0148] θ(m) represents the m-th adaptive optimization iteration result of the fine-tuning parameter θ, represents the gradient of θ(m), clip represents the preset gradient clipping coefficient, and ||·||1 represents the L1 norm;

[0149] η m represents the adaptive learning rate of the m-th adaptive optimization iteration, represents the gradient control parameter, η0 represents the initial learning rate, and Max represents the preset maximum number of adaptive optimization iterations;

[0150] Repeat the adaptive optimization iteration of the fine-tuning parameters until the maximum number of adaptive optimization iterations is reached;

[0151] A method of dynamically adjusting the learning rate by fusing gradient information and training stage information is proposed, which combines the magnitude of the gradient with the training steps to help use a larger learning rate for rapid search in the initial stage of training and a smaller learning rate for fine-tuning in the later stage; and through the method of gradient clipping, the problem of unstable training or explosion caused by too large gradients of the fine-tuning parameters in the pre-trained large model is effectively avoided. By using the gradient clipping coefficient to limit the maximum value of the gradient, the stability in the optimization process is improved, and the violent oscillation in the training process is avoided.

[0152] S4: Use the Chinese medicine field classification model after adaptive fine-tuning to receive multi-source entity recognition data and the mapping association pairs between Chinese medicine and modern pharmacological index pairs to classify Chinese medicine.

[0153] The Chinese medicine field classification model after adaptive fine-tuning receives multi-source entity recognition data and the mapping association pairs between Chinese medicine and modern pharmacological index pairs to classify Chinese medicine, including:

[0154] The input layer receives multi-source entity recognition data and the mapping association pairs between traditional Chinese medicines and modern pharmacological indexes. The text entity completion layer extracts the text entity recognition data and the modern pharmacological indexes that have mapping association pairs with the traditional Chinese medicines corresponding to the text entity recognition data, and uses the extracted text content as the input of the pre-trained large model. The pre-trained large model outputs the completion information of the text entity recognition data, and the completion information includes the source, efficacy, shape, property, and use of the traditional Chinese medicine.

[0155] The multi-source entity matching layer uses the shape in the completion information as the input of the pre-trained large model to obtain the structural features of roots, stems, and leaves corresponding to the shape, which are used as the structural features of the text entity recognition data, and matches the image entity recognition data and the text entity recognition data with the structural feature similarity.

[0156] The traditional Chinese medicine classification layer receives the text entity recognition data, the mapped modern pharmacological indexes, the completion information of the text entity recognition data, and the image entity recognition data matched with the text entity recognition data. It extracts the entity recognition result with the optimal text entity label as the traditional Chinese medicine name label from the text entity recognition data as the traditional Chinese medicine name, and extracts the other entity recognition results, the mapped modern pharmacological indexes, and the completion information except the traditional Chinese medicine name, performs word vectorization representation, combines the word vectorization representation result with the structural features of the matched image entity recognition data into a classification vector, and uses a support vector machine to classify the classification vector to obtain the classification results of the traditional Chinese medicine in terms of efficacy and use. As an embodiment of the present invention, the classification categories of the efficacy include diaphoretics, heat-clearing drugs, purgatives, dampness-removing drugs, phlegm-resolving and cough-suppressing drugs, drugs for activating blood circulation and removing stasis, and tranquilizers, and the classification categories of the use include oral administration and external use.

[0157] It should be understood that the above embodiment is only for illustration purposes and is not limited by this structure in the scope of the patent application.

[0158] It should be noted that the serial numbers of the above embodiments of the present invention are only for description and do not represent the superiority or inferiority of the embodiments. And the term "comprising" or any other variant thereof in this article is intended to cover a non-exclusive inclusion, so that a process, device, article, or method including a series of elements not only includes those elements but also includes other elements not explicitly listed, or further includes elements inherent to such a process, device, article, or method. Without further limitation, an element defined by the statement "comprising one..." does not exclude the existence of another identical element in the process, device, article, or method including the element.

[0159] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-described embodiment methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium as described above (such as ROM / RAM, magnetic disk, optical disc), and includes several instructions for causing a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in various embodiments of the present invention.

[0160] The above are only the preferred embodiments of the present invention, and do not limit the patent scope of the present invention accordingly. Any equivalent structure or equivalent process transformation made by using the content of the specification and drawings of the present invention, or directly or indirectly applied in other related technical fields, shall be equally included in the patent protection scope of the present invention.

Claims

1. A traditional Chinese medicine classification method based on large models, characterized in that, The method includes: S1: Collect multi-source traditional Chinese medicine data and perform preprocessing. Perform entity recognition on the multi-source traditional Chinese medicine data to obtain text entity recognition data and image entity recognition data, and form multi-source entity recognition data; The multi-source traditional Chinese medicine data includes traditional Chinese medicine classic data, clinical literature data, and traditional Chinese medicine image data; The traditional Chinese medicine classic data and clinical literature data are in the form of text data, and the traditional Chinese medicine image data is in the form of image data; The entity recognition methods include text entity recognition and image entity recognition. The text entity recognition is used to perform entity recognition on text data, and the image entity recognition is used to perform entity recognition on image data; S2: Perform entity mapping association on the multi-source entity recognition data to construct a mapping association pair between traditional Chinese medicine and modern pharmacological indicators; S3: Construct a traditional Chinese medicine domain classification model based on a pre-trained large model and perform adaptive fine-tuning to obtain an adaptive fine-tuned traditional Chinese medicine domain classification model; S4: Use the adaptive fine-tuned traditional Chinese medicine domain classification model to receive the multi-source entity recognition data and the mapping association pair between traditional Chinese medicine and modern pharmacological indicators to classify traditional Chinese medicine.

2. The Chinese medicine classification method based on a large model according to claim 1, characterized in that Performing preprocessing on the multi-source traditional Chinese medicine data includes: Perform word segmentation on the traditional Chinese medicine classic data and clinical literature data to obtain the word segmentation phrase sequences of the traditional Chinese medicine classic data and clinical literature data; Use a BERT encoder to represent the word segmentation phrases in the word segmentation phrase sequence as word vectors, use a linear layer to map the word vectors, and obtain the scores of the word vectors under different text entity labels; Use the word vectors and the score sequence of the word vectors as the preprocessing results of the traditional Chinese medicine classic data and clinical literature data; The categories of the text entity labels include traditional Chinese medicine name labels, pharmacological description labels, efficacy labels, and other entity labels; The preprocessing method for the traditional Chinese medicine image data is grayscale processing to obtain preprocessed traditional Chinese medicine image data.

3. The Chinese medicine classification method based on a large model according to claim 2, wherein Performing text entity recognition on the preprocessing results of the traditional Chinese medicine classic data and clinical literature data includes: Calculate the dynamic transition probability between different text entity labels. The dynamic transition probability between the nth text entity label and the pth text entity label is: G(n,p) = G0(n,p) + Sim(n,p)·Cor(n,p) Where: G(n,p) represents the dynamic transition probability between the nth text entity label and the pth text entity label, p ∈ [1,N]; G0(n,p) represents the initial transition probability between the nth text entity label and the pth text entity label; Sim(n,p)·Cor(n,p) represents the dynamic transition parameter between the nth text entity label and the pth text entity label. Cor(n,p) represents the co-occurrence parameter between the nth text entity label and the pth text entity label, and Sim(n,p) represents the semantic similarity parameter between the nth text entity label and the pth text entity label; count(n) represents the number of word vectors whose scores of the nth text entity label are greater than a preset score threshold, and count(n,p) represents the number of word vectors whose scores of both the nth text entity label and the pth text entity label are greater than the preset score threshold; mean n It represents the mean of the word vectors where the score of the nth text entity label is greater than the preset score threshold, mean p It represents the mean of the word vectors where the score of the pth text entity label is greater than the preset score threshold; ||·||2 represents the L2 norm; Based on the score sequence of word vectors and the dynamic transition probabilities between different text entity labels, the Viterbi algorithm is used to solve for the optimal text entity label of each word vector. If the score of a word vector for the optimal text entity label is higher than the preset score threshold, the segmented word group associated with the word vector and the optimal text entity label are extracted to form a set of entity recognition results; Select the entity recognition results with the optimal text entity label being the traditional Chinese medicine name label, and traverse to obtain the set of entity recognition results whose distances from this entity recognition result are less than the preset distance threshold. The set of entity recognition results and the entity recognition results with the optimal text entity label being the traditional Chinese medicine name label are used as a set of text entity recognition data.

4. The Chinese medicine classification method based on a large model according to claim 2, characterized in that, Perform image entity recognition on the preprocessed traditional Chinese medicine image data, including: Perform Gaussian filtering on the preprocessed traditional Chinese medicine image data to remove image noise, and use the Sobel operator to calculate the gradients of the image pixels after Gaussian filtering. Mark the image pixels with gradients higher than the preset gradient threshold as edge candidate pixels, and calculate the contrast of the 5×5 pixel area centered on the edge candidate pixels; Generate a dynamic gradient threshold for the 5×5 pixel area centered on the edge candidate pixels in combination with the contrast; Mark the pixels in the 5×5 pixel area with gradients higher than the dynamic gradient threshold as edge pixels, and mark the edge candidate pixels as edge pixels; Connect the edge pixels, take the closed image area enclosed by the edge pixels as the image entity to be recognized, extract the structural features of the image entity to be recognized, and use the YOLO object detection model to receive the structural features of the image entity to be recognized and output the image entity label corresponding to the image entity to be recognized; Use all the image entities to be recognized, structural features, and corresponding image entity labels in a set of preprocessed traditional Chinese medicine image data as a set of image entity recognition data.

5. The Chinese medicine classification method based on a large model according to claim 1, characterized in that Construct multi-source entity recognition data from the text entity recognition data and the image entity recognition data, including: The representation form of the multi-source entity recognition data is data: data = {data1, data2} where: data1 represents the text entity recognition data set, represents the r-th group of text entity recognition data, and R represents the total number of text entity recognition data; data2 represents the image entity recognition data set, representing the q-th group of image entity recognition data, where Q represents the total number of image entity recognition data.

6. The Chinese medicine classification method based on a large model according to claim 5, wherein, Perform entity mapping association on the multi-source entity recognition data, including: Obtain a traditional Chinese medicine pharmacology dictionary, which stores data in dictionary form, and the representation form of the traditional Chinese medicine pharmacology dictionary is: where: The dict represents a traditional Chinese medicine pharmacology dictionary, which describes the correspondence between traditional Chinese medicine pharmacology description phrases and modern pharmacological indicators, B e represents the e-th traditional Chinese medicine pharmacology description phrase in the traditional Chinese medicine pharmacology dictionary, and E represents the total number of traditional Chinese medicine pharmacology description phrases in the traditional Chinese medicine pharmacology dictionary, represents the traditional Chinese medicine pharmacology description phrase B e corresponding modern pharmacological indicator; Match the entity recognition results with the optimal text entity label being the pharmacology description label in the text entity recognition data with the traditional Chinese medicine pharmacology description phrases in the traditional Chinese medicine pharmacology dictionary; Establish a mapping association pair between the modern pharmacological indicators corresponding to the successfully matched traditional Chinese medicine pharmacological description phrases and the text entity recognition data where the selected entity recognition result is located. Among them, the modern pharmacological indicator with a mapping association pair with the traditional Chinese medicine corresponding to the r-th group of text entity recognition data is T r 。 7. The Chinese medicine classification method based on a large model according to claim 1, wherein, Construct a traditional Chinese medicine domain classification model based on a pre-trained large model, including: The classification model in the field of traditional Chinese medicine uses a pre-trained large model as the base model. The pre-trained large model has a Decoder-only structure. The Decoder-only structure generates text step by step in an autoregressive manner according to the input text. The autoregressive manner means that when generating text, the output of each step is used as part of the input to generate the next word, and each generated word affects the subsequent generation results; The classification model in the field of traditional Chinese medicine includes an input layer, a text entity completion layer, a multi-source entity matching layer, and a traditional Chinese medicine classification layer. The input layer is used to receive multi-source entity recognition data and the mapping association pairs between traditional Chinese medicine and modern pharmacological indicators. The text entity completion layer is used to extract the text entity recognition data and the modern pharmacological indicators that have mapping association pairs with the traditional Chinese medicine corresponding to the text entity recognition data, and use the extracted text content as the input of the pre-trained large model. The pre-trained large model outputs the completion information of the text entity recognition data, and the completion information includes the source and shape of the traditional Chinese medicine; The multi-source entity matching layer is used to use the shape of the traditional Chinese medicine as the input of the pre-trained large model to obtain the root, stem, and leaf structural features corresponding to the shape, as the structural features of the text entity recognition data, and match the image entity recognition data and the text entity recognition data with structural feature similarity; The traditional Chinese medicine classification layer is a support vector machine structure, which is used to receive the text entity recognition data, the mapped modern pharmacological indicators, the completion information of the text entity recognition data, and the image entity recognition data matched by the text entity recognition data, and classify the traditional Chinese medicine corresponding to the text entity recognition data.

8. The Chinese medicine classification method based on a large model according to claim 7, wherein Adaptive fine-tuning of the classification model in the field of traditional Chinese medicine includes: Collect fine-tuning training data, construct the fine-tuning training data into a fine-tuning training set, and add a prefix sequence with a length of Len before each group of fine-tuning training data. The prefix sequence is the fine-tuning parameter to be trained; Use the fine-tuning training data with the added prefix sequence as the input of the pre-trained large model, generate text step by step in an autoregressive manner, and construct an adaptive fine-tuning loss function: Where: Loss(θ) represents the adaptive fine-tuning loss function, θ represents the fine-tuning parameters to be trained, and δ h represents the h-th group of fine-tuning training data, ((θ, δ h ), 1:t) represents the first t sequence values of the sequence (θ, δ h ), represents the t-th sequence value of the pre-trained large model target output sequence of the h-th group of fine-tuning training data, represents the pre-trained large model based on the sequence ((θ, δ h ), 1:t) output of the conditional probability, t h represents the sequence length of the pre-trained large model target output sequence of the h-th group of fine-tuning training data, h ∈ [1, H], and H represents the number of fine-tuning training data; Adaptive optimization iteration is performed on the fine-tuning parameters based on the adaptive fine-tuning loss function, and the fine-tuning parameters obtained by the adaptive optimization iteration are embedded into the pre-trained large model. After receiving the text content, the pre-trained large model automatically adds the fine-tuning parameters before the text content and generates the output content.

9. The Chinese medicine classification method based on a large model according to claim 1, characterized in that The classification model in the field of traditional Chinese medicine after adaptive fine-tuning receives multi-source entity recognition data and the mapping association pairs between traditional Chinese medicine and modern pharmacological indicators, and classifies traditional Chinese medicine, including: The input layer receives multi-source entity recognition data and the mapping association pairs between traditional Chinese medicine and modern pharmacological indicators. The text entity completion layer extracts the text entity recognition data and the modern pharmacological indicators that have mapping association pairs with the traditional Chinese medicine corresponding to the text entity recognition data, and uses the extracted text content as the input of the pre-trained large model. The pre-trained large model outputs the completion information of the text entity recognition data, and the completion information includes the source, efficacy, shape, property, and use of the traditional Chinese medicine; The multi-source entity matching layer takes the shape in the complemented information as the input of the pre-trained large model, obtains the structural features of the root, stem, and leaves corresponding to the shape, uses them as the structural features of the text entity recognition data, and matches the image entity recognition data and the text entity recognition data with the structural feature similarity. The traditional Chinese medicine classification layer receives the text entity recognition data, the mapped and associated modern pharmacological indicators, the complemented information of the text entity recognition data, and the image entity recognition data matched by the text entity recognition data. It extracts the optimal text entity label from the text entity recognition data as the entity recognition result with the traditional Chinese medicine name label, uses it as the traditional Chinese medicine name, and extracts other entity recognition results, the mapped and associated modern pharmacological indicators, and the complemented information except the traditional Chinese medicine name, performs word vectorization representation, merges the word vectorization representation result with the structural features of the matched image entity recognition data into a classification vector, and uses a support vector machine to classify the classification vector to obtain the classification results of the traditional Chinese medicine in terms of efficacy and uses.