Pre-hospital emergency text classification and annotation method, electronic device, storage medium and computer program product based on ChatGLM model

By combining P-tuning v2 and Lora fine-tuning technology on the ChatGLM model, the existing technology problems of low accuracy and high consumption of computing resources for pre-hospital emergency text classification and annotation are solved, and more efficient pre-hospital emergency text information classification and annotation is achieved. , improving the accuracy of initial diagnosis and treatment efficiency of critically ill patients.

CN118277573BActive Publication Date: 2024-09-13HEBEI UNIV OF ENG
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
CN202410692198.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-31
Publication Date
2024-09-13
Estimated Expiration
2044-05-31

AI Technical Summary

Technical Problem

The existing pre-hospital emergency text classification and annotation methods rely on manual experience and have limited accuracy. Moreover, the performance improvement after fine-tuning using the Bert model is not significant and the computing resources are large, making it difficult to effectively learn the characteristics of pre-hospital emergency medical record data.

Method used

The pre-hospital emergency text classification and annotation method based on the ChatGLM model is adopted. Through P-tuning v2 and Lora fine-tuning technology, the baseline model parameters are frozen, trainable parameters and low-rank matrix bypass are introduced, and the parameter values ​​are updated until the loss function is minimized, improving the model. The accuracy and professionalism of classification labeling.

Benefits of technology

It improves the accuracy and professionalism of classification and annotation of pre-hospital emergency text information, quickly provides initial disease diagnosis and decision-making suggestions for critically ill patients, improves the treatment rate, and achieves accurate identification and comprehensive prediction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118277573B
    Figure CN118277573B
Patent Text Reader

Abstract

The present invention discloses a pre-hospital emergency text classification and labeling method based on the ChatGLM model, including: S1: acquiring historical data of pre-hospital emergency medical records, obtaining pre-hospital emergency text after data pre-processing, and manually labeling disease ICD codes; S2: selecting the ChatGLM‑6B benchmark model, freezing the benchmark model parameters, and respectively introducing P‑tuning v2 trainable parameters and Lora bypass to perform model fine-tuning; S3: using the fine-tuning model to complete the classification and labeling of the pre-hospital emergency medical records to be processed, and obtaining the disease ICD code. The present invention also discloses an electronic device, a storage medium, and a computer program product. The present invention performs model fine-tuning through language model enhanced learning, improves the accuracy and professionalism of the classification and labeling of pre-hospital emergency text information, improves the work efficiency for the initial diagnosis of diseases of critically ill patients, realizes accurate identification and comprehensive prediction, and has broad application prospects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of natural language processing, and more specifically, to a pre-hospital emergency text classification and annotation method based on a ChatGLM model, an electronic device, a storage medium, and a computer program product. Background Art

[0002] Pre-hospital emergency care is an emergency medical activity for critically ill patients outside the hospital, and is an important part of emergency medicine. Strengthening the management of emergency calls is an important guarantee for pre-hospital emergency care. After answering the 120 call, ask for the personal identity information and symptoms of critically ill patients, and collect detailed emergency information in the shortest possible time, which can provide guidance for the reception. However, the problem is that the initial diagnosis of the disease mainly relies on manual experience to make judgments, which may be misjudged due to the limitations of staff experience. A large number of pre-hospital emergency electronic medical records are recorded in the emergency network systems established in large and medium-sized cities. If the text information of the existing pre-hospital emergency electronic medical records can be analyzed by using deep learning methods, and the disease information of critically ill patients can be classified and labeled, the initial diagnosis results can be accelerated and the accuracy of the initial diagnosis can be improved, which is of great significance to pre-hospital emergency care. This is the technical problem that this application aims to solve. In addition, the previous solution achieved the recognition of pre-hospital emergency medical record text through a combination of the Bert model and the classification model, but due to the limitation of the model parameters, it was not able to learn the characteristics of the pre-hospital emergency medical record data well, and the accuracy of the model was limited; in addition, the Bert model fine-tuned by the full parameter fine-tuning method in the past methods did not significantly improve the performance of the final model, and the full parameter fine-tuning consumed a lot of computing resources. Summary of the invention

