Text processing method, device, equipment, medium and product based on large model
By decomposing the recognition and classification process of large language models and combining the capabilities of general and specialized models, the problem of insufficient accuracy of information extraction in text processing in specific fields is solved, achieving higher accuracy and recognition and classification effects.
Patent Information
- Application Number
- CN202411136208.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2044-08-19
AI Technical Summary
There is still room for improvement in the accuracy of information extraction in text processing in specific domains, especially the hallucination problems caused by mutual interference of recognition and classification capabilities.
The general big model is used to identify and classify entity units, and combined with the ability to identify large models and classify large models, the decomposition and extraction task is the identification and classification process, and the advantages of different models are used to reduce the ability interference between models and improve accuracy.
By decomposing the identification and classification process, the capabilities of different large models are utilized to improve the accuracy of text processing, reduce interference between models, and improve the accuracy of information extraction.
Smart Images

Figure CN118656479B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to technical fields such as artificial intelligence and large language models, and the present application relates to a text processing method, device, equipment, medium and product based on a large model. Background Art
[0002] In recent years, large language models (LLMs) have powerful processing capabilities and have developed rapidly in various fields. Text processing methods based on large models have emerged.
[0003] However, there are still some shortcomings when using large models to process texts in specific fields. For example, when extracting information in a specific field, the accuracy of information extraction still has a lot of room for improvement. Therefore, how to use large models to better process text is still one of the problems that need to be solved in this field. Summary of the invention
[0004] The present application provides a text processing method, device, equipment, medium and product based on a large model. The technical solution is as follows:
[0005] On the one hand, the present application provides a text processing method based on a large model, the method comprising:
[0006] Get the text to be processed;
[0007] Based on the text to be processed, a general large model is used to perform entity unit recognition on the text to be processed to obtain a first probability distribution corresponding to a first dictionary, and a recognition large model is used to perform entity unit recognition on the text to be processed to obtain a second probability distribution corresponding to the first dictionary, wherein the first dictionary includes a plurality of candidate entity units;
[0008] Based on the first probability distribution and the second probability distribution, obtaining a target entity unit in the text to be processed;
[0009] Based on the text to be processed and the target entity unit, the target entity unit is classified by the general large model to obtain a third probability distribution corresponding to a second dictionary, and the target entity unit is classified by the classification large model to obtain a fourth probability distribution corresponding to the second dictionary, wherein the second dictionary includes a plurality of candidate categories;
[0010] Based on the third probability distribution and the fourth probability distribution, obtaining a target category of the target entity unit;
[0011] Based on the target entity unit and the target category of the target entity unit, an extraction result of the text to be processed is obtained.
[0012] On the other hand, the present application provides a text processing device based on a large model, comprising:
[0013] A first acquisition module, used to acquire the text to be processed;
[0014] A first recognition module is used to perform entity unit recognition on the text to be processed based on the text to be processed by using a general large model to obtain a first probability distribution corresponding to a first dictionary, and to perform entity unit recognition on the text to be processed by using a recognition large model to obtain a second probability distribution corresponding to the first dictionary, wherein the first dictionary includes a plurality of candidate entity units;
[0015] A first obtaining module, used for obtaining a target entity unit in the text to be processed based on the first probability distribution and the second probability distribution;
[0016] A first classification module is used for classifying the target entity unit using the general large model based on the text to be processed and the target entity unit to obtain a third probability distribution corresponding to a second dictionary, and classifying the target entity unit using the classification large model to obtain a fourth probability distribution corresponding to the second dictionary, wherein the second dictionary includes a plurality of candidate categories;
[0017] A second obtaining module, configured to obtain a target category of the target entity unit based on the third probability distribution and the fourth probability distribution;
[0018] The third obtaining module is used to obtain the extraction result of the text to be processed based on the target entity unit and the target category of the target entity unit.
[0019] In a possible implementation, the recognition large model is trained based on the similarity between the first predicted entity unit and the entity label of each first sample; the classification large model is trained based on the similarity between the second predicted category and the category label of each second sample;
[0020] The general large model is trained based on the similarity between the third extraction results of each third sample and the sample label, the third extraction results include a third predicted entity unit and a third category, and the sample label includes an entity label and a category label of the third sample.
[0021] In one possible implementation, the device further includes:
[0022] A second classification module is used to perform entity unit recognition on the text to be processed based on the text to be processed by using a classification model to obtain a fifth probability distribution corresponding to the first dictionary;
[0023] A second recognition module, configured to classify the target entity unit using the recognition large model based on the text to be processed and the target entity unit, so as to obtain a sixth probability distribution corresponding to the second dictionary;
[0024] Wherein, when the first obtaining module obtains the target entity unit in the to-be-processed text based on the first probability distribution and the second probability distribution, it is used to:
[0025] Based on the first probability distribution, the second probability distribution and the fifth probability distribution, acquiring the target entity unit;
[0026] Wherein, when the second obtaining module obtains the target category of the target entity unit based on the third probability distribution and the fourth probability distribution, it is used to:
[0027] Based on the third probability distribution, the fourth probability distribution and the sixth probability distribution, a target category corresponding to the target entity unit is obtained.
[0028] In one possible implementation, the device further includes:
[0029] The second acquisition module is used to obtain the prompt text of the extraction task;
[0030] The prompt text includes recognition prompt words and classification prompt words, the recognition prompt words indicate to recognize entity units in the target field in the text to be processed, and the classification prompt words indicate to classify the recognized entity units.
[0031] In a possible implementation, the first probability distribution is obtained based on the text to be processed and the recognition prompt word, and using a general large model to perform entity unit recognition on the text to be processed; the second probability distribution is obtained based on the text to be processed and the recognition prompt word, and using a recognition large model to perform entity unit recognition on the text to be processed;
[0032] Among them, the third probability distribution is obtained by classifying the target entity unit based on the text to be processed, the target entity unit and the classification prompt words using a general large model; the fourth probability distribution is obtained by classifying the target entity unit based on the text to be processed, the target entity unit and the classification prompt words using a classification large model.
[0033] In a possible implementation, the first obtaining module is specifically configured to:
[0034] determining a first recognition error of the second probability distribution based on a similarity between the first probability distribution and the second probability distribution;
[0035] determining a first adjusted probability for the first probability distribution based on a difference between the second probability distribution and a first identification error;
[0036] Adjusting the first probability distribution based on the first adjustment probability to obtain a first target probability distribution;
[0037] Based on the first target probability distribution, the target entity unit is obtained.
[0038] In a possible implementation, the first obtaining module is specifically configured to:
[0039] determining a first recognition error of the second probability distribution based on a similarity between the first probability distribution and the second probability distribution;
[0040] determining a second recognition error of the fifth probability distribution based on a similarity between the first probability distribution and a fifth probability distribution;
[0041] determining a first adjusted probability for the first probability distribution based on a difference between the second probability distribution and the first identification error;
[0042] adjusting the first probability distribution based on the first adjusted probability;
[0043] determining a second target probability distribution based on a difference between the adjusted first probability distribution and the second recognition error;
[0044] Based on the second target probability distribution, the target entity unit is obtained.
[0045] In a possible implementation, the first probability distribution and the second probability distribution are obtained in the following manner:
[0046] Based on the text to be processed, a general large model is used to perform entity unit recognition on the text to be processed to obtain a first initial probability distribution corresponding to a first dictionary, and a recognition large model is used to perform entity unit recognition on the text to be processed to obtain a second initial probability distribution corresponding to the first dictionary;
[0047] The first initial probability distribution includes the first initial probability of each candidate entity unit, and the second initial probability includes the second initial probability of each candidate entity unit;
[0048] Based on the first initial probability distribution and the second initial probability distribution, determining, from the candidate entity units, a target candidate unit whose first initial probability and second initial probability are both not lower than a target threshold;
[0049] The probabilities corresponding to the non-target candidate units in the first initial probability distribution and the second initial probability distribution are eliminated respectively to obtain the first probability distribution and the second probability distribution.
[0050] In a possible implementation, the text to be processed includes a plurality of target entity units, and the extraction result includes a plurality of target entity units and target categories of the target entity units;
[0051] The extraction result is generated by executing n tasks, each task is a recognition task or a classification task, and the generated text of each task is a target entity unit or a target category;
[0052] The execution process of the i-th task includes:
[0053] Based on the generated text of the i-1th task, determine the text type of the text to be generated, the text type is a recognition type or a classification type, and the text type corresponding to the first task is a recognition type;
[0054] Based on the text to be processed and the generated text of the previous i-1 tasks, a general large model is used to obtain a general probability distribution, a recognition large model is used to obtain a recognition probability distribution, and a classification large model is used to obtain a classification probability distribution;
[0055] Wherein, the general probability distribution is the first probability distribution or the third probability distribution, the recognition probability distribution is the second probability distribution or the sixth probability distribution, and the classification probability distribution is the fourth probability distribution or the fifth probability distribution;
[0056] Based on the general probability distribution, the recognition probability distribution and the classification probability distribution, a generated text for the i-th task is generated.
[0057] In a possible implementation, the device further includes a first training module, and the first training module, when training the recognition large model, includes:
[0058] A first acquisition unit is used to acquire a first training set, wherein the first training set includes a plurality of first sample texts with sample labels, and the sample label of each first sample includes an entity label of the first sample;
[0059] A first recognition unit is used to perform entity unit recognition on each first sample based on each first sample by using a recognition large model to be trained to obtain a first predicted entity unit of each first sample;
[0060] a first classification unit, configured to classify the first prediction entity unit based on each first sample and the first prediction entity unit by using the recognition large model to be trained to obtain a first prediction category of the first prediction entity unit, and obtain an extraction result of each first sample based on the first prediction entity unit and the first prediction category of each first sample;
[0061] The first training unit is used to determine a first training loss based on the similarity between the first predicted entity unit and the entity label of each first sample, and fine-tune the model parameters of the recognition large model to be trained based on the first training loss.
[0062] In a possible implementation, the device further includes a second training module, and the second training module, when training the large classification model, includes:
[0063] A second acquisition unit is used to acquire a second training set, where the second training set includes a plurality of second samples with sample labels, and the sample label of each second sample includes a category label of each entity label of the second sample;
[0064] A second recognition unit is used to perform entity unit recognition on each second sample based on each second sample by using the classification large model to be trained to obtain a second predicted entity unit of each second sample;
[0065] a second classification unit, configured to classify the second prediction entity unit based on each second sample and the second prediction entity unit by using the classification large model to be trained to obtain a second prediction category of the second prediction entity unit, and obtain an extraction result of each second sample based on the second prediction entity unit and the second prediction category of each second sample;
[0066] The second training unit is used to determine a second training loss based on the similarity between the second predicted category and the category label of each second sample, and fine-tune the model parameters of the large classification model to be trained based on the second training loss.
[0067] In a possible implementation, the device further includes a third training module, and the third training module, when training the general large model, includes:
[0068] a third acquisition unit, configured to acquire a third training set, wherein the third training set includes a plurality of third samples with sample labels, wherein the sample label of each third sample includes an entity label of the third sample and a category label of each entity label;
[0069] A third recognition unit is used to perform entity unit recognition on each third sample by using a general large model to be trained based on each third sample to obtain a third predicted entity unit of each third sample;
[0070] a third classification unit, configured to classify the third prediction entity unit based on each third sample and the third prediction entity unit by using the general large model to be trained to obtain a third prediction category of the third prediction entity unit, and obtain an extraction result of each third sample based on the third prediction entity unit and the third prediction category of each third sample;
[0071] The third training unit is used to determine a third training loss based on the similarity between the third extraction results of each third sample and the sample label, and fine-tune the model parameters of the general large model to be trained based on the third training loss.
[0072] On the other hand, an electronic device is provided, comprising a memory, a processor and a computer program stored in the memory, wherein the processor executes the computer program to implement the above-mentioned large model-based text processing method.
[0073] On the other hand, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the above-mentioned large model-based text processing method is implemented.
[0074] On the other hand, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the large model-based text processing method described above is implemented.
[0075] The beneficial effects of the technical solution provided by the embodiment of the present application are:
[0076] The text processing method based on the large model of the present application is based on the text to be processed, and the general large model is used to identify the entity unit to obtain the first probability distribution, and the recognition large model is used to identify the entity unit to obtain the second probability distribution. Based on the first probability distribution and the second probability distribution, the target entity unit in the text to be processed is obtained; so that during recognition, the recognition ability of the recognition large model can be used to reduce the illusion caused by the classification ability in the recognition task of the general large model, and improve the accuracy of recognition. In addition, based on the text to be processed and the target entity unit, the general large model is used to classify the target entity unit to obtain a third probability distribution, and the classification large model is used to classify to obtain a fourth probability distribution, and the target category is obtained based on the third probability distribution and the fourth probability distribution; so that during classification, the classification ability of the classification large model can be further used to reduce the illusion caused by the recognition ability in the classification task of the general large model, and improve the accuracy of classification. By decomposing the extraction into different processes of recognition and classification, and rotating the recognition ability or classification ability of different large models in different processes, the accuracy of the extraction result can be further improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0077] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in describing the embodiments of the present application are briefly introduced below.
[0078] Figure 1 A schematic diagram of an implementation environment of a large model-based text processing method provided in an embodiment of the present application;
[0079] Figure 2 A flowchart of a text processing method based on a large model provided in an embodiment of the present application;
[0080] Figure 3 A schematic diagram of a process of a fine-tuning stage provided in an embodiment of the present application;
[0081] Figure 4 A schematic diagram of a process of the reasoning stage provided in an embodiment of the present application;
[0082] Figure 5 A flowchart of an online consultation using a large model provided in an embodiment of the present application;
[0083] Figure 6 A schematic diagram of an online medical consultation scenario provided in an embodiment of the present application;
[0084] Figure 7 A medical question-answering flow chart using a large model provided in an embodiment of the present application;
[0085] Figure 8 A schematic diagram of a medical question-and-answer scenario provided in an embodiment of the present application;
[0086] Fig. 9 A schematic diagram of an online conference scenario provided in an embodiment of the present application;
[0087] Fig.10 A schematic diagram of a smart shopping guide scenario provided in an embodiment of the present application;
[0088] Fig.11 A schematic diagram of a scenario of an interview activity provided in an embodiment of the present application;
[0089] Fig.12 A schematic diagram for comparing experimental results provided in an embodiment of the present application;
[0090] Fig.13 A schematic diagram of the structure of a text processing device based on a large model provided in an embodiment of the present application;
[0091] Fig.14 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0092] The embodiments of the present application are described below in conjunction with the drawings in the present application. It should be understood that the implementation methods described below in conjunction with the drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions of the embodiments of the present application.
[0093] Those skilled in the art will appreciate that, unless otherwise stated, the singular forms "a", "an", "said", and "the" used herein may also include plural forms. It should be further understood that the terms "include" and "comprise" used in the embodiments of the present application mean that the corresponding features can be implemented as the presented features, information, data, steps, operations, elements and / or components, but do not exclude the implementation as other features, information, data, steps, operations, elements, components and / or combinations thereof supported by the technical field.
[0094] It is understandable that in the specific implementation of the present application, any data related to the object, such as the to-be-processed text of the object, the extraction results of the to-be-processed text, the conversation text, the text processing request, etc., when the above embodiments of the present application are applied to specific products or technologies, it is necessary to obtain the permission or consent of the object, and the collection, use and processing of the relevant data need to comply with the relevant laws, regulations and standards of the relevant countries and regions. In other words, if any data related to the object is involved in the above techniques in the embodiments of the present application, these data need to be obtained with the authorization and consent of the object and in compliance with the relevant laws, regulations and standards of the country and region.
[0095] Figure 1 A schematic diagram of the implementation environment of a text processing method based on a large model provided in this application. Figure 1 As shown, the implementation environment includes: a server 101 and a terminal 102 .
[0096] The server 101 can provide a text processing service based on a large language model (LLM), which is an information extraction service for the text to be processed. The user can trigger a text processing request on the terminal 102, and the terminal 102 sends the text processing request to the server 101, and the text processing request carries the user's text to be processed. The server 101 extracts information based on the text processing service and returns the extraction result of the text to be processed to the terminal 102.
[0097] The information extraction may be to identify entity units in the text to be processed and classify the entities, and the extraction result may include entity units and categories. The entity unit may be an entity in a specific field.
[0098] The large model-based text processing method provided in the present application can be applied to the medical field, and the specific field can be the medical field, that is, information extraction can be to identify and classify entity units in the medical field in the text to be processed.
[0099] In one possible application scenario, the powerful capabilities of the big model can be used to extract medical information to cope with the complexity of medical clinical scenarios. Specifically, text processing services can be used to extract medical information from texts in the medical field. For example, in a medical consultation scenario, for the conversation text between a doctor and a patient, a big model can be used to extract entity units and entity unit categories in the conversation text. For example, an entity unit can be a symptom object, and a category can be a predefined negative, positive, etc. For example, the medical information extraction result can be: "Fever: Positive", "Dizziness: Negative".
[0100] Exemplarily, the terminal 102 may be configured with an application platform supporting text processing services, and the application platform may be an independent application or a program plug-in configured in an independent application. The server 101 may be a background server of the application platform. The terminal 102 and the server 101 may exchange data based on the application platform.
[0101] For example, the application platform may be an application platform in the medical field; for example, an intelligent medical platform that supports online medical consultation, a medical question-and-answer system, an AI assistant platform that assists doctors in diagnosis and treatment, etc.
[0102] It should be noted that the server 101 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server or server cluster that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, and big data and artificial intelligence platforms. The terminal 102 can be a smart phone, a tablet computer, a laptop computer, a digital broadcast receiver, a desktop computer, a vehicle terminal (such as a vehicle navigation terminal, a vehicle computer, etc.), a smart speaker, a smart watch, etc. The terminal and the server can be directly or indirectly connected via wired or wireless communication, and can also be determined based on the actual application scenario requirements, which is not limited here.
[0103] Figure 2 The flowchart of a text processing method based on a large model provided in the embodiment of the present application is shown in FIG. The execution subject of the method can be any electronic device, which can be a user terminal or a server. Figure 2 As shown, the method includes the following steps 201-206.
[0104] Step 201: The electronic device obtains a text to be processed.
[0105] Exemplarily, the text to be processed may include entity units in the target domain. In the present application, a large language model may be used to extract information in the target domain from the text to be processed.
[0106] In one possible manner, the target domain may be a medical domain; entity units in the medical domain may include but are not limited to symptoms, such as fever, stomachache, abdominal distension, and the like.
[0107] Among them, the present application can decompose the extraction task into a recognition task and a classification task. The recognition task is used to recognize the entity units in the processed text to obtain the target entity units; and the classification task is used to classify the identified target entity units to obtain the target category of the target entity units, thereby obtaining the extraction result based on the target entity units and the target category. The following steps will introduce the extraction process.
[0108] In one possible scenario, the text to be processed may be a conversation text between a doctor and a patient during a medical consultation. The text processing method of this application can be used to extract medical information from the conversation text during the medical consultation using a large model; specifically, the symptoms in the conversation text can be generated by performing a recognition task, and the categories of the symptoms can be generated by performing a classification task. For example, the extraction results may be: "Fever: positive", "Dizziness: negative".
[0109] Step 202: Based on the text to be processed, the electronic device uses a general large model to perform entity unit recognition on the text to be processed to obtain a first probability distribution corresponding to the first dictionary, and uses a recognition large model to perform entity unit recognition on the text to be processed to obtain a second probability distribution corresponding to the first dictionary.
[0110] The first dictionary includes a plurality of candidate entity units. The first probability distribution includes a first probability that each candidate entity unit is included in the text to be processed, and the second probability distribution includes a second probability that each candidate entity unit is included in the text to be processed. That is, for the recognition task, the probability distribution (first probability distribution, second probability distribution) includes the probability that the entity unit predicted by the model (general large model, recognition large model) is the probability of each candidate entity unit in the preconfigured entity unit set (candidate entity dictionary).
[0111] It is understandable that the text to be processed may include one or more entity units in the target domain. When the entity units in different target domains are identified through the large model, for example, when the entity units in one of the target domains are identified, the probability distribution of each candidate entity unit corresponding to the target domain can be predicted, or the probability of each candidate entity unit corresponding to each target domain can be predicted. The embodiments of the present application do not limit the domain of the entity units to be identified, the number of domains, etc.
[0112] The first probability distribution and the second probability distribution are the recognition probability distributions of the general large model and the recognition large model, respectively. The first probability distribution and the second probability distribution may correspond to the same candidate entity units. For example, a dictionary including a large number of entity units may be pre-configured. When performing a recognition task, each entity unit in the dictionary is used as a candidate entity unit. The general large model and the recognition large model are used to predict the probability that each candidate entity unit in the dictionary is an entity unit in the text to be processed.
[0113] The probabilities of the same candidate entity unit in the first probability distribution and the second probability distribution may be different or the same. For example, for the i-th candidate entity unit among the candidate entity units in the dictionary, the probability of the i-th candidate entity unit in the first probability distribution is P i1 , the probability of the i-th candidate entity unit in the second probability distribution is P i2 , P i1 With P i2 The sizes may be the same or different.
[0114] In one possible manner, the first probability distribution and the second probability distribution are obtained by further constraining the probability distributions directly output by the general large model and the recognition large model. Optionally, the implementation of step 202 may include the following steps 2021-2023:
[0115] Step 2021: Based on the text to be processed, the general large model is used to perform entity unit recognition on the text to be processed to obtain a first initial probability distribution corresponding to the first dictionary, and the recognition large model is used to perform entity unit recognition on the text to be processed to obtain a second initial probability distribution corresponding to the first dictionary;
[0116] The first initial probability distribution includes the first initial probability of each candidate entity unit, and the second initial probability includes the second initial probability of each candidate entity unit;
[0117] Step 2022: Based on the first initial probability distribution and the second initial probability distribution, determine, from the candidate entity units, a target candidate unit whose first initial probability and second initial probability are both not lower than a target threshold;
[0118] Step 2023: Eliminate the probabilities corresponding to the non-target candidate units in the first initial probability distribution and the second initial probability distribution, respectively, to obtain the first probability distribution and the second probability distribution.
[0119] It should be noted that the first initial probability distribution and the second initial probability distribution are initial probability distributions directly output by the general large model and the recognition large model, respectively, and the initial probability distributions can be constrained by pre-configured constraints. Among them, the initial probabilities of candidate entity units that do not meet the constraints can be eliminated to constrain the probability values in the first probability distribution and the second probability distribution within a certain range.
[0120] Among them, the constraint condition may be: the initial probability is not lower than the target threshold. The target threshold may be configured based on needs, and this application does not limit this. For example, the target threshold corresponding to each initial probability distribution may be configured, and the target threshold may be 40%, 30%, etc. of the maximum initial probability in the corresponding initial probability distribution.
[0121] The method for determining each target candidate unit may include the following steps:
[0122] The electronic device selects, from each candidate entity unit of the first initial probability distribution, each first candidate entity unit whose first initial probability is not less than a first target threshold, to obtain a first entity set;
[0123] And, from each candidate entity unit of the second initial probability distribution, each second candidate entity unit whose second initial probability is not less than a second target threshold is screened out to obtain a second entity set;
[0124] And, performing an intersection operation on the first entity set and the second entity set to obtain each third candidate entity unit commonly included in the first entity set and the second entity set, and taking each third candidate entity unit as a target candidate unit.
[0125] Among them, the first target threshold and the second target threshold can be the same or different, and can be configured based on needs, and this application does not limit this.
[0126] The non-target candidate units refer to candidate entity units other than the target candidate units in each initial probability distribution (the first initial probability distribution and the second initial probability distribution).
[0127] Among them, eliminating the probability of non-target candidate units refers to eliminating or filtering out the initial probabilities of non-target candidate units in each initial probability distribution. For example, the first initial probability value of the non-target candidate unit in the first initial probability distribution can be set to a negative infinite value to obtain a first probability distribution; and the second initial probability value of the non-target candidate unit in the second initial probability distribution can be set to a negative infinite value to obtain a second probability distribution.
[0128] Based on this, the probability values in the first probability distribution and the second probability distribution can be constrained within a certain range to avoid certain candidate entity units with significant differences in the two probability distributions. For example, the value of the same candidate entity unit in the first probability distribution is too large and the value in the second probability distribution is too small. This avoids errors caused by the significant difference in subsequent comparative decoding and improves the reliability of text processing.
[0129] Step 203: The electronic device obtains a target entity unit in the text to be processed based on the first probability distribution and the second probability distribution.
[0130] The electronic device may determine a first target probability distribution by combining the first probability distribution and the second probability distribution, and determine a target entity unit among the candidate entity units based on the first target probability distribution.
[0131] For example, for the i-th candidate entity unit, the target probability of the i-th candidate entity unit in the target probability distribution is P i ; According to the target probabilities of the candidate entity units included in the first target probability distribution, the candidate entity unit with the largest target probability can be selected as the target entity unit.
[0132] In one possible manner, the electronic device may sum the first probability distribution and the second probability distribution to obtain a first target probability distribution.
[0133] For example, the first target probability distribution can be obtained by the following formula:
[0134] ;
[0135] in, represents the first target probability distribution, represents the first probability distribution, represents the second probability distribution, is a hyperparameter. Can represent a general large model or identify model parameters of a large model, Can represent large models, Can represent a general large model.
[0136] In one possible implementation, the recognition big model is trained based on the similarity between the first predicted entity unit and the entity label of each first sample; the classification big model is trained based on the similarity between the second predicted category and the category label of each second sample; the general big model is trained based on the similarity between the third extraction result and the sample label of each third sample, the third extraction result includes the third predicted entity unit and the third category, and the sample label includes the entity label and the category label of the third sample.
[0137] Therefore, by decoupling the model's recognition and classification capabilities during the training phase, the capabilities of different large models in different tasks are independently trained. Specifically, the recognition capability of the recognition large model is optimized, while the classification capability of the classification large model is optimized, so that the capabilities of different large models in specific tasks can be enhanced.
[0138] It should be noted that since the general large model jointly trains the recognition ability and classification ability in the training stage, there may be mutual interference between the recognition ability and the classification ability, which may cause hallucinations caused by the classification ability in the recognition task. In the training stage, the model recognition ability and classification ability are decoupled, and the recognition ability of the large recognition model is optimized, so the second probability distribution is the predicted probability that is not interfered by the classification ability. The first probability distribution and the second probability distribution are used to jointly predict and obtain the first target probability distribution, which helps to alleviate the hallucination problem caused by the classification ability of the general large model in the recognition task. The probability of each candidate entity unit in the obtained first target probability distribution is also more accurate, thereby improving the accuracy of the recognition result.
[0139] In one possible manner, the electronic device may determine the first target probability distribution based on the similarity between the first probability distribution and the second probability distribution. Exemplarily, step 203 may include the following steps 2031-2034:
[0140] Step 2031: Determine a first recognition error of the second probability distribution based on the similarity between the first probability distribution and the second probability distribution;
[0141] Step 2032: Determine a first adjusted probability for the first probability distribution based on a difference between the second probability distribution and the first recognition error;
[0142] Step 2033: adjusting the first probability distribution based on the first adjusted probability to obtain a first target probability distribution;
[0143] Step 2034: Based on the first target probability distribution, obtain the target entity unit.
[0144] The divergence (JSD, Jensen-Shannon) can be used to represent the similarity between the first probability distribution and the second probability distribution. The divergence between the first probability distribution and the second probability distribution can be obtained by the following formula:
[0145] ;
[0146] in, represents the first probability distribution determined using the general large model, which can also be simplified as ; It represents the second probability distribution determined by the identification model, which can also be simplified as ; represents the divergence, which is used to measure the distance between the first probability distribution and the second probability distribution; the smaller the distance, the greater the similarity between the first probability distribution and the second probability distribution.
[0147] In one possible manner, the product of the similarity and the second probability distribution may be used as the first recognition error, and the first recognition error is expressed as: In addition, the difference between the second probability distribution and the first recognition error can be used as the first adjusted probability by the following formula: .
[0148] Exemplarily, the electronic device may determine the first target probability distribution by the following formula based on the similarity between the first probability distribution and the second probability distribution:
[0149] ;
[0150] in, represents the first target probability distribution, represents the first probability distribution, represents the second probability distribution, is a hyperparameter. Among them, if the similarity between the first probability distribution and the second probability distribution is greater, that is, the divergence is smaller, the first recognition error of the second probability distribution is also smaller.
[0151] By adjusting the first probability distribution through the first adjustment probability, the parts with large differences between the first probability distribution and the second probability distribution can be effectively removed. At the same time, the candidate entity units with higher probabilities in the first probability distribution and the first adjusted probability distribution can be integrated, and the parts with higher similarity in the two probability distributions can be more integrated.
[0152] Specifically, through , which can enhance the probability of entity words with higher similarity in the first probability distribution and the second probability distribution, and weaken the probability of entity words with lower similarity.
[0153] Based on this, the expression ability of the first target probability distribution for the real target entity unit can be enhanced, which helps to more accurately find the target entity unit with the highest probability, thereby improving the accuracy of the recognition result.
[0154] Therefore, by using the first probability distribution and the second probability distribution to obtain the target entity unit, the recognition ability of the identification large model can be further utilized on the basis of the recognition ability of the general large model to improve the accuracy of the recognition task. In addition, by subtracting the first recognition error from the second probability distribution to obtain the first adjustment probability, the recognition ability of the identification large model can be effectively corrected, and the first probability distribution is adjusted using the first adjustment probability, so that the recognition ability of the general large model and the identification large model is effectively integrated, thereby improving the accuracy of the first target probability distribution and the accuracy of the recognition result.
[0155] Step 204: Based on the text to be processed and the target entity unit, the electronic device uses the general large model to classify the target entity unit to obtain a third probability distribution corresponding to the second dictionary, and uses the classification large model to classify the target entity unit to obtain a fourth probability distribution corresponding to the second dictionary.
[0156] The second dictionary includes a plurality of candidate categories. The third probability distribution includes a third probability that the category of the target entity unit is each candidate category, and the fourth probability distribution includes a fourth probability that the category of the target entity unit is each candidate category.
[0157] Among them, for classification tasks, a second dictionary including multiple categories can be pre-configured. For example, the target field is the medical field, and the categories included in the second dictionary can be classifications of entities in the medical field; for example, the categories may include but are not limited to: negative, positive, and others. The probability that each candidate category in the second dictionary is a category of the target entity unit can be predicted by a general large model and a classification large model, respectively. It can be understood that for different fields, the classification method of categories may be different. This application only takes the classification into negative, positive, and other categories as an example. In fact, the division method and number of categories can be configured according to actual application requirements, but this application does not specifically limit the specific division method of categories, the number of categories, etc.
[0158] In this step, the text to be processed and the target entity unit can be input into the general large model and the classification large model respectively; the target entity unit is classified using the general large model to obtain a third probability distribution; and the target entity unit is classified using the classification large model to obtain a fourth probability distribution.
[0159] It should be noted that the third probability distribution and the fourth probability distribution are the classification probability distributions of the general large model and the classification large model respectively; in the two probability distributions, the probabilities corresponding to the same candidate category may be different or the same.
[0160] In addition, the recognition task and the classification task can use a common dictionary together. The first dictionary and the second dictionary can be the same or different. For example, the common dictionary can include various entity words and category words. In the recognition task, the probability that all words in the common dictionary are entity units in the text to be processed can be predicted; in the classification task, the probability that all words in the dictionary are categories of the target entity unit can be predicted.
[0161] For example, the first probability distribution may include: dizziness 0.9, stomachache 0.05, negative 0.02, positive 0.03; the target entity unit is most likely to be dizziness. For example, if the target entity unit is dizziness, the third probability distribution includes: dizziness 0.02, stomachache 0.03, positive 0.86, negative 0.09; the dizziness category is most likely to be positive.
[0162] In one possible manner, the third probability distribution and the fourth probability distribution may also be obtained by further constraining the probability distribution directly output by the general large model and the classification large model. Exemplarily, the implementation of step 204 may include the following steps 2041-2043:
[0163] Step 2041: Based on the text to be processed and the target entity unit, the target entity unit is classified using the general large model to obtain a third initial probability distribution corresponding to the second dictionary, and the target object unit is classified using the classification large model to obtain a fourth initial probability distribution corresponding to the second dictionary;
[0164] The third initial probability distribution includes the third initial probability of each candidate category, and the fourth initial probability includes the fourth initial probability of each candidate category;
[0165] Step 2042: Based on the third initial probability distribution and the fourth initial probability distribution, determine, from the candidate categories, a target candidate category whose third initial probability and fourth initial probability are both not lower than a target threshold;
[0166] Step 2043: Eliminate the probabilities corresponding to the non-target candidate categories in the third initial probability distribution and the fourth initial probability distribution, respectively, to obtain the third probability distribution and the fourth probability distribution.
[0167] It should be noted that the third initial probability distribution and the fourth initial probability distribution are the initial probability distributions directly output by the general large model and the classification large model, respectively. The probabilities in each initial probability distribution can be constrained by pre-configured constraints, and the probability values in each initial probability distribution can be constrained within a certain range. For example, the constraint condition can be: the initial probability is not lower than the target threshold. For example, the target threshold corresponding to each initial probability distribution can be configured, and the target threshold can be 40%, 30%, etc. of the maximum initial probability in the corresponding initial probability distribution.
[0168] It should be noted that the determination method for each target candidate category can be the same as the determination method for each target candidate unit in the above steps, and will not be repeated here. The elimination process of the initial probability of the non-target candidate category can also be carried out in the same way as the elimination process of the initial probability of each non-target candidate unit in the above steps, and will not be repeated here.
[0169] Step 205: The electronic device obtains the target category of the target entity unit based on the third probability distribution and the fourth probability distribution.
[0170] In this step, the electronic device can combine the third probability distribution and the fourth probability distribution to determine the third target probability distribution; based on the third target probability distribution, determine the target category in each candidate category; and the target entity unit and the target category can be used as the extraction result of the extraction task. For example, the extraction result can be expressed as: "dizziness: positive".
[0171] For example, for the i-th candidate category, the target probability of the i-th candidate category in the third target probability distribution is Q i ; According to the target probabilities of each candidate category in the third target probability distribution, the candidate category with the largest target probability can be selected as the target category.
[0172] In one possible manner, the electronic device may sum the third probability distribution and the fourth probability distribution to obtain a third target probability distribution. For example, the third target probability distribution may be obtained by the following formula: ;in, represents the third target probability distribution, represents the third probability distribution, represents the fourth probability distribution, is a hyperparameter.
[0173] It should be noted that since the recognition ability and classification ability of the general large model may interfere with each other, hallucinations caused by recognition ability may exist in the classification task. The classification large model decouples the recognition ability and classification ability during the training phase, that is, the fourth probability distribution is the predicted probability that is not interfered by the recognition ability; and the third probability distribution and the fourth probability distribution are used to jointly predict and obtain the third target probability distribution, which helps to alleviate the hallucination problem caused by the recognition ability of the general large model in the classification task. The probability of each candidate category in the obtained third target probability distribution is also more accurate, thereby improving the accuracy of the classification result.
[0174] In one possible manner, the electronic device may determine the third target probability distribution based on the similarity between the third probability distribution and the fourth probability distribution. Exemplarily, in step 205, the implementation method of generating the target category corresponding to the target entity unit in the to-be-processed text based on the third probability distribution and the fourth probability distribution may include the following steps 2051 to 2054:
[0175] Step 2051: Determine a first classification error of the fourth probability distribution based on the similarity between the third probability distribution and the fourth probability distribution;
[0176] Step 2052: Determine a second adjusted probability for the third probability distribution based on the difference between the fourth probability distribution and the first classification error;
[0177] Step 2053: adjusting the third probability distribution based on the second adjusted probability to obtain a third target probability distribution;
[0178] Step 2054: Obtain the target category based on the third target probability distribution.
[0179] Wherein, divergence can be used to represent the similarity between the third probability distribution and the fourth probability distribution. The divergence between the third probability distribution and the fourth probability distribution can be obtained by the following formula:
[0180] ;
[0181] in, represents the third probability distribution determined using the general large model, represents a fourth probability distribution determined using the classification macro model; represents the divergence, which is used to measure the distance between the third probability distribution and the fourth probability distribution; the smaller the distance, the greater the similarity between the third probability distribution and the fourth probability distribution.
[0182] In one possible manner, the product between the similarity and the fourth probability distribution can be used as the category error, and the category error is expressed as: In addition, the difference between the fourth probability distribution and the classification error can be used as the second adjusted probability by the following formula: .
[0183] Exemplarily, the electronic device may determine the second target probability distribution by the following formula based on the similarity between the third probability distribution and the fourth probability distribution:
[0184] ;
[0185] in, represents the third target probability distribution, represents the third probability distribution determined by the general large model, Represents the fourth probability distribution determined by the classification model.
[0186] It should be noted that, similar to the recognition task, the greater the similarity between the third probability distribution and the fourth probability distribution, the smaller the classification error of the fourth probability distribution, indicating that the classification ability of the large classification model is better. By adjusting the third probability distribution through the second adjustment probability, the parts with large differences between the third probability distribution and the fourth probability distribution can be effectively removed. At the same time, the candidate categories with higher probabilities in the third probability distribution and the fourth adjusted probability distribution can be integrated. The parts with higher similarity in the two probability distributions can be more integrated. This enhances the ability of the third target probability distribution to express the true target category, helps to more accurately divide the target entity units into corresponding categories, and improves the accuracy of the classification results.
[0187] Therefore, by using the third probability distribution and the fourth probability distribution to classify the target entity unit, the classification ability of the classification large model can be further utilized on the basis of the classification ability of the general large model to improve the accuracy of the classification results. In addition, by subtracting the first classification error in the fourth probability distribution to obtain the second adjustment probability, the part with a larger error in the fourth probability distribution can be removed to effectively correct the classification ability of the classification large model. The use of the second adjustment probability to adjust the third probability distribution allows the classification ability of the general large model and the classification-specific large model to be more effectively combined, further enhancing the accuracy of the prediction of the true category in the third target probability distribution, helping to accurately find the target category with the highest probability and improve the accuracy of the classification results.
[0188] Step 206: The electronic device obtains an extraction result of the text to be processed based on the target entity unit and the target category of the target entity unit.
[0189] The extraction result of the text to be processed includes the target entity unit and the category of the target entity unit.
[0190] If the text to be processed includes multiple entity units in the target domain, multiple recognition tasks can be performed through the above steps 202-203 to obtain multiple target entity units; and multiple classification tasks can be performed through the above steps 204-205 to obtain the target category of each target entity unit. The extraction result includes the multiple target entity units and the target category of each target entity unit.
[0191] For example, in the task of extracting medical information from the text to be processed, the target entity unit to be identified is "dizziness", and the target category for "dizziness" is "negative", then the extraction result is "dizziness: negative".
[0192] In some possible embodiments, for the recognition task, that is, the recognition of the entity units of the text to be processed, the classification model can also be used for recognition; and on the basis of the first probability distribution and the second probability distribution, the fifth probability distribution of the classification model is further combined to determine the final recognition result.
[0193] Exemplarily, the method further comprises the following steps A1:
[0194] Step A1: Based on the text to be processed, use the classification model to perform entity unit recognition on the text to be processed to obtain a fifth probability distribution corresponding to the first dictionary;
[0195] Exemplarily, the electronic device can input the text to be processed into the general large model, the recognition large model, and the classification large model respectively, and the three large models respectively perform the recognition task to obtain the first probability distribution of the general large model corresponding to the recognition task, the second probability distribution of the recognition large model corresponding to the recognition task, and the fifth probability distribution of the classification large model corresponding to the recognition task. The fifth probability distribution may include the probability of each candidate entity unit being included in the text to be processed.
[0196] In one possible manner, the fifth probability distribution may also be obtained by constraining the probability distribution directly output by the classification model. Exemplarily, in step 202 and step A1, the first probability distribution, the second probability distribution and the fifth probability distribution are obtained by the following steps:
[0197] Based on the text to be processed, a general large model, a recognition large model, and a classification large model are respectively used to perform recognition tasks, and a first initial probability distribution output by the general large model, a second initial probability distribution output by the recognition large model, and a fifth initial probability distribution output by the classification large model are obtained, wherein the fifth initial probability distribution includes fifth initial probabilities of each candidate entity unit;
[0198] Based on the first initial probability, the second initial probability and the fifth initial probability of each candidate entity unit, determining, from the candidate entity units, a target candidate unit whose first initial probability, second initial probability and fifth initial probability are not lower than a target threshold;
[0199] The probabilities of non-target candidate units in the first initial probability distribution, the second initial probability distribution, and the fifth initial probability distribution are eliminated respectively to obtain the first probability distribution, the second probability distribution, and the fifth probability distribution.
[0200] It should be noted that the fifth initial probability distribution directly output by the classification model can also be constrained by constraint conditions. The constraint conditions can refer to the constraint conditions in step 202, which will not be described here one by one.
[0201] Among them, for the method of determining each target candidate unit, the electronic device uses constraints to obtain the corresponding first entity set based on the first initial probability distribution. Similarly, from each candidate entity unit of the fifth initial probability distribution, each candidate entity unit that is not lower than the target threshold is screened out to obtain the fifth entity set; then, the first entity set, the second entity set, and the fifth entity set are subjected to intersection operations to obtain the candidate entity units commonly included in the three entity sets, and the candidate entity units commonly included in the three entity sets are used as the target candidate units.
[0202] Among them, the fifth initial probability value of the non-target candidate unit in the fifth initial probability distribution may be set to a negative infinite value to obtain a fifth probability distribution.
[0203] For example, the following constraints can be used to directly initialize the initial probability distribution of the three large models to screen target candidate units:
[0204] Constraints: ;
[0205] in, represents the target candidate unit, Represents all candidate entity units. i represents the prompt text, x represents the text to be processed, y<t represents the first t generated target candidate units or target categories; β can be a hyperparameter used to determine the target threshold, that is, a truncation rate hyperparameter used to truncate low-probability candidate entity units.
[0206] in, The intersection of the three entity sets corresponding to the three large models can be used, expressed as ; can be determined by the following formula: .in, , , They are the first entity set corresponding to the general large model, the second entity set corresponding to the recognition large model, and the fifth entity set corresponding to the classification large model.
[0207] Among them, the non-candidate units in each initial probability distribution can be eliminated by the following formula: .
[0208] If the fifth probability distribution is obtained by using the classification model, the above step 203 may include the following steps:
[0209] Based on the first probability distribution, the second probability distribution and the fifth probability distribution, the target entity unit is obtained.
[0210] Exemplarily, the electronic device may determine a second target probability distribution by combining the first probability distribution, the second probability distribution, and the fifth probability distribution; and determine a target entity unit among the candidate entity units based on the second target probability distribution.
[0211] In a possible implementation, the electronic device may integrate the recognition capabilities of the recognition large model and the classification large model based on the similarity between the first probability distribution and the second probability distribution and the fifth probability distribution. Exemplarily, if the classification large model is also used to obtain the fifth probability distribution corresponding to the recognition task, then in step 203, the target entity unit is generated based on the first probability distribution, the second probability distribution and the fifth probability distribution, including the following steps:
[0212] Determining a first recognition error of the second probability distribution based on a similarity between the first probability distribution and the second probability distribution;
[0213] determining a second recognition error of the fifth probability distribution based on a similarity between the first probability distribution and the fifth probability distribution;
[0214] determining a first adjusted probability for the first probability distribution based on a difference between the second probability distribution and the first identification error;
[0215] adjusting the first probability distribution based on the first adjusted probability;
[0216] Determining a second target probability distribution based on a difference between the adjusted first probability distribution and the second recognition error;
[0217] Based on the second target probability distribution, the target entity unit is obtained.
[0218] Wherein, the divergence JSD can be used to represent the similarity between the first probability distribution and the fifth probability distribution. The divergence between the first probability distribution and the fifth probability distribution can be obtained by the following formula:
[0219] ;
[0220] in, represents the first probability distribution; It represents the fifth probability distribution determined by the classification model, which can also be simplified as ; represents divergence, which is used to measure the distance between the first probability distribution and the fifth probability distribution; wherein, the smaller the distance, the greater the similarity between the first probability distribution and the fifth probability distribution.
[0221] In one possible manner, the product of the similarity and the fifth probability distribution may be used as the second recognition error, and the second recognition error is obtained by the following formula: .
[0222] Exemplarily, the electronic device may determine the second target probability distribution based on the first probability distribution, the second probability distribution, and the fifth probability distribution by using the following formula:
[0223] ;
[0224] in, represents the second target probability distribution, represents the first probability distribution, represents the second probability distribution, is the first adjusted probability, is the first recognition error, is the second identification error, is a hyperparameter.
[0225] It should be noted that the large classification model can have recognition and classification capabilities, and the classification capability is better than the recognition capability; the accuracy of the fifth probability distribution may be affected by the classification capability.
[0226] Since the recognition task of the general large model may have hallucinations caused by classification ability, in the recognition task, on the basis of integrating the recognition ability of the general large model and the recognition large model; further, taking the recognition ability of the general large model as the benchmark, To measure the distance between the first probability distribution and the fifth probability distribution, use this distance to further To quantify the recognition error caused by the classification ability in the fifth probability distribution, so as to further remove the recognition error caused by the classification ability in the recognition task of the general large model, thereby further enhancing the accuracy of the second target probability distribution and improving the accuracy of the recognition result.
[0227] In addition, the above formula for determining the second target probability distribution can also be expressed as:
[0228] ;
[0229] In this formula, within, within Based on the first part of " means enhancing the first probability distribution, that is, using the recognition capability of the recognition large model on the basis of the general large model; at the same time, the second part " "middle, , Respectively represent the adaptive scales corresponding to the second probability distribution and the fifth probability distribution, and use the adaptive scales to reduce , , that is, minus the first recognition error , the second recognition error . Thus using , compare the recognition capabilities of the general large model and the recognition large model; use , compare the recognition capabilities of the general large model and the classification large model; and then compare the influence of the recognition large model and the classification large model on the recognition task.
[0230] Specifically, since the classification ability of the classification large model is better, there may be errors caused by the classification ability in the recognition task. The general large model may have hallucinations caused by the classification ability in the recognition task. If the comparison shows that the difference between the fifth probability distribution of the classification large model and the first probability distribution of the general large model is large, and there is also a difference in the recognition ability between the recognition large model and the general large model; then by subtracting " ", can remove the hallucination problem caused by classification ability in the first probability distribution of the general large model; at the same time, the parts with higher similarity in the first probability distribution and the second probability distribution are integrated, further improving the accuracy of the second target probability distribution.
[0231] In another possible embodiment, for the classification task, that is, classifying the target entity units, the recognition large model can also be used for classification; and based on the third probability distribution and the fourth probability distribution, the sixth probability distribution is further combined to determine the final classification result.
[0232] Exemplarily, the method further comprises the following steps A2:
[0233] Step A2: Based on the text to be processed and the target entity unit, the target entity unit is classified using the recognition large model to obtain a sixth probability distribution corresponding to the second dictionary.
[0234] Exemplarily, the electronic device can input the text to be processed and the target entity unit into the general large model, the recognition large model, and the classification large model respectively, and the three large models respectively perform the classification task to obtain the third probability distribution of the general large model corresponding to the classification task, the fourth probability distribution of the classification large model corresponding to the classification task, and the sixth probability distribution of the recognition large model corresponding to the classification task. Among them, the sixth probability distribution may include the probability that the category of the target entity unit is each candidate category.
[0235] In one possible way, the sixth probability distribution can also be obtained by constraining the probability distribution directly output by the recognition large model. The process may include: based on the text to be processed and the target entity unit, the recognition large model can be used to classify the target entity unit to obtain the sixth initial probability distribution, and the sixth initial probability distribution includes the sixth initial probability of each candidate category; based on the third initial probability distribution, the fourth initial probability distribution and the sixth initial probability distribution, from each candidate category, determine the target candidate category whose third initial probability, fourth initial probability and sixth initial probability are not lower than the target threshold; eliminate the probabilities of non-target candidate categories in the third initial probability distribution, the fourth initial probability distribution and the sixth initial probability distribution, respectively, to obtain the third probability distribution, the fourth probability distribution and the sixth probability distribution.
[0236] It should be noted that the process of obtaining the third probability distribution, the fourth probability distribution, and the sixth probability distribution for the initial probability distribution directly output by the three large models is the same as the process of obtaining the first probability distribution, the second probability distribution, and the fifth probability distribution in the above steps, and can also be implemented by using the above-mentioned corresponding constraints, corresponding methods of elimination processing, etc., which will not be elaborated here one by one.
[0237] If the sixth probability distribution is obtained by using the recognition large model, correspondingly, the above step 205 may include:
[0238] Based on the third probability distribution, the fourth probability distribution and the sixth probability distribution, a target category corresponding to the target entity unit is obtained.
[0239] Exemplarily, the electronic device may determine a fourth target probability distribution in combination with the third probability distribution, the fourth probability distribution, and the sixth probability distribution; and determine the target category of the target entity unit based on the fourth target probability distribution.
[0240] In one possible implementation, the electronic device may combine the classification capabilities of the recognition large model and the classification large model based on the similarity between the third probability distribution and the fourth probability distribution and the sixth probability distribution, respectively.
[0241] Exemplarily, if the recognition large model is also used to obtain the sixth probability distribution corresponding to the classification task, then in step 205, the target category corresponding to the target entity unit is generated based on the third probability distribution, the fourth probability distribution and the sixth probability distribution, including the following steps:
[0242] Determining a first classification error of the fourth probability distribution based on a similarity between the third probability distribution and the fourth probability distribution;
[0243] determining a second classification error of the sixth probability distribution based on a similarity between the third probability distribution and the sixth probability distribution;
[0244] determining a second adjusted probability for the third probability distribution based on a difference between the fourth probability distribution and the first classification error;
[0245] adjusting the third probability distribution based on the second adjusted probability;
[0246] determining a fourth target probability distribution based on a difference between the adjusted third probability distribution and the second classification error;
[0247] Based on the fourth target probability distribution, the target entity unit is obtained.
[0248] Wherein, the divergence can be used to represent the similarity between the third probability distribution and the sixth probability distribution. The divergence between the third probability distribution and the sixth probability distribution can be obtained by the following formula:
[0249] ;
[0250] in, represents the third probability distribution determined using the general large model, represents a sixth probability distribution determined using the identification large model; represents the divergence, which can measure the distance between the third probability distribution and the sixth probability distribution; the smaller the distance, the greater the similarity between the third probability distribution and the sixth probability distribution.
[0251] In one possible manner, the product of the similarity and the sixth probability distribution may be used as the second category error. That is, the second category error may be obtained by the following formula: .
[0252] Exemplarily, the electronic device may determine the fourth target probability distribution based on the third probability distribution, the fourth probability distribution, and the sixth probability distribution by using the following formula:
[0253] ;
[0254] in, represents the fourth target probability distribution, represents the third probability distribution, represents the fourth probability distribution. is the second adjusted probability, is the first classification error, is the second classification error, is a hyperparameter.
[0255] It should be noted that the recognition ability of the large model is better than the classification ability; the accuracy of the sixth probability distribution may be affected by the recognition ability. Specifically, the probability of entity words in the sixth probability distribution is more accurate than the probability of category words, and the probability of category words in the sixth probability distribution is significantly different from that in the third probability distribution.
[0256] Since the classification task of the general large model may have hallucinations caused by recognition ability, therefore, in the classification task, on the basis of integrating the classification capabilities of the general large model and the classification large model; further, through To measure the difference in classification ability between the recognition large model and the general large model, by subtracting , the probability of the category words in the third probability distribution that differ greatly from the sixth probability distribution can be weakened, thereby further removing the classification error caused by recognition ability in the classification task of the general large model. This can improve the accuracy of the fourth target probability distribution and the accuracy of the classification results.
[0257] Similar to the formula for determining the probability distribution of the second target in the recognition task, the formula for determining the probability distribution of the fourth target can also be expressed as:
[0258] ;
[0259] In this formula, Inside," " means enhancing the third probability distribution, that is, using the classification capability of the classification large model on the basis of the general large model. At the same time, " "middle, , They represent the adaptive scales corresponding to the fourth probability distribution and the sixth probability distribution, respectively, and the adaptive scales are used to reduce , , that is, minus the first classification error , the second classification error . Thus using , compare the classification capabilities of the general large model and the classification large model; use , compare the classification capabilities of the general large model and the recognition large model; and then compare the influence of the classification large model and the recognition large model on the classification task.
[0260] Specifically, since the recognition ability of the recognition large model is better, there may be errors caused by recognition ability in the classification task. The general large model may have hallucinations caused by recognition ability in the classification task. If the comparison shows that the difference between the sixth probability distribution of the recognition large model and the third probability distribution of the general large model is large, and there is also a difference in the classification ability between the classification large model and the general large model; then by subtracting " ", can remove the hallucination problem caused by recognition ability in the third probability distribution of the general large model; at the same time, the parts with higher similarity in the third probability distribution and the fourth probability distribution are integrated. Thereby improving the accuracy of the fourth target probability distribution.
[0261] It should be noted that in this application, the text to be processed is input into three large models, and each large model is combined to encode and decode the text to be processed, and finally an extraction result is generated. This application mainly improves the decoding stage. The text processing method based on the large model provided in this application is an alternate contrast decoding (ALCD, Alternate Contrastive Decoding) method.
[0262] Among them, regarding alternating decoding, specifically, in the decoding stage, the execution process of the extraction task is decomposed into the recognition process and the classification process, and the recognition ability and the classification ability are decoupled in the training stage. Different large models have advantages in different abilities, so that the different ability advantages of different large models can be used alternately in the recognition process and the classification process. For example, in the recognition process, the recognition ability advantage of the recognition large model is used on the basis of the general large model to enhance the accuracy of the recognition result; in the classification process, the classification ability advantage of the classification large model is used on the basis of the general large model to enhance the accuracy of the classification result; it can be realized that the recognition ability of the recognition large model Mid and the classification ability of the classification large model Mcl are used alternately in the decoding stage.
[0263] Among them, regarding contrastive decoding, specifically, in the recognition process, the differences in the recognition capabilities of the general large model, the recognition large model, and the classification large model are used to compare the respective influences of the classification large model and the recognition large model, so as to remove the hallucination problem caused by the classification ability in the general large model during decoding, and integrate the recognition capabilities of the general large model and the recognition large model. In the classification process, the differences in the classification capabilities of the general large model, the classification large model, and the recognition large model are used to compare the respective influences of the classification large model and the recognition large model on the classification ability, so as to remove the hallucination problem caused by the recognition ability in the general large model during decoding, and integrate the classification capabilities of the general large model and the classification large model, thereby using contrastive decoding to achieve the effect of removing hallucinations and improving accuracy.
[0264] In a possible implementation, the method may further include the following steps B1:
[0265] Step B1, obtaining the prompt text of the extraction task;
[0266] The prompt text includes a recognition prompt word and a classification prompt word. The recognition prompt word indicates to recognize entity units in a target field in the text to be processed, and the classification prompt word indicates to classify the recognized entity units.
[0267] The extraction task includes a recognition task and a classification task, and the prompt text includes prompt words corresponding to the recognition task and the classification task respectively. The recognition task is to recognize entity units in the target field of the processed text, and the classification task is to classify the recognized entity units.
[0268] In a possible implementation, the prompt text may include recognition prompt words for recognition tasks and classification prompt words for classification tasks. In different tasks, prompt words corresponding to the tasks may be used respectively.
[0269] The first probability distribution is obtained by using a general large model to perform entity unit recognition on the text to be processed based on the text to be processed and the recognition prompt word; the second probability distribution is obtained by using a general large model to perform entity unit recognition on the text to be processed based on the text to be processed and the recognition prompt word; for example, step 202 can be replaced by step T1:
[0270] Step T1: Based on the text to be processed and the recognition prompt words, the electronic device uses a general large model to perform entity unit recognition on the text to be processed to obtain a first probability distribution corresponding to the first dictionary, and uses the recognition large model to perform entity unit recognition on the text to be processed to obtain a second probability distribution corresponding to the first dictionary.
[0271] The third probability distribution is obtained by classifying the target entity unit based on the text to be processed, the target entity unit and the classification prompt word using a general large model; the fourth probability distribution is obtained by classifying the target entity unit based on the text to be processed, the target entity unit and the classification prompt word using a classification large model. For example, step 204 can be replaced by step T2:
[0272] Step T2: Based on the text to be processed, the classification prompt words and the target entity unit, the electronic device uses the general large model to classify the target entity unit to obtain a third probability distribution corresponding to the second dictionary, and uses the classification large model to classify the target entity unit to obtain a fourth probability distribution corresponding to the second dictionary.
[0273] In another possible implementation, regardless of whether it is a recognition task or a classification task, prompt text is used uniformly. That is, step 202 can be replaced by: the electronic device uses a general large model to perform entity unit recognition on the text to be processed based on the text to be processed and the prompt text to obtain a first probability distribution corresponding to the first dictionary, and uses the recognition large model to perform entity unit recognition on the text to be processed to obtain a second probability distribution corresponding to the first dictionary; the classification task is similar and will not be listed one by one here.
[0274] In one possible approach, prompt texts may also be used for the training process.
[0275] For example, different tasks are distinguished, and different tasks use prompt words corresponding to the tasks. For example, if the large recognition model to be trained performs a recognition task, the first sample and the recognition prompt word can be input; if it performs a classification task, the first predicted entity unit of the first sample and the classification prompt word can be input. It should be noted that the prompt text method used in the reasoning stage is also consistent with the training stage. For example, both stages use task prompt words corresponding to the currently performed task. For example, the above steps T1 and T2.
[0276] Alternatively, both stages do not distinguish between different tasks, that is, different tasks all use complete prompt texts. For example, if in the training stage, tasks are not distinguished, but complete prompt texts are uniformly used for both recognition tasks and classification tasks, then in the inference stage, complete prompt texts can also be uniformly used for each task.
[0277] It should be noted that by distinguishing different tasks and using different prompt words, the prompt text can be decoupled, the recognition prompt words can be used for recognition tasks, and the classification prompt words can be used for classification tasks. Based on this, on the basis of decoupling the recognition ability and the classification ability, the current task can be further prevented from being interfered with by other different tasks, thereby improving the accuracy.
[0278] In another possible embodiment, the text to be processed may include multiple entity monomers, and multiple tasks need to be performed to obtain a complete extraction result of the text to be processed. The result of each recognition task or classification task can be generated by autoregression.
[0279] Exemplarily, the text to be processed includes a plurality of target entity units, and the extraction result includes a plurality of target entity units and target categories of the target entity units;
[0280] The extraction result is generated by executing n tasks, each task is a recognition task or a classification task, and the generated text of each task is a target entity unit or a target category; wherein n is an integer greater than or equal to 2;
[0281] The execution process of the i-th task includes the following steps C1-C3:
[0282] Step C1: based on the generated text of the i-1th task, determine the text type of the text to be generated, the text type is a recognition type or a classification type, and the text type corresponding to the first task is a recognition type, wherein i is an integer greater than or equal to 2;
[0283] Step C2: Based on the text to be processed and the generated text of the previous i-1 tasks, a general large model is used to obtain a general probability distribution, a recognition large model is used to obtain a recognition probability distribution, and a classification large model is used to obtain a classification probability distribution;
[0284] Wherein, the general probability distribution is the first probability distribution or the third probability distribution, the recognition probability distribution is the second probability distribution or the sixth probability distribution, and the classification probability distribution is the fourth probability distribution or the fifth probability distribution;
[0285] Step C3: Generate a generated text for the i-th task based on the general probability distribution, the recognition probability distribution and the classification probability distribution.
[0286] The general probability distribution is the first probability distribution, the identification probability distribution is the second probability distribution, and the classification probability distribution is the fifth probability distribution. Alternatively, the general probability distribution is the third probability distribution, the classification probability distribution is the fourth probability distribution, and the identification probability distribution is the sixth probability distribution.
[0287] In a possible implementation, for the first task, the first task is determined to be a recognition task based on a preconfigured judgment rule; based on the text to be processed, the first task is performed using a general large model and a recognition large model respectively, and the first probability distribution and the second probability distribution corresponding to the first task are obtained; based on the first probability distribution and the second probability distribution corresponding to the first task, the target entity unit is determined, and the determined target entity unit is used as the result of the first task. Alternatively, the first task can also be performed using a classification large model to obtain a fifth probability distribution; then the target entity unit of the first task is obtained based on the first probability distribution, the second probability distribution and the fifth probability distribution.
[0288] In one possible approach, the judgment rule is used to judge the text type of the current text to be generated, that is, the task type of the task to be performed; the recognition type corresponds to the recognition task, and the classification type corresponds to the classification task. Exemplarily, the results of each generated task can be represented in a structured form, and the judgment rule can be based on a predefined structure for judgment.
[0289] For example, the target entity unit and the target category can be separated by a colon ":", and the extraction result of each extraction task can be expressed as: "target entity unit: target category"; the extraction results of different extraction tasks can be separated by a "space n\". For the i-th task, if the generated text of the i-1-th task is followed by a colon, the text type corresponding to the i-th task is the classification type; if there is no colon after the generated task of the i-1-th task, the text type corresponding to the i-th task is the recognition type. That is, the judgment rule may include: before the colon is the target entity unit, and after the colon is the target category of the target entity unit.
[0290] The text processing method based on the large model of this application can use an autoregressive method to generate tokens (words) for each task until the token of the last task is generated, and then the final extraction result of the text to be processed can be obtained. In a possible example, for the i-th task, the token of the i-th task can be generated by executing the following process:
[0291] (1) If i ≥ 2, obtain the token, pending text, and prompt text of the previous i-1 tasks; if i = 1, obtain the pending text and prompt text.
[0292] (2) Based on the judgment rules, determine the task type of the i-th task to be executed;
[0293] Among them, the type of the i-th token to be generated can be determined based on whether there is a colon after the last token currently generated.
[0294] For example, if there is a colon, the i-th token is located after the colon and is a token of the classification type (cls). If there is no colon, the i-th token is located before the colon and is a token of the identification type (ide).
[0295] (3) Based on the token, the text to be processed, and the prompt text of the previous i-1 tasks, the general large model, the recognition large model, and the classification large model are used to perform the i-th task, and the following probability distributions of the general large model corresponding to the i-th task are obtained respectively: , identify the probability distribution corresponding to the large model , the probability distribution corresponding to the large classification model ;
[0296] That is, get the corresponding value of the i-th token , , ;
[0297] (4) Judgment-based task types and the corresponding probability distributions of the three major models , , ; Use the following formula to determine the target probability distribution corresponding to the i-th task;
[0298] ,if ;
[0299] ;
[0300] in, Indicates the type of the i-th task currently to be executed, that is, the type of the i-th token.
[0301] , indicating that the i-th token is a classification type (cls) token. Represents the target probability distribution of classification tokens.
[0302] , indicating that the i-th token is an identification type (ide) token. Represents the target probability distribution of the recognition token.
[0303] in, , Respectively represent: and The similarity between and The similarity between them can be expressed as divergence, which can be obtained by the following divergence formula , :
[0304] ;
[0305] ;
[0306] (5) Based on the target probability distribution, generate the result of the i-th task.
[0307] If it is a classification token, you can Select the target category with the maximum target probability as the i-th token; if it is an identification token, it can be selected from The target entity unit with the maximum target probability is selected as the i-th token.
[0308] The training process of each large model is introduced below.
[0309] In this application, the extraction task can be modeled into a recognition and classification process, corresponding to the recognition task and the classification task respectively. In the training stage, the recognition ability and classification ability of the large model can be decoupled.
[0310] In one possible manner, the recognition large model is trained by following steps S11-S14:
[0311] Step S11, obtaining a first training set, the first training set including a plurality of first sample texts with sample labels, the sample label of each first sample including an entity label of the first sample;
[0312] Step S12: Based on each first sample, use the recognition large model to be trained to perform entity unit recognition on each first sample to obtain a first predicted entity unit of each first sample;
[0313] Step S13: Based on each first sample and the first prediction entity unit, the first prediction entity unit is classified using the recognition large model to be trained to obtain a first prediction category of the first prediction entity unit, and based on the first prediction entity unit and the first prediction category of each first sample, an extraction result of each first sample is obtained;
[0314] Step S14: determine a first training loss based on the similarity between the first predicted entity unit and the entity label of each first sample, and fine-tune the model parameters of the large recognition model to be trained based on the first training loss.
[0315] Exemplarily, each first sample may be a sample text. For example, each first sample may be a text of a conversation between a doctor and a patient.
[0316] It should be noted that each first sample may include one or more entity units, and an autoregressive approach may be used to generate a plurality of first predicted entity units and the first predicted category of each first predicted entity unit.
[0317] The difference from the above steps C1-C3 is that in the training phase, the large recognition model to be trained can be used to independently perform recognition tasks and classification tasks. That is, the large recognition model to be trained can be used to predict the entity unit of the first sample to obtain a first prediction probability distribution; based on the first prediction probability distribution, a first prediction entity unit is generated; then, using the first sample and the first prediction entity unit, the first prediction entity unit is classified through the large recognition model to be trained to obtain a second prediction probability distribution, and a first prediction category is generated based on the second prediction probability distribution. The extraction result is obtained based on the first prediction entity unit and the first prediction category.
[0318] In this step, the token of the recognition task can be selectively used to optimize the large recognition model to be trained. For example, the first predicted category in the extraction result of the first sample can be masked, and the loss between the first predicted entity unit and the entity label of each sample can be calculated, and the loss can be used to fine-tune the large recognition model to be trained. Therefore, when optimizing the large recognition model Mid, the parameter θ of the large recognition model to be trained can be adjusted according to the following optimization goal, using the loss between the recognition token and the corresponding entity label: id :
[0319] ;
[0320] in, Indicates the time step of the classification token, located in The classification tokens in the collection do not need to be optimized. represents the first training set. Indicates t token that has been generated before, i Represents the prompt word prompt, x The sample text representing the first sample, Representative t A token is probability.
[0321] In one possible manner, the classification model is trained by following steps S21-S24:
[0322] Step S21, obtaining a second training set, where the second training set includes a plurality of second samples with sample labels, where the sample label of each second sample includes a category label of each entity label of the second sample;
[0323] Step S22: Based on each second sample, use the classification model to be trained to perform entity unit recognition on each second sample to obtain a second predicted entity unit of each second sample;
[0324] Step S23: Based on each second sample and the second prediction entity unit, the second prediction entity unit is classified by using the classification large model to be trained to obtain a second prediction category of the second prediction entity unit, and based on the second prediction entity unit and the second prediction category of each second sample, an extraction result of each second sample is obtained;
[0325] Step S24: determine a second training loss based on the similarity between the second predicted category and the category label of each second sample, and fine-tune the model parameters of the large classification model to be trained based on the second training loss.
[0326] Exemplarily, each second sample may be a sample text, for example, each second sample may be a conversation text between a doctor and a patient. An autoregressive method may be used to generate entity units of the second sample and the category of each entity unit. Similar to the recognition large model to be trained, the classification large model to be trained may be used to independently perform the recognition task and the classification task.
[0327] For example, the large classification model to be trained can be used to predict the entity unit of the second sample to obtain a third prediction probability distribution, and the third prediction probability distribution can be used to generate a second prediction entity unit; then, using the second sample and the second prediction entity unit, the category of the second prediction entity unit is classified through the large classification model to be trained to obtain a fourth prediction probability distribution, and the fourth prediction probability distribution is used to generate a second prediction category.
[0328] In this step, the token of the classification task can be selectively used to optimize the classification model to be trained. For example, the second predicted entity unit in the second extraction result can be masked, and the loss between the second predicted category and the category label of each second sample can be calculated, and the loss can be used to fine-tune the classification model to be trained. cl When , the parameters θ of the classification model to be trained can be adjusted according to the following optimization objectives, using the loss of the classification token and the corresponding category label cl :
[0329] ;
[0330] in, Indicates the time step of identifying token, located in The identification tokens in the collection do not need to be optimized. represents the second training set.
[0331] In one possible manner, the general large model is trained by following steps S31-S34:
[0332] Step S31, obtaining a third training set, where the third training set includes a plurality of third samples with sample labels, where the sample label of each third sample includes an entity label of the third sample and a category label of each entity label;
[0333] Step S32: Based on each third sample, use the general large model to be trained to perform entity unit recognition on each third sample to obtain a third predicted entity unit of each third sample;
[0334] Step S33: Based on each third sample and the third prediction entity unit, the third prediction entity unit is classified using the general large model to be trained to obtain a third prediction category of the third prediction entity unit, and based on the third prediction entity unit and the third prediction category of each third sample, an extraction result of each third sample is obtained;
[0335] Step S34: determine a third training loss based on the similarity between the third extraction results of each third sample and the sample label, and fine-tune the model parameters of the general large model to be trained based on the third training loss.
[0336] When training the general large model, the general large model can be used to independently generate the third prediction entity unit and the third prediction category. In addition, the first similarity between the third prediction entity unit and the entity label of each third sample, the second similarity between the third prediction category and the category label can be determined, and the loss between the third extraction result of each third sample and the sample label can be determined. The general large model to be trained is trained using the loss to obtain the general large model.
[0337] Among them, in the training stage of each of the above-mentioned large models, efficient parameter fine-tuning technology can be used to train each large model. For example, the LoRA (Low-Rank Adaptation) method can be used to optimize model parameters.
[0338] like Figure 3 and Figure 4 , respectively showing the two main steps of the method of the present application.
[0339] in, Figure 3 A schematic diagram of the fine-tuning process is shown in FIG. Figure 3 As shown, during the fine-tuning phase, the capabilities of the large model can be decoupled. The Mask method can be used to optimize the recognition capability of the large recognition model and the classification capability of the large classification model in a targeted manner. When fine-tuning the recognition large model Mid and the classification large model Mcl, the same input as the general large model is used. For example, the input may include prompt text and samples; in one example, the prompt text may be: "Please identify each symptom from the text and classify it as negative or positive." During the fine-tuning process, tokens are selectively optimized. Specifically, when optimizing the parameter θ of the recognition large model Mid, id , the generated token of the classification task can be occluded; for example, Figure 3 In the optimization of the parameters θ of the large classification model Mcl, the positive and negative categories in the extraction results generated by the large recognition model are blocked. cl , the generated recognition task token can be occluded; for example, Figure 3The entity words such as dizziness and fever in the extraction results generated by the large classification model are blocked. Figure 3 As shown in the figure, when fine-tuning the general large model Mnl, there is no need to block the extraction results, and both recognition tokens and classification tokens are used for optimization.
[0340] in, Figure 4 A schematic diagram of the process of the reasoning stage is shown. Figure 4 As shown in the figure, in the inference stage, the predictions of the three large models can be compared. In order to effectively utilize the individual capabilities of each large model, the classification ability of Mcl and the recognition ability of Mid can be enhanced alternately, while removing the influence of other capabilities in the general large model Mnl.
[0341] like Figure 4 As shown, taking the token generated at time t, i.e., yt, as an example, the input includes the token before t, i.e., y<t, the prompt text, the text to be processed, etc., and may also include pre-configured judgment rules. Among them, the judgment rules can be used to determine the type of the tth token. Among them, the three large models can be used to obtain the corresponding , , , and calculate Respectively , In the recognition task, the divergence JSD between the large model is used to identify To enhance the general large model ; In the classification task, the classification model is used To enhance the general large model In addition, in the recognition task, the classification model can also be used Remove the general large model In classification tasks, the illusion caused by the ability to classify can also be used to identify large models. Remove the general large model The problem of hallucinations caused by recognition ability.
[0342] like Figure 4 As shown, the initial probability distribution directly output by the three large models can be constrained first to obtain the probability distribution of each large model. For example, the probability values of abdominal pain whose probability values are lower than the target threshold in the three probability distributions are eliminated using constraints. For example. If the tth token is a classification token, in the probability distribution of the classification large model, the probabilities of positive and negative are higher, and the probability of dizziness is lower; while in the general large model, there may be hallucination problems due to the recognition ability, and the probability of dizziness and positivity are relatively high. In the recognition large model, the probabilities of positive and negative are lower, and the probability of dizziness is higher. Through , , which can enhance the classification ability and remove the interference of recognition ability, so that in the final target probability distribution, the probability of the classified category words is increased and the probability of the entity units of recognition ability is effectively reduced, so that the classification token is negative.
[0343] Figure 5 This is a flowchart of an online consultation using a large model provided in an embodiment of the present application. Figure 5 As shown, the process includes the following steps:
[0344] S41, obtaining the online consultation dialogue text input by the user;
[0345] For example, the online consultation dialogue text can be an interactive dialogue between a doctor and a patient.
[0346] For example, Figure 6 As shown, the medical interaction dialogue is as follows:
[0347] “Patient: My baby is one year old and suddenly started vomiting and having diarrhea.
[0348] Doctor: Hello, does your child have a fever? How is your child's mental state?
[0349] Patient: No fever, the child is in good spirits. This happened suddenly today. Is this related to the formula?
[0350] Doctor: How many times a day does your child have bowel movements? Is the stomach swollen? Does your child suck their hands?
[0351] Patient: I have only had one bowel movement so far today. "
[0352] S42. Obtain prompt text corresponding to the medical information extraction task.
[0353] For example, Figure 6 As shown in the figure, the prompt text prompt for the medical information extraction task is as follows:
[0354] “Please identify each clinical symptom from the following [medical conversation] and categorize it into [options]:”.
[0355] Among them, [Medical Dialogue] is the text of the online consultation dialogue, and [Options] can be the classification category.
[0356] S43, inputting the medical consultation dialogue text and the prompt text into the large model;
[0357] Among them, the large model can be configured with a fine-tuned recognition large model, a classification large model, and a general large model; based on the similar process of the three large models in the application for the extraction task of the text to be processed in the inference stage, at least one symptom word corresponding to the medical consultation dialogue text and the category of each symptom word can be generated. For example, if there are multiple symptoms, they can be separated by spaces (which can be expressed as \n), and each symptom word and its category can be separated by a colon.
[0358] S44: Generate and output the extraction result of the medical consultation dialogue text.
[0359] like Figure 6 As shown, in this application, in the inference stage, the output extraction results can be output as follows by comparing the alternating decoding method:
[0360] “Vomiting: positive Fever: negative Stomach bloating: other”.
[0361] In addition, in the related technology, a large model is directly used to extract medical information, and the generated extraction results may be: "Vomiting positive Fever positive Abdominal swelling Others", among which "Fever positive" is wrong, and the correct one should be "Fever negative", and this error is an illusion in the classification of medical entities. Among them, "Abdominal swelling" is wrong, and the correct one should be "Stomach swelling", and this error is the generation of symptom entities that do not exist in the consultation dialogue.
[0362] Figure 7 This is a medical question-answering flow chart using a large model provided in an embodiment of the present application. Figure 7 As shown, the process includes the following steps:
[0363] S51, obtaining a medical question input by a user;
[0364] For example, Figure 8 As shown, the user inputs the question: "You can't eat those things after a burn."
[0365] S52, obtaining a prompt text for a medical information extraction task;
[0366] S53, inputting the medical question and prompt text into the big model, and extracting medical information from the medical question through the big model;
[0367] For example, medical information extraction may include identifying symptoms in a problem and classifying the identified symptoms.
[0368] S54, obtaining medical symptoms and categories output by the large model;
[0369] For example, the extraction result of the question of the medical question answering may be obtained, that is, the medical symptoms and categories are: "Burn: positive".
[0370] S55. Based on the medical symptom and the category, provide the user with medical information for the medical symptom;
[0371] For example, Figure 8 As shown, for "burn: positive", a more accurate answer or medical advice can be matched to the question of the medical question and answer as follows:
[0372] “After a burn, patients need to pay special attention to what they eat. Here are some foods to avoid after a burn:
[0373] 1. Spicy foods: such as chili peppers, peppercorns, ginger, etc. These foods will irritate the burned area and increase pain and discomfort.
[0374] 2. Raw and cold foods: such as ice cream, cold noodles, seafood, etc. These foods will reduce the patient's immunity and easily cause infection.
[0375] 3. High-fat foods: such as fried chicken, fried foods, etc. These foods are difficult to digest and can easily cause gastrointestinal discomfort.
[0376] 4. Pickled foods: such as pickles, salted fish, bacon, etc. These foods contain more salt and can easily aggravate edema in the burned area.
[0377] 5. Stimulating beverages: such as coffee, tea, cola, etc. These beverages will irritate the burned area and cause pain and discomfort.
[0378] In short, after burns, spicy, cold, high-fat, pickled and stimulating drinks should be avoided. Patients should choose nutritious and easily digestible foods such as milk, eggs, vegetables, fruits, etc. ".
[0379] It should be noted that medical question answering based on a large language model has greatly enriched the diversity and accessibility of medical services. The text processing method of this application can also have many other applications in medical question answering scenarios. Figure 5 , Figure 7 The scenario process is taken as an example, but the scenario to which the present application is applicable is not limited to this.
[0380] For example, by providing immediate and accurate medical information, patients can better understand their health conditions and manage themselves effectively. For another example, it can not only assist doctors in making rapid diagnoses and clinical decisions, but also serve as an educational tool to enhance the professional skills of medical professionals. For another example, in areas with limited resources, medical question-and-answer systems have improved the accessibility of medical services and alleviated the problem of uneven distribution of medical resources through telemedicine services. For another example, they can also collect and analyze large amounts of patient data, provide support for medical research, and promote the development of precision medicine. Through personalized medical advice, medical question-and-answer systems can meet the personalized needs of patients, improve patient satisfaction, and reduce medical costs, etc.
[0381] In addition, the text processing method based on the large model provided in this application can also be applied to other scenarios, such as online meeting scenarios, smart shopping guide scenarios, interview activity scenarios, etc. Fig. 9 , Fig.10 , Fig.11 The scenario diagram shown introduces the above three application scenarios and processes.
[0382] In a possible scenario, the embodiment of the present application provides a text processing process for an online conference scenario. The process includes the following steps S61-S64:
[0383] S61, obtaining the meeting content text of the online meeting;
[0384] Among them, the method of the present application can be applied in online conference scenarios to provide conference agenda sorting services. The large model can be used to extract conference agenda items based on the conference content to assist in conference summarization and improve meeting efficiency.
[0385] like Fig. 9 As shown in the example of a possible scenario, the text of the online meeting content is as follows:
[0386] "In today's online course meeting, we discussed several important tasks. First, we need to complete a research report on a new deep learning algorithm next week. This is urgent and important. Second, we need to complete a learning summary of last year's machine learning course by the end of the month. Although this is important, we have plenty of time. Finally, we need to complete the semester evaluation and assessment for all students in the next quarter, which is also not urgent."
[0387] S62, obtaining a prompt text for the meeting item extraction task;
[0388] like Fig. 9 As shown, for example, the prompt text prompt for the meeting items extraction task is as follows:
[0389] “Please identify each meeting item from the following [meeting content] and categorize it into [options]:”.
[0390] [Meeting content] is the meeting content text of the online meeting, and [Options] may be categories for classifying meeting items. For example, the categories of meeting items may include the following predefined categories: urgent and important, important but not urgent, generally important and urgent, generally important but not urgent, etc.
[0391] S63, inputting the meeting content text and the prompt text into the big model, and extracting meeting items from the meeting content text through the big model;
[0392] For example, conference agenda extraction may include identifying agenda items in conference content text and classifying the identified conference agenda items.
[0393] S64: Generate and output the extraction result of the conference content text.
[0394] like Fig. 9 As shown, for example, for the above conference content text, the large model uses a comparative alternating decoding method based on the conference content text and the prompt text, and the output extraction results are as follows:
[0395] “Complete the curation of new deep learning algorithms: Urgent and important;
[0396] Completed a summary of last year’s machine learning projects: important but not urgent;
[0397] Complete annual evaluation review for all team members: generally important and non-urgent."
[0398] In another possible scenario, the embodiment of the present application provides a text processing flow for a smart shopping guide scenario. The flow includes the following steps S71-S74:
[0399] S71. Obtaining a conversation text between the intelligent robot and the buyer in the intelligent shopping guide scenario;
[0400] The method of the present application can be applied to intelligent shopping guide scenarios to provide product information sorting services, so as to quickly match buyers with products that meet their needs and help merchants improve service quality and efficiency. For example, a large model can be used to extract product information from the conversation text between the intelligent robot and the buyer.
[0401] like Fig.10 As shown in the example of a possible scenario, the conversation text between the intelligent robot and the buyer is as follows:
[0402] “Buyer: Hi, I want to buy a new electronic product but I’m not sure which one to choose.
[0403] Robot: Hello, I'm happy to help you. Can you tell me what you need? For example, are you more concerned about running speed, response time, screen display quality or battery life?
[0404] Buyer: I am mainly concerned about running speed and battery life.
[0405] Robot: OK, I recommend you to take a look at our product A. It runs very fast, has the best performance, and has a strong battery life of 10 hours.
[0406] Buyer: That sounds good, but I also want to know how its screen display works?
[0407] Robot: The screen display effect of product A is also very good, but if you have higher requirements on this point, I suggest you consider our product B. Its screen display effect performance is better.
[0408] Buyer: OK, I'll think about it. Thank you for your suggestion."
[0409] S72, obtaining a prompt text for the commodity information extraction task;
[0410] like Fig.10 For example, the prompt text for the commodity information extraction task is as follows:
[0411] "Please identify the performance of each product from the following [conversation content] and categorize the performance into [options]:".
[0412] Among them, [Conversation Content] is the conversation text between the intelligent robot and the buyer, and [Options] can be the categories for classifying each performance of the product. For example, the performance categories can include the following predefined categories: best performance, better performance, average performance, etc.; for certain performances, corresponding categories can also be predefined. For example, for battery life, the following categories can be predefined: long battery life, average battery life, short battery life, or directly battery life of xx hours.
[0413] S73, inputting the conversation text between the intelligent robot and the buyer, as well as the prompt text, into the big model, and extracting product information from the conversation text between the intelligent robot and the buyer through the big model;
[0414] For example, product information extraction may include identifying product properties of the conversation text and classifying the identified product properties.
[0415] S74: Generate and output the extraction result of the conversation text between the intelligent robot and the buyer.
[0416] like Fig.10As shown, for example, for the above conversation text between the intelligent robot and the buyer, the large model uses the contrast alternating decoding method based on the conversation text and prompt text between the intelligent robot and the buyer, and the output extraction results are as follows:
[0417] “Product A: running speed (best performance), battery life (10 hours of continuous use), screen display effect (average performance);
[0418] Product B: Screen display effect (better performance)".
[0419] In another possible scenario, the embodiment of the present application provides a text processing flow for an interview activity scenario. The flow includes the following steps S81-S84:
[0420] S81, obtaining the interview record text in the interview activity scene;
[0421] Among them, the method of this application can be applied to interview-related activity scenarios to provide interview element extraction services. Through a large model, elements in the interview record text can be identified and extracted to quickly organize the interview minutes.
[0422] Among them, the interview record text can be a question-and-answer dialogue text between the reporter and the interviewee.
[0423] like Fig.11 For example, the text of the interview record of the interview activity is as follows:
[0424] "Reporter: Hello, congratulations on winning the gold medal in this Games. Can you tell us how you feel?
[0425] Champion: Thank you, I am very excited and honored. This is the result of my many years of training, and I am very happy to show my strength on this stage.
[0426] Reporter: Can you tell us about your training process?
[0427] Champion: I train about 6 hours a day, including strength training, technical training and recovery training. I also have a great coaching team who help me develop training plans and diet plans.
[0428] Reporter: Do you have any special strategy in the game?
[0429] Champion: My main strategy is to stay calm and focus on my own game rather than my opponent's performance. I also try to keep my body in the best condition possible so that I can perform at my best during the match. "
[0430] S82, obtaining a prompt text of the feature extraction task;
[0431] like Fig.11 As shown, for example, the prompt text prompt of the interview dialogue feature extraction task is as follows:
[0432] “Please identify each element from the following [interview dialogue], categorize them into [options], and extract the specific content of the element:”.
[0433] Among them, [Interview dialogue] is the interview record text of the interview activity, and [Options] can be the category of the elements in the interview activity. For example, the category of the element can include the following predefined categories: personal feelings, training details, team support, game strategy, etc. For example, the specific content of the element can be the specific content of the interviewee's answer to the element in the interview record.
[0434] S83, inputting the interview record text and the prompt text into the big model, and extracting elements from the interview record text through the big model;
[0435] S84. Generate and output the extraction results of the interview record text.
[0436] like Fig.11 As shown, for example, for the above interview record text, the large model uses a comparative alternating decoding method based on the interview record text and the prompt text, and the output extraction results are as follows:
[0437] "The winner:
[0438] Feeling (personal feeling), very excited and honored
[0439] Training process (training details), 6 hours of training per day, including strength training, technical training and recovery training
[0440] Coaching team (team support) to help develop training plans and diet plans
[0441] Race strategy (game strategy), stay calm, focus on your game, keep your body in the best condition."
[0442] Among them, "feelings, training process" etc. are identified element words; "personal feelings, training details" etc. in brackets belong to the category of elements; "very excited and honored", "training for 6 hours a day, including strength training, technical training and recovery training" etc. belong to the specific content of the elements.
[0443] Fig.12 A schematic diagram of experimental results provided by this application is shown. Fig.12As shown, six medical data were selected to verify the effectiveness of the method of this application on two large models. Among them, the six medical data are: CMeEE-V2, CMeIE-V2, IMCS-V2-NER, CMedCausal, IMCS-V2-SR, CHIP-MDCFNPC. The two large models are ChatGLM-6B and Qwen-7B-Chat. Among them, CMeEE-V2 is a Chinese medical entity recognition task. IMCS-V2-SR aims to standardize doctor-patient dialogues through medical concepts. The goal of IMCS-V2-NER is to extract medical concepts from dialogues. CMedCausal is a causal relationship extraction task for medical texts. CHIPMDCFNPC refers to clinical concept discovery and differentiation. CMeIE-V2 aims to identify and classify entity relationships contained in medical texts. The method of this application is compared with eight other decoding methods in the related art. Among them, such as Fig.12 As shown, the eight decoding methods in the related technology specifically include: Greedy Search Decoding, Beam Search Decoding, Top K Sample Decoding, Nucleus Sample, Context-Free Grammer (CFG), Context-aware Decoding (CAD), Controlled Decoding (CD), Decoding by Contrasting Layers (DoLa), etc. Fig.12 In the paper, the method of this application (ALCD) and the above 8 decoding methods in related technologies are verified on two large models respectively, and the micro F1 score is used as the evaluation index to obtain the F1 score of each large model in each method. The higher the score, the better the performance. Fig.12 As shown, the experiment found that the score of the method of the present application (ALCD ours) is the best. Therefore, the method of the present application can significantly improve the effect compared with some large model decoding solutions in the related art.
[0444] The text processing method based on the large model of the present application is based on the text to be processed, and the general large model is used to identify the entity unit to obtain the first probability distribution, and the recognition large model is used to identify the entity unit to obtain the second probability distribution. Based on the first probability distribution and the second probability distribution, the target entity unit in the text to be processed is obtained; so that during recognition, the recognition ability of the recognition large model can be used to reduce the illusion caused by the classification ability in the recognition task of the general large model, and improve the accuracy of recognition. In addition, based on the text to be processed and the target entity unit, the general large model is used to classify the target entity unit to obtain a third probability distribution, and the classification large model is used to classify to obtain a fourth probability distribution, and the target category is obtained based on the third probability distribution and the fourth probability distribution; so that during classification, the classification ability of the classification large model can be further used to reduce the illusion caused by the recognition ability in the classification task of the general large model, and improve the accuracy of classification. By decomposing the extraction into different processes of recognition and classification, and rotating the recognition ability or classification ability of different large models in different processes, the accuracy of the extraction results can be further improved.
[0445] Fig.13 The following is a schematic diagram of a text processing device based on a large model provided in an embodiment of the present application. Fig.13 As shown, the device comprises:
[0446] The first acquisition module 1301 is used to acquire the text to be processed;
[0447] A first recognition module 1302 is used to perform entity unit recognition on the text to be processed using a general large model based on the text to be processed to obtain a first probability distribution corresponding to a first dictionary, and to perform entity unit recognition on the text to be processed using a recognition large model to obtain a second probability distribution corresponding to the first dictionary, wherein the first dictionary includes a plurality of candidate entity units;
[0448] A first obtaining module 1303 is used to obtain a target entity unit in the text to be processed based on the first probability distribution and the second probability distribution;
[0449] A first classification module 1304 is used to classify the target entity unit using the general large model based on the text to be processed and the target entity unit to obtain a third probability distribution corresponding to the second dictionary, and to classify the target entity unit using the classification large model to obtain a fourth probability distribution corresponding to the second dictionary, wherein the second dictionary includes multiple candidate categories;
[0450] A second obtaining module 1305 is used to obtain a target category of the target entity unit based on the third probability distribution and the fourth probability distribution;
[0451] The third obtaining module 1306 is used to obtain the extraction result of the text to be processed based on the target entity unit and the target category of the target entity unit.
[0452] In a possible implementation, the recognition model is trained based on the similarity between the first predicted entity unit and the entity label of each first sample; the classification model is trained based on the similarity between the second predicted category and the category label of each second sample;
[0453] The general large model is trained based on the similarity between the third extraction results of each third sample and the sample label, the third extraction result includes a third predicted entity unit and a third category, and the sample label includes an entity label and a category label of the third sample.
[0454] In one possible implementation, the device further includes:
[0455] A second classification module is used to perform entity unit recognition on the text to be processed by using a large classification model based on the text to be processed, so as to obtain a fifth probability distribution corresponding to the first dictionary;
[0456] A second recognition module is used to classify the target entity unit using the recognition large model based on the text to be processed and the target entity unit, so as to obtain a sixth probability distribution corresponding to the second dictionary;
[0457] The first obtaining module 1303, when obtaining the target entity unit in the to-be-processed text based on the first probability distribution and the second probability distribution, is used to:
[0458] Based on the first probability distribution, the second probability distribution and the fifth probability distribution, acquiring the target entity unit;
[0459] The second obtaining module 1305, when obtaining the target category of the target entity unit based on the third probability distribution and the fourth probability distribution, is used to:
[0460] Based on the third probability distribution, the fourth probability distribution and the sixth probability distribution, a target category corresponding to the target entity unit is obtained.
[0461] In one possible implementation, the device further includes:
[0462] The second acquisition module is used to obtain the prompt text of the extraction task;
[0463] The prompt text includes a recognition prompt word and a classification prompt word. The recognition prompt word indicates to recognize entity units in a target field in the text to be processed, and the classification prompt word indicates to classify the recognized entity units.
[0464] In a possible implementation, the first probability distribution is obtained by using a general large model to perform entity unit recognition on the text to be processed based on the text to be processed and the recognition prompt word; the second probability distribution is obtained by using a general large model to perform entity unit recognition on the text to be processed based on the text to be processed and the recognition prompt word;
[0465] Among them, the third probability distribution is obtained by classifying the target entity unit based on the text to be processed, the target entity unit and the classification prompt words using a general large model; the fourth probability distribution is obtained by classifying the target entity unit based on the text to be processed, the target entity unit and the classification prompt words using a classification large model.
[0466] In a possible implementation, the first obtaining module 1303 is specifically configured to:
[0467] Determining a first recognition error of the second probability distribution based on a similarity between the first probability distribution and the second probability distribution;
[0468] determining a first adjusted probability for the first probability distribution based on a difference between the second probability distribution and the first identification error;
[0469] Adjusting the first probability distribution based on the first adjusted probability to obtain a first target probability distribution;
[0470] Based on the first target probability distribution, the target entity unit is obtained.
[0471] In a possible implementation, the first obtaining module 1303 is specifically configured to:
[0472] Determining a first recognition error of the second probability distribution based on a similarity between the first probability distribution and the second probability distribution;
[0473] determining a second recognition error of the fifth probability distribution based on a similarity between the first probability distribution and the fifth probability distribution;
[0474] determining a first adjusted probability for the first probability distribution based on a difference between the second probability distribution and the first identification error;
[0475] adjusting the first probability distribution based on the first adjusted probability;
[0476] Determining a second target probability distribution based on a difference between the adjusted first probability distribution and the second recognition error;
[0477] Based on the second target probability distribution, the target entity unit is obtained.
[0478] In a possible implementation, the first probability distribution and the second probability distribution are obtained in the following manner:
[0479] Based on the text to be processed, a general large model is used to perform entity unit recognition on the text to be processed to obtain a first initial probability distribution corresponding to the first dictionary, and a recognition large model is used to perform entity unit recognition on the text to be processed to obtain a second initial probability distribution corresponding to the first dictionary;
[0480] The first initial probability distribution includes the first initial probability of each candidate entity unit, and the second initial probability includes the second initial probability of each candidate entity unit;
[0481] Based on the first initial probability distribution and the second initial probability distribution, determining, from the candidate entity units, a target candidate unit whose first initial probability and second initial probability are both not lower than a target threshold;
[0482] The probabilities corresponding to the non-target candidate units in the first initial probability distribution and the second initial probability distribution are eliminated respectively to obtain the first probability distribution and the second probability distribution.
[0483] In a possible implementation, the text to be processed includes a plurality of target entity units, and the extraction result includes a plurality of target entity units and target categories of the target entity units;
[0484] The extraction result is generated by executing n tasks, each task is a recognition task or a classification task, and the generated text of each task is the target entity unit or target category;
[0485] The execution process of the i-th task includes:
[0486] Based on the generated text of the i-1th task, determine the text type of the text to be generated, the text type is a recognition type or a classification type, and the text type corresponding to the first task is a recognition type;
[0487] Based on the text to be processed and the generated text of the previous i-1 tasks, a general large model is used to obtain a general probability distribution, a recognition large model is used to obtain a recognition probability distribution, and a classification large model is used to obtain a classification probability distribution;
[0488] Wherein, the general probability distribution is the first probability distribution or the third probability distribution, the recognition probability distribution is the second probability distribution or the sixth probability distribution, and the classification probability distribution is the fourth probability distribution or the fifth probability distribution;
[0489] Based on the general probability distribution, the recognition probability distribution and the classification probability distribution, a generated text for the i-th task is generated.
[0490] In a possible implementation, the device further includes a first training module, and the first training module, when training the recognition large model, includes:
[0491] A first acquisition unit is used to acquire a first training set, where the first training set includes a plurality of first sample texts with sample labels, where the sample label of each first sample includes an entity label of the first sample;
[0492] A first recognition unit is used to perform entity unit recognition on each first sample based on each first sample by using a recognition large model to be trained to obtain a first predicted entity unit of each first sample;
[0493] A first classification unit is used to classify the first prediction entity unit based on each first sample and the first prediction entity unit using the recognition large model to be trained to obtain a first prediction category of the first prediction entity unit, and to obtain an extraction result of each first sample based on the first prediction entity unit and the first prediction category of each first sample;
[0494] The first training unit is used to determine a first training loss based on the similarity between the first predicted entity unit and the entity label of each first sample, and fine-tune the model parameters of the large recognition model to be trained based on the first training loss.
[0495] In a possible implementation, the device further includes a second training module, and the second training module, when training the large classification model, includes:
[0496] A second acquisition unit is used to acquire a second training set, where the second training set includes a plurality of second samples with sample labels, where the sample label of each second sample includes a category label of each entity label of the second sample;
[0497] A second recognition unit is used to perform entity unit recognition on each second sample based on each second sample by using the classification large model to be trained to obtain a second predicted entity unit of each second sample;
[0498] A second classification unit is used to classify the second prediction entity unit based on each second sample and the second prediction entity unit using the classification large model to be trained to obtain a second prediction category of the second prediction entity unit, and to obtain an extraction result of each second sample based on the second prediction entity unit and the second prediction category of each second sample;
[0499] The second training unit is used to determine a second training loss based on the similarity between the second predicted category and the category label of each second sample, and fine-tune the model parameters of the large classification model to be trained based on the second training loss.
[0500] In a possible implementation, the device further includes a third training module, and the third training module, when training the general large model, includes:
[0501] a third acquisition unit, configured to acquire a third training set, wherein the third training set includes a plurality of third samples with sample labels, wherein the sample label of each third sample includes an entity label of the third sample and a category label of each entity label;
[0502] A third recognition unit is used to perform entity unit recognition on each third sample by using the general large model to be trained based on each third sample to obtain a third predicted entity unit of each third sample;
[0503] a third classification unit, configured to classify the third prediction entity unit based on each third sample and the third prediction entity unit by using the general large model to be trained to obtain a third prediction category of the third prediction entity unit, and obtain an extraction result of each third sample based on the third prediction entity unit and the third prediction category of each third sample;
[0504] The third training unit is used to determine a third training loss based on the similarity between the third extraction results of each third sample and the sample label, and fine-tune the model parameters of the general large model to be trained based on the third training loss.
[0505] The text processing method based on the large model of the present application is based on the text to be processed, and the general large model is used to identify the entity unit to obtain the first probability distribution, and the recognition large model is used to identify the entity unit to obtain the second probability distribution. Based on the first probability distribution and the second probability distribution, the target entity unit in the text to be processed is obtained; so that during recognition, the recognition ability of the recognition large model can be used to reduce the illusion caused by the classification ability in the recognition task of the general large model, and improve the accuracy of recognition. In addition, based on the text to be processed and the target entity unit, the general large model is used to classify the target entity unit to obtain a third probability distribution, and the classification large model is used to classify to obtain a fourth probability distribution, and the target category is obtained based on the third probability distribution and the fourth probability distribution; so that during classification, the classification ability of the classification large model can be further used to reduce the illusion caused by the recognition ability in the classification task of the general large model, and improve the accuracy of classification. By decomposing the extraction into different processes of recognition and classification, and rotating the recognition ability or classification ability of different large models in different processes, the accuracy of the extraction results can be further improved.
[0506] The device of the embodiments of the present application can execute the method provided by the embodiments of the present application, and the implementation principles are similar. The actions performed by each module in the device of each embodiment of the present application correspond to the steps in the method of each embodiment of the present application. For the detailed functional description of each module of the device, please refer to the description in the corresponding method shown in the previous text, which will not be repeated here.
[0507] Fig.14 1 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig.14 As shown, the electronic device includes: a memory, a processor and a computer program stored in the memory, and the processor executes the above computer program to implement the steps of the text processing method based on the large model.
[0508] In an alternative embodiment, an electronic device is provided, such as Fig.14 As shown, Fig.14 The electronic device 1400 shown includes: a processor 1401 and a memory 1403. The processor 1401 and the memory 1403 are connected, such as through a bus 1402. Optionally, the electronic device 1400 may also include a transceiver 1404, which may be used for data interaction between the electronic device and other electronic devices, such as data transmission and / or data reception. It should be noted that in actual applications, the transceiver 1404 is not limited to one, and the structure of the electronic device 1400 does not constitute a limitation on the embodiments of the present application.
[0509] Processor 1401 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It may implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 1401 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like.
[0510] The bus 1402 may include a path to transmit information between the above components. The bus 1402 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus 1402 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.14 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0511] The memory 1403 may be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), magnetic disk storage medium\other magnetic storage devices, or any other medium that can be used to carry or store computer programs and can be read by a computer, without limitation herein.
[0512] The memory 1403 is used to store the computer program for executing the embodiment of the present application, and the execution is controlled by the processor 1401. The processor 1401 is used to execute the computer program stored in the memory 1403 to implement the steps shown in the above method embodiment.
[0513] Among them, electronic equipment includes but is not limited to: servers, terminals or cloud computing center equipment, etc.
[0514] An embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps and corresponding contents of the aforementioned method embodiment can be implemented.
[0515] The embodiment of the present application also provides a computer program product, including a computer program, which can implement the steps and corresponding contents of the aforementioned method embodiment when executed by a processor.
[0516] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories), or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0517] Those skilled in the art will appreciate that, unless otherwise stated, the singular forms "a", "an", "said", and "the" used herein may also include plural forms. The terms "include" and "comprise" used in the embodiments of the present application mean that the corresponding features can be implemented as the presented features, information, data, steps, and operations, but do not exclude the implementation as other features, information, data, steps, operations, etc. supported by the technical field.
[0518] The terms "first", "second", "third", "fourth", "1", "2", etc. (if any) in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than that shown or described in the drawings.
[0519] It should be understood that, although each operation step is indicated by arrows in the flowchart of the embodiment of the present application, the implementation order of these steps is not limited to the order indicated by the arrows. Unless clearly stated herein, in some implementation scenarios of the embodiment of the present application, the implementation steps in each flowchart can be performed in other orders according to demand. In addition, some or all of the steps in each flowchart may include multiple sub-steps or multiple stages based on actual implementation scenarios. Some or all of these sub-steps or stages may be executed at the same time, and each sub-step or stage in these sub-steps or stages may also be executed at different times respectively. In different scenarios of execution time, the execution order of these sub-steps or stages may be flexibly configured according to demand, and the embodiment of the present application does not limit this.
[0520] The above is only an optional implementation method for some implementation scenarios of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the technical concept of the solution of the present application, other similar implementation methods based on the technical ideas of the present application are also within the protection scope of the embodiments of the present application.
Claims
1. A text processing method based on a large model, characterized in that: The method comprises: Get the text to be processed; Based on the text to be processed, a general large model is used to perform entity unit recognition on the text to be processed to obtain a first probability distribution corresponding to a first dictionary, and a recognition large model is used to perform entity unit recognition on the text to be processed to obtain a second probability distribution corresponding to the first dictionary, wherein the first dictionary includes a plurality of candidate entity units; Based on the text to be processed, the classification large model is used to perform entity unit recognition on the text to be processed, and a fifth probability distribution corresponding to the first dictionary is obtained; the recognition large model is trained based on the similarity between the first predicted entity unit and the entity label of each first sample; the classification large model is trained based on the similarity between the second predicted category and the category label of each second sample; the general large model is trained based on the similarity between the third extraction result and the sample label of each third sample, the third extraction result includes the third predicted entity unit and the third category, and the sample label includes the entity label and the category label of the third sample; Based on the first probability distribution, the second probability distribution and the fifth probability distribution, a target entity unit is obtained; based on the text to be processed and the target entity unit, the target entity unit is classified using the general large model to obtain a third probability distribution corresponding to a second dictionary, and the target entity unit is classified using the classification large model to obtain a fourth probability distribution corresponding to the second dictionary, wherein the second dictionary includes a plurality of candidate categories; Based on the text to be processed and the target entity unit, the target entity unit is classified using the recognition large model to obtain a sixth probability distribution corresponding to the second dictionary; Based on the third probability distribution, the fourth probability distribution and the sixth probability distribution, obtaining a target category corresponding to the target entity unit; Based on the target entity unit and the target category of the target entity unit, an extraction result of the text to be processed is obtained.
2. The method according to claim 1, characterized in that The method further comprises: Get the prompt text of the extraction task; The prompt text includes recognition prompt words and classification prompt words, the recognition prompt words indicate to recognize entity units in the target field in the text to be processed, and the classification prompt words indicate to classify the recognized entity units.
3. The method according to claim 2, characterized in that in, The first probability distribution is obtained by using a general large model to perform entity unit recognition on the text to be processed and the recognition prompt word; the second probability distribution is obtained by using a general large model to perform entity unit recognition on the text to be processed and the recognition prompt word; Among them, the third probability distribution is obtained by classifying the target entity unit based on the text to be processed, the target entity unit and the classification prompt words using a general large model; the fourth probability distribution is obtained by classifying the target entity unit based on the text to be processed, the target entity unit and the classification prompt words using a classification large model.
4. The method according to claim 1, characterized in that The acquiring the target entity unit based on the first probability distribution, the second probability distribution and the fifth probability distribution includes: determining a first recognition error of the second probability distribution based on a similarity between the first probability distribution and the second probability distribution; determining a second recognition error of the fifth probability distribution based on a similarity between the first probability distribution and a fifth probability distribution; determining a first adjusted probability for the first probability distribution based on a difference between the second probability distribution and the first identification error; adjusting the first probability distribution based on the first adjusted probability; determining a second target probability distribution based on a difference between the adjusted first probability distribution and the second recognition error; Based on the second target probability distribution, the target entity unit is obtained.
5. The method according to any one of claims 1 to 4, characterized in that The first probability distribution and the second probability distribution are obtained in the following manner: Based on the text to be processed, a general large model is used to perform entity unit recognition on the text to be processed to obtain a first initial probability distribution corresponding to a first dictionary, and a recognition large model is used to perform entity unit recognition on the text to be processed to obtain a second initial probability distribution corresponding to the first dictionary; The first initial probability distribution includes the first initial probability of each candidate entity unit, and the second initial probability includes the second initial probability of each candidate entity unit; Based on the first initial probability distribution and the second initial probability distribution, determining, from the candidate entity units, a target candidate unit whose first initial probability and second initial probability are both not lower than a target threshold; The probabilities corresponding to the non-target candidate units in the first initial probability distribution and the second initial probability distribution are eliminated respectively to obtain the first probability distribution and the second probability distribution.
6. The method according to claim 1, characterized in that The text to be processed includes a plurality of target entity units, and the extraction result includes a plurality of target entity units and target categories of the target entity units; The extraction result is generated by executing n tasks, each task is a recognition task or a classification task, and the generated text of each task is a target entity unit or a target category; The execution process of the i-th task includes: Based on the generated text of the i-1th task, determine the text type of the text to be generated, the text type is a recognition type or a classification type, and the text type corresponding to the first task is a recognition type; Based on the text to be processed and the generated text of the previous i-1 tasks, a general large model is used to obtain a general probability distribution, a recognition large model is used to obtain a recognition probability distribution, and a classification large model is used to obtain a classification probability distribution; Wherein, the general probability distribution is the first probability distribution or the third probability distribution, the recognition probability distribution is the second probability distribution or the sixth probability distribution, and the classification probability distribution is the fourth probability distribution or the fifth probability distribution; Based on the general probability distribution, the recognition probability distribution and the classification probability distribution, a generated text for the i-th task is generated.
7. The method according to any one of claims 1 to 4, characterized in that The recognition large model is trained by the following method: Obtain a first training set, wherein the first training set includes a plurality of first sample texts with sample labels, and the sample label of each first sample includes an entity label of the first sample; Based on each first sample, use the recognition large model to be trained to perform entity unit recognition on each first sample to obtain a first predicted entity unit of each first sample; Based on each of the first samples and the first prediction entity unit, the first prediction entity unit is classified using the recognition large model to be trained to obtain a first prediction category of the first prediction entity unit, and based on the first prediction entity unit and the first prediction category of each of the first samples, an extraction result of each of the first samples is obtained; Based on the similarity between the first predicted entity unit and the entity label of each first sample, a first training loss is determined, and based on the first training loss, model parameters of the recognition large model to be trained are fine-tuned.
8. The method according to any one of claims 1 to 5, characterized in that The classification model is trained in the following way: Obtaining a second training set, where the second training set includes a plurality of second samples with sample labels, and the sample label of each second sample includes a category label of each entity label of the second sample; Based on each second sample, use the classification model to be trained to perform entity unit recognition on each second sample to obtain a second predicted entity unit of each second sample; Based on each second sample and the second prediction entity unit, the second prediction entity unit is classified using the classification model to be trained to obtain a second prediction category of the second prediction entity unit, and based on the second prediction entity unit and the second prediction category of each second sample, an extraction result of each second sample is obtained; Based on the similarity between the second predicted category and the category label of each second sample, a second training loss is determined, and model parameters of the large classification model to be trained are fine-tuned based on the second training loss.
9. The method according to any one of claims 1 to 4, characterized in that: The general large model is trained in the following way: Acquire a third training set, where the third training set includes a plurality of third samples with sample labels, where the sample label of each third sample includes an entity label of the third sample and a category label of each entity label; Based on each third sample, use the general large model to be trained to perform entity unit recognition on each third sample to obtain a third predicted entity unit of each third sample; Based on each of the third samples and the third prediction entity unit, the third prediction entity unit is classified using the general large model to be trained to obtain a third prediction category of the third prediction entity unit, and based on the third prediction entity unit and the third prediction category of each of the third samples, an extraction result of each of the third samples is obtained; Based on the similarity between the third extraction results of each third sample and the sample label, a third training loss is determined, and based on the third training loss, model parameters of the general large model to be trained are fine-tuned.
10. A text processing device based on a large model, characterized in that: include: A first acquisition module, used to acquire the text to be processed; A first recognition module is used to perform entity unit recognition on the text to be processed using a general large model based on the text to be processed to obtain a first probability distribution corresponding to a first dictionary, perform entity unit recognition on the text to be processed using a recognition large model to obtain a second probability distribution corresponding to the first dictionary, wherein the first dictionary includes a plurality of candidate entity units; and perform entity unit recognition on the text to be processed using a classification large model based on the text to be processed to obtain a fifth probability distribution corresponding to the first dictionary; A first acquisition module is used to obtain the target entity unit based on the first probability distribution, the second probability distribution and the fifth probability distribution; the recognition large model is obtained by training based on the similarity between the first predicted entity unit and the entity label of each first sample; the classification large model is obtained by training based on the similarity between the second predicted category and the category label of each second sample; the general large model is obtained by training based on the similarity between the third extraction result and the sample label of each third sample, the third extraction result includes the third predicted entity unit and the third category, and the sample label includes the entity label and the category label of the third sample; A first classification module is used to classify the target entity unit based on the text to be processed and the target entity unit using the general large model to obtain a third probability distribution corresponding to the second dictionary, and to classify the target entity unit using the classification large model to obtain a fourth probability distribution corresponding to the second dictionary, wherein the second dictionary includes a plurality of candidate categories; based on the text to be processed and the target entity unit, the target entity unit is classified using the recognition large model to obtain a sixth probability distribution corresponding to the second dictionary; A second obtaining module, used for obtaining a target category corresponding to the target entity unit based on the third probability distribution, the fourth probability distribution and the sixth probability distribution; The third obtaining module is used to obtain the extraction result of the text to be processed based on the target entity unit and the target category of the target entity unit.
11. An electronic device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the large model-based text processing method according to any one of claims 1 to 9.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the large model-based text processing method according to any one of claims 1 to 9 is implemented.
13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the large model-based text processing method according to any one of claims 1 to 9 is implemented.