[0003] The present invention provides a pre-hospital emergency text classification and labeling method, electronic device, storage medium and computer program product based on the ChatGLM model, which performs model fine-tuning through language model reinforcement learning, improves the classification and labeling accuracy and professionalism of pre-hospital emergency text information, improves the work efficiency for the initial diagnosis of diseases of critically ill patients, realizes accurate identification and comprehensive prediction, and has broad application prospects.

[0004] In order to achieve these purposes and other advantages according to the present invention, a pre-hospital emergency text classification and annotation method based on the ChatGLM model is provided, comprising:

[0005] S1: Obtain historical data of pre-hospital emergency medical records, obtain pre-hospital emergency text after data pre-processing, manually annotate disease ICD codes, and obtain pre-hospital emergency text dataset;

[0006] S2: Select the ChatGLM-6B benchmark model, freeze the benchmark model parameters, introduce the trainable parameters of P-tuning v2 and Lora bypass to fine-tune the model, and update the parameter values ​​until the loss function is minimized;

[0007] S3: Use the fine-tuning model to complete the classification and labeling of the pre-hospital emergency medical records to be processed and obtain the disease ICD code.

[0008] Preferably, the data preprocessing in S1 includes information desensitization, information screening and text cleaning.

[0009] Preferably, the pre-hospital emergency text dataset in S1 is divided into a training set, a test set, and a validation set.

[0010] Preferably, S2 specifically includes: selecting the ChatGLM-6B benchmark model, freezing the benchmark model parameters, converting the pre-hospital emergency text into a word embedding vector through the embedding layer of the model, introducing the trainable parameters of P-tuning v2, generating a continuous embedding sequence as the model input vector, and at the same time, introducing the Lora bypass containing a low-rank matrix into the self-attention layer of the model, obtaining the minimum loss by minimizing the loss function, back-propagating and updating the parameter values, and realizing model fine-tuning.

[0011] Preferably, the introduction of trainable parameters of P-tuning v2 is achieved by adding a PrefixEncoder module to the ChatGLM-6B benchmark model, where the PrefixEncoder module consists of two layers of perceptrons.

[0012] Preferably, the hyperparameters in S2 include learning rate, batch size, natural language instruction length, maximum length of input sequence, maximum length of output text, low-rank matrix rank, and Lora fine-tuning scaling factor.

[0013] An electronic device comprises: at least one processor, and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described.

[0014] A storage medium stores a computer program, which, when executed by a processor, implements the method described.

[0015] A computer program product comprises a computer program, which, when executed by a processor, implements the method described.

[0016] The present invention has at least the following beneficial effects:

[0017] First, the present invention first collects the text information of pre-hospital emergency medical records, and then performs data preprocessing on the collected text information. The preprocessed data will be divided into a training set, a test set, and a validation set. The model fine-tuning adopts improved PV2-Lora fine-tuning, and the fine-tuned language model is used to complete more classification and labeling tasks of pre-hospital emergency medical records.

[0018] Second, the present invention can improve the accuracy and professionalism of classification and annotation of pre-hospital emergency text information, improve the work efficiency for the initial diagnosis of diseases of critically ill patients, quickly provide decision-making suggestions, improve the treatment rate of critically ill patients, achieve accurate identification and comprehensive prediction, and has broad application prospects.

[0019] Third, compared with the applicant's previous research results, the present invention has the following advantages: (1) in data set construction, each input text and the corresponding ICD code are constructed as a key-value pair, and then multiple key-value pairs are stored as a json format file; (2) in model selection, the ChatGLM-6B benchmark model is selected and used, and the GLM model architecture is adopted, which has stronger dialogue generation ability, memory ability and real-time processing ability, so it has a wider range of application scenarios and understanding ability; (3) in fine-tuning method, the PV2-Lora combined fine-tuning method is used to achieve efficient fine-tuning of the model, so the present invention specifically highlights the substantial characteristics and significant progress.

[0020] Other advantages, objectives and features of the present invention will be embodied in part through the following description, and in part will be understood by those skilled in the art through study and practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 It is a schematic diagram of the architecture structure of the PV2-Lora fine-tuning of the present invention. DETAILED DESCRIPTION

[0022] The present invention is further described in detail below in conjunction with the accompanying drawings so that those skilled in the art can implement the invention with reference to the description.

[0023] It should be understood that the terms such as “having”, “including” and “comprising” used herein do not exclude the existence or addition of one or more other elements or combinations thereof.

[0024] It should be noted that the experimental methods described in the following embodiments are conventional methods unless otherwise specified, and the reagents and materials can be obtained from commercial sources unless otherwise specified; in the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "set" should be understood in a broad sense, for example, they can be fixedly connected, set, or detachably connected, set, or connected and set in one piece. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood in specific circumstances. The orientation or position relationship indicated by the terms "lateral", "longitudinal", "upper", "lower", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc. is based on the orientation or position relationship shown in the accompanying drawings, which is only for the convenience of describing the present invention and simplifying the description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation of the present invention.

[0025] The present invention provides a pre-hospital emergency text classification and annotation method based on the ChatGLM model, comprising:

[0026] S1: Obtain historical data of pre-hospital emergency medical records, obtain pre-hospital emergency text after data pre-processing, manually annotate disease ICD codes, and obtain pre-hospital emergency text dataset. Specifically, data pre-processing in S1 includes information desensitization, information screening, and text cleaning.

[0027] Before the patient is sent to the hospital for emergency treatment, the patient, his family or other people will contact the hospital staff by phone. At this time, various information about the patient will be recorded, resulting in a large amount of data to be processed. However, the data obtained at this time contains a large amount of sensitive information, and professionals need to be assigned to collect such data and desensitize the data. Pre-hospital emergency data contains information such as task code number, gender, age, nationality, occupation, condition, cause, chief complaint, current medical history, etc. In addition to recording information related to these diseases, pre-hospital emergency data also records information unrelated to some diseases, such as "passers-by", "passerby complaints", etc. These information unrelated to the disease are entered by the operator according to the actual situation and are irrelevant to the description of the disease. Therefore, it is necessary to denoise the text information in the pre-hospital emergency data to obtain the denoised text information, including: information screening and text cleaning. Among them, information screening is mainly responsible for screening out disease-related information from pre-hospital emergency medical records; text cleaning is mainly responsible for removing special symbols, redundant spaces, and data missing caused by improper operation during the entry process in the text information. After information desensitization, information screening and text cleaning, the pre-hospital emergency text is obtained, and then handed over to experts for manual annotation of ICD-10 codes based on the specific content. ICD coding (International Statistical Classification of Diseases and Related Health Problems) is an internationally unified disease classification method compiled by the World Health Organization, which has the uniformity of healthcare industry terminology and statistical data.

[0028] By inputting text information into the large language processing model and fine-tuning the model parameters, the performance of the large language model in the pre-hospital emergency text classification task can be significantly improved. The large language processing model can be Bert, LlAMA, DialoGPT, ChatGLM-6B, without restriction, and can achieve a certain improvement in performance. The model used in this application is the Tsinghua open source model ChatGLM-6B. When fine-tuning the model, the original data needs to be processed into a specific format. The format example is shown below:

[0029] {"content":"content is data","summary":"summary can be understood as a label"}

[0030] The "content" part in this application is the text description related to the disease, and the "summary" part is the ICD-10 code corresponding to the disease description. By running the written data processing script, the denoised text information can be processed into the above form and transferred to a json format file. The following is the processed sample data:

[0031] {"content": "61-year-old male fell down after drinking and had a history of coronary heart disease for many years", "summary": "T51"}

[0032] When fine-tuning the model, write the local path where the file is stored into the fine-tuning script to input data.

[0033] Specifically, the pre-hospital emergency text dataset in S1 is divided into training set, test set, and validation set, which together constitute a complete process of learning, tuning, and evaluation, providing a solid foundation for performance improvement and application expansion of model fine-tuning.

[0034] S2: Select the ChatGLM-6B benchmark model, freeze the benchmark model parameters, introduce the trainable parameters of P-tuning v2 and Lora bypass to fine-tune the model, and update the parameter values ​​until the loss function is minimized.

[0035] The model used in this paper is the ChatGLM-6B benchmark model, which is based on the General Language Model (GLM) model architecture and supports Chinese-English bilingual dialogue. GLM is a transformer-based language model that uses the technology of autoregressive space filling tasks. Specifically, for a given input text x ={ x 1,...., x n}, sampling multiple text fragments { s 1, s 2,..., s n}. Each segment is replaced with a single [Mask] to form a "damaged" text. The model will predict the missing content in the segment in an autoregressive manner based on the damaged text, that is, the model can access both the lost text and the previously predicted segments when making predictions. At the same time, in order to fully capture the interdependencies between different segments, the order of the segments is randomly sorted. Autoregressive blank filling improves the filling pre-training and greatly improves the model performance. The maximum likelihood function of autoregressive blank filling is as follows:

[0036]

[0037] in Z m is the set of all possible permutations of an index sequence of length m, S z<i It can also be expressed as { S 1 ,…, S i-1The generation probability of each missing part is decomposed into:

[0038]

[0039] In order to achieve autoregressive generation, the input text is divided into two parts: Part A is the "damaged" text x corrupt , and Part B contains the masked fragment. Tokens in Part A ("token" refers to a smallest unit in the text. Usually, a token can be a word, a punctuation mark, a number, a symbol, etc.) can pay attention to each other, but cannot pay attention to any token in B. Tokens in Part B can pay attention to the preceding tokens in Part A and Part B, but cannot pay attention to any subsequent tokens in Part B. At the same time, each fragment is filled with special tokens [START] and as input and output. The original text is sampled into multiple fragments, some of which are replaced by [MASK], and then autoregressive generation is performed. Each fragment starts with [S] and ends with [E].

[0040] In addition, in order to solve the problem of encoding position information in the autoregressive blank filling task, GLM introduces two-dimensional position encoding. Specifically, each token is encoded with two position ids. The first position id represents the position in the damaged text. x corrupt The second position id represents the position in the fragment. For the replaced fragment, it is the position of the corresponding [MASK]. The second position id represents the position inside the fragment. For tokens in Part A, their second position id is 0; for tokens in Part B, their second position id is between 1 and the fragment length. These two position ids are projected into two vectors through a learnable embedding table and then added to the input token embedding.

[0041] In addition, the GLM model implements a variant based on the transformer model - GLMBlock, whose basic structure is Hidden States→Self Attention→Layer Norm→GLU→HiddenStates.

[0042] (1) Layer Norm is a normalization method that normalizes each sample in the feature dimension so that the output has a mean of 0 and a variance of 1 in each feature dimension, thereby accelerating the convergence of the model and helping to solve the problems of gradient vanishing and gradient exploding.

[0043] (2) Self-Attention is the core component of the Transformer model. Given an input sequence, the self-attention mechanism can calculate a weight vector based on the relationship between each element in the sequence and other elements, and use the weight vector to perform weighted averaging on the input sequence, so that the model can better capture long-sequence dependencies in the sequence.

[0044] (3) GLU (Gated Linear Unit) is a nonlinear activation function, which is defined as:

[0045]

[0046] in, x is the input vector, represents element-by-element multiplication, and σ represents the Sigmoid function. GLU mainly consists of two parts: linear transformation and gating mechanism. Linear transformation is responsible for extracting input features, while gating mechanism is responsible for controlling the flow of information to achieve selective filtering of input.

[0047] P-Tuning v2 fine-tuning technology is an improvement on P-Tuning v1 fine-tuning technology. P-Tuning v1 replaces the tokens prompted by natural language with trainable embeddings, uses LSTM for reparamerization to accelerate training, and introduces a small number of anchor characters (such as Britain) prompted by natural language to further improve the effect. The following is an example of the implementation process of P-Tuning v1 fine-tuning technology:

[0048] Input a sentence and design a template that contains pseudo tokens. Use LSTM to represent these tokens and replace the original pre-trained model word embedding to get:

[0049] [ e ( x ), h 0 ,…, h i , e ([ MASK ])]

[0050] Input it into MLM, MLM outputs the probability distribution of the [MASK] position, and gives the label word and the corresponding class prediction probability according to the language model.

[0051] The differences between P-tuning v2 and P-tuning v1 are as follows: (1) BiLSTM or MLP is no longer used to represent pseudo tokens, and the pre-trained model word embedding is no longer replaced. Instead, the parameters of the deep model corresponding to the pseudo token are directly fine-tuned; (2) For the continuous prompt of the pseudo token, a multi-task method is adopted; (3) P-tuning v2 can output the sentence-level class in the [CLS] part, as well as the token-level class at each token position. This improves the performance in tasks that require high reasoning and understanding, such as sequence labeling and text classification.

[0052] The present invention uses PV2-Lora fine-tuning technology to fine-tune the ChatGLM-6B benchmark model. PV2-Lora fine-tuning is an improved large model fine-tuning method, which combines the two mainstream large model fine-tuning methods at present, namely P-Tuning v2 and Lora fine-tuning. Specifically, PV2-Lora fine-tunes the model by introducing Lora bypass into the P-Tuning v2 fine-tuning model, freezing the benchmark model parameters during the fine-tuning process and only training the encoder and Lora bypass of P-Tuning v2.

[0053] Specifically, S2 is as follows: select the ChatGLM-6B benchmark model, freeze the benchmark model parameters, convert the pre-hospital emergency text into a word embedding vector through the model's embedding layer, introduce the trainable parameters of P-tuning v2, generate a continuous embedding sequence as the model input vector, and introduce the Lora bypass containing a low-rank matrix into the model's self-attention layer. Minimize the loss function to obtain the minimum loss, back-propagate to update the parameter value, and implement model fine-tuning. The PV2-Lora fine-tuning architecture is as follows: Figure 1 shown.

[0054] To implement Pv2Lora fine-tuning in the ChatGLM-6B benchmark model, it is necessary to introduce the Lora bypass and the trainable parameters of P-tuning v2 in the model. Specifically, for the self-attention layer in the ChatGLM-6B benchmark model, the Lora bypass is constructed by constructing low-rank matrices A and B to replace the Q, K, and V matrices in the attention mechanism. At the same time, the PrefixEncoder module is added to the ChatGLM-6B benchmark model to introduce the trainable parameters in P-tuning v2.

[0055] Specifically, the introduction of trainable parameters of P-tuning v2 is achieved by adding a PrefixEncoder module to the ChatGLM-6B benchmark model, which consists of two layers of perceptrons.

[0056] During the fine-tuning process, the input text is converted into a word embedding vector through the embedding layer of the ChatGLM-6B benchmark model, and then the virtual prompt generated by the PrefixEncoder module is embedded in front of the word embedding vector to form a continuous embedding sequence, which is used as the input of the model. Compared with Lora fine-tuning, in the self-attention layer of the ChatGLM-6B benchmark model, the input vector will become the above-mentioned continuous embedding sequence (while the input in Lora fine-tuning is only the word embedding vector converted by the embedding layer). Finally, the obtained output and the true label are used to obtain the minimum loss through the minimum loss function, and the minimum loss is used to calculate the value of the trainable parameter through the back propagation of the ChatGLM-6B benchmark model.

[0057] The following is an example of the implementation process of the PV2-Lora fine-tuning technology:

[0058] Assume that the pre-trained language model is M and the parameters are θ .

[0059] (1) Input x Its word embedding is represented as x= [ x 1 ,x 2 ,…,x n ],in x i is the first i word embedding representation.

[0060] (2) Construct a learnable parameter vector through P-tuning v2 p Stands for soft prompt, p is a fixed length vector represented by p= [ p 1 ,p 2 ,…,p m ].

[0061] (3) x and p Connect them to form a new input x ’ = [ p ; x].

[0062] (4) In Lora fine-tuning, the model is efficiently tuned by constructing a bypass containing low-rank matrices A and B. The formula of this process is expressed as h=M θ ( x ) +B × f ( A × M θ ( x )),in h represents the model output, f is a nonlinear activation function (such as Gelu), A, B is the introduced low-rank matrix. After combining with P-tuning v2, a new input is formed x’ , the input is processed through the model and Lora's modification is applied, then the output formula of the model becomes h'=M θ ( p , x ) +B × f ( A × M θ ( p , x )),in M θ (p , x) Indicates that the model is input x ’ = [ p ; x ] on the output.

[0063] (5) Final model output y Will be h’ It is obtained through the output layer of the model. If the output layer of the model is a linear layer, the final output of the model is y = W out × h ’ + b out ,in W out and b out Represent the weight and bias of the output layer respectively.

[0064] (6) The goal of model fine-tuning is to minimize the loss function L , the minimum loss is calculated by back propagation about p , A and BThe gradient of , and update these parameters. Its formula is expressed as min L ( y , y true ),in y true Represents the true label. It should be noted that in the actual training process, the original parameters of the pre-trained model need to be fixed θ .

[0065] Before starting model fine-tuning, you need to define hyperparameters. Specifically, the hyperparameters in S2 include learning rate, batch size, natural language instruction length, maximum length of input sequence, maximum length of output text, low-rank matrix rank, Lora fine-tuning scaling factor, etc. The key parameters for fine-tuning in this embodiment are set as follows:

[0066] Learning rate: 1e-2

[0067] Batch size (batch_size): 10

[0068] Natural language instruction length (pre_seq_len): 10

[0069] Maximum length of input sequence (max_source_length): 217

[0070] Maximum length of output text (max_target_length): 6

[0071] Low rank matrix rank size (lora_rank): 8

[0072] Lora fine-tuning scaling factor (lora_alpha): 32

[0073] S3: Use the fine-tuning model to complete the classification and labeling of the pre-hospital emergency medical records to be processed and obtain the disease ICD code.

[0074] After the model is fine-tuned, the user inputs the pre-hospital emergency text to be annotated according to actual needs. The fine-tuning model will annotate the text to be annotated based on the ICD code, and return the annotated text. The user can perform subsequent treatment based on the ICD code given by the fine-tuning model.

[0075] <Evaluation and Analysis of Classification Labeling>

[0076] The evaluation indicators of the classification and labeling results of the method of the present invention include BLEU, ROUGE, accuracy and F1 score.

[0077] BLEU (Bilingual Evaluation Understudy) is an indicator used to evaluate the difference between sentences generated by the model and actual sentences. The value range is [0, 1]. The closer to 1, the smaller the difference between the generated sentence and the actual sentence. The formula of BLEU is:

[0078]

[0079] Recall is an indicator used to evaluate the performance of classification models, especially in binary or multi-classification, and is often used to detect the model's ability to find relevant instances. The formula is as follows:

[0080]

[0081] Accuracy is the most intuitive performance indicator. It calculates the proportion of all correctly classified predictions to the total number of predictions. The formula is as follows:

[0082]

[0083] The F1 score is an indicator that uses the harmonic mean to combine the recall rate and the precision rate. Its formula is as follows:

[0084]

[0085]

[0086] Among them, TP (True Positives) represents the number of features that are predicted to be positive samples and are actually positive samples; TN (True Negatives) represents the number of features that are predicted to be negative samples and are actually negative samples; FP (False Positives) represents the number of features that are predicted to be positive samples and are actually negative samples; FN (False Negatives) represents the number of features that are predicted to be negative samples and are actually positive samples.

[0087] In order to verify the effect of the Pv2-Lora fine-tuning method on improving model performance and the advantages of the ChatGLM-6B benchmark model in the pre-hospital emergency text classification task, comparative experiments were designed respectively. The results are shown in Tables 1 and 2.

[0088] Table 1

[0089] Improvement methods BLEU Recall Accuracy F1 ChatGLM-6B benchmark model 0.469 0.498 0.507 0.476 ChatGLM-6B benchmark model + Lora 0.656 0.708 0.728 0.674 ChatGLM-6B benchmark model + P-tuningv2 0.675 0.724 0.733 0.693 ChatGLM-6B benchmark model + Pv2-Lora 0.761 0.815 0.826 0.773

[0090] By testing the performance of the ChatGLM-6B benchmark model on different fine-tuning methods, it can be seen that the performance of the model fine-tuned with Pv2-Lora is significantly improved compared to the benchmark model without fine-tuning and the model fine-tuned with only Lora or only P-tuningV2, indicating that the fine-tuned model can better adapt to the pre-hospital emergency classification task in the present invention. This may be because: (1) P-tuning v2 fine-tuning enhances the adaptability of the model to specific tasks to a certain extent by introducing learnable prompt vectors, making up for the shortcomings of Lora fine-tuning in adaptability. (2) The combination of P-tuning v2 and Lora improves the generalization ability of the model while maintaining efficient parameters. This shows that the Pv2-Lora fine-tuning method is effective in improving model performance.

[0091] Table 2

[0092] Benchmark Model BLEU Recall Accuracy F1 Bert 0.589 0.612 0.633 0.606 LlAMA 0.755 0.798 0.817 0.761 DialoGPT 0.625 0.644 0.663 0.630 ChatGLM-6B 0.761 0.815 0.826 0.773

[0093] By testing the performance of various mainstream benchmark models using pre-hospital emergency data combined with the Pv2Lora fine-tuned model, it can be seen that the classification effect of the ChatGLM-6B benchmark model in the pre-hospital emergency text classification task is significantly better than other models.

[0094] An electronic device comprises: at least one processor, and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor executes the described method.

[0095] A storage medium stores a computer program, which, when executed by a processor, implements the method described.

[0096] The present invention also provides an electronic device, comprising: at least one processor, and a memory connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor, so that the at least one processor executes the pre-hospital emergency text classification and annotation method based on the ChatGLM model. The electronic device can be any terminal device including a mobile phone, a laptop computer, a desktop computer, a tablet computer, a PDA (Personal Digital Assistant), a POS (Point of Sales), a car computer, etc.

[0097] The present invention also provides a storage medium on which a computer program is stored. When the program is executed by a processor, the pre-hospital emergency text classification and annotation method based on the ChatGLM model is implemented.

[0098] Through the description of the above implementation mode, the technicians in the relevant field can clearly understand that the present invention can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present invention, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0099] The present invention also provides a computer program product, which includes a computer program. When the program is executed by a processor, the method described above is implemented.

[0100] A computer program (which may also be referred to or described as a program, software, software application, module, software module, script or code) may be written in any form of programming language, including compiled or interpreted languages ​​or declarative or procedural languages, and the computer program may be deployed in any form, including as a standalone program or as a module, component, subroutine or other unit suitable for use in a computing environment. A computer program may, but need not, correspond to a file in a file system. A program may be stored in a portion of a file that stores other programs or data, for example, one or more scripts stored in the following: in a markup language document; in a single file dedicated to a related program; or in multiple collaborative files, for example, files storing one or more modules, subroutines or code portions. A computer program may be deployed to execute on one or more computers, the computers being located in one place, or distributed to multiple locations and interconnected through a communication network. The processes and logic flows described in this specification may be performed by one or more programmable computers that execute one or more computer programs to run functions by computing input data and generating output.

[0101] The number of devices and processing scales described here are used to simplify the description of the present invention. Applications, modifications and variations of the present invention will be obvious to those skilled in the art.

[0102] Although the embodiments of the present invention have been disclosed as above, they are not limited to the applications listed in the specification and the implementation modes, and they can be fully applied to various fields suitable for the present invention. For those familiar with the art, additional modifications can be easily implemented. Therefore, without departing from the general concept defined by the claims and the scope of equivalents, the present invention is not limited to the specific details and the illustrations shown and described herein.

Claims

1. A pre-hospital emergency text classification and annotation method based on the ChatGLM model, characterized in that: include: S1: Obtain historical data of pre-hospital emergency medical records, obtain pre-hospital emergency text after data pre-processing, manually annotate disease ICD codes, and obtain pre-hospital emergency text dataset; S2: Select the ChatGLM-6B benchmark model, freeze the benchmark model parameters, convert the pre-hospital emergency text into a word embedding vector through the model's embedding layer, introduce the trainable parameters of P-tuning v2, generate a continuous embedding sequence as the model input vector, and introduce the Lora bypass containing a low-rank matrix into the model's self-attention layer. Minimize the loss function to obtain the minimum loss, back-propagate to update the parameter value, and implement model fine-tuning. The introduction of trainable parameters of P-tuning v2 is achieved by adding a PrefixEncoder module to the ChatGLM-6B baseline model. The PrefixEncoder module consists of two layers of perceptrons. The pre-trained language model is M, and the parameters are θ , the original parameters of the pre-trained model need to be fixed θ ; (1) Input x Its word embedding is represented as x= [ x 1 ,x 2 ,…,x n ],in x i is the first i word embedding representation; (2) Construct a learnable parameter vector through P-tuning v2 p Stands for soft prompt, p is a fixed length vector represented by p= [ p 1 ,p 2 ,…,p m ]; (3) x and p Connect them to form a new input x ’ = [ p ; x ]; (4) In Lora fine-tuning, the model is efficiently tuned by constructing a bypass containing low-rank matrices A and B. The formula of this process is expressed as h=M θ ( x ) +B × f ( A × M θ ( x )),in h represents the model output, f is the nonlinear activation function Gelu, A, B The low-rank matrix introduced, combined with P-tuning v2, forms a new input x’ , the input is processed through the model and Lora's modification is applied, then the output formula of the model becomes h'=M θ ( p , x ) +B × f ( A × M θ ( p , x )) ,in M θ (p, x) Indicates that the model is input x ’ = [ p ; x ] on the output; (5) Final model output y Will be h’ It is obtained through the output layer of the model. If the output layer of the model is a linear layer, the final output of the model is y = W out × h ’ + b out ,in W out and b out Represent the weight and bias of the output layer respectively; (6) The goal of model fine-tuning is to minimize the loss function L , the minimum loss is calculated by back propagation about p , A and B The gradient of , and update these parameters, the formula is expressed as min L ( y , y true ),in y true represents the true label; S3: Use the fine-tuning model to complete the classification and labeling of the pre-hospital emergency medical records to be processed and obtain the disease ICD code.

2. The pre-hospital emergency text classification and labeling method based on the ChatGLM model as claimed in claim 1, characterized in that: Data preprocessing in S1 includes information desensitization, information screening, and text cleaning.

3. The pre-hospital emergency text classification and annotation method based on the ChatGLM model as claimed in claim 1, characterized in that: The pre-hospital emergency text dataset in S1 is divided into training set, test set, and validation set.

4. The pre-hospital emergency text classification and labeling method based on the ChatGLM model as claimed in claim 1, characterized in that: The hyperparameters in S2 include learning rate, batch size, natural language instruction length, maximum length of input sequence, maximum length of output text, low-rank matrix rank, and Lora fine-tuning scaling factor.

5. An electronic device, characterized in that include: At least one processor, and a memory communicatively connected to the at least one processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor performs the method described in any one of claims 1 to 4.

6. A storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method described in any one of claims 1 to 4 is implemented.

7. A computer program product comprising a computer program, characterized in that When the program is executed by a processor, the method described in any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Pre-hospital first-aid information processing device

    CN113761201A

  • ICD code prediction method and system based on joint learning and denoising mechanism

    CN114023412A

  • Text information processing method and device, equipment, storage medium and program product

    CN117076668A

  • Wrong question analysis and test question recommendation system and method based on large language model

    CN117150151A

  • Medical disease code mapping method and device based on big language model reasoning

    CN117235275A