Intelligent event text labeling method and device based on pre-training model
By using pre-trained models in event text intelligent annotation combined with natural language processing and deterministic policy gradient modules, the annotation strategy is optimized, and the problems of diversified event types and insufficient sample data in the existing technology are solved, and the accuracy of annotation and the ability to identify a few classes are improved.
Patent Information
- Application Number
- CN202411881511.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-19
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2044-12-19
AI Technical Summary
The existing intelligent annotation technology of event text faces the problems of diverse event types and insufficient sample data, which leads to high difficulty in model training and poor labeling effect, especially the labeling accuracy of a few classes.
The pre-trained model-based event text intelligent annotation method is adopted, and the pre-trained event text annotation model is loaded. The model includes a natural language processing sub-model and a deterministic policy gradient module. The annotation decision network is used to make sequence annotation decisions and optimize the annotation strategy to improve the annotation accuracy.
By combining natural language processing sub-model and deterministic strategy gradient module, the labeling strategy is optimized, which significantly improves the accuracy of event text annotation and improves the labeling ability of a few classes.
Smart Images

Figure CN119807394A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent annotation, and in particular to a method and device for intelligent annotation of event text based on a pre-training model. Background Art
[0002] Event text intelligent annotation is a method that uses artificial intelligence technology to automatically and efficiently annotate and classify events. Through training models and algorithms, the system can automatically identify and annotate key information in events, such as time, location, participants, behavior, etc., to help users quickly understand the important content and background information of the event.
[0003] At present, event labeling is difficult due to the large number of event types and small amount of sample data in the field of intelligent labeling. The existing event text intelligent labeling technology faces complex event information, and the model training is difficult and the labeling effect is poor. The performance of existing intelligent labeling technology depends largely on the quality and quantity of training data. If the training data is insufficient or of low quality, the model may not be able to learn enough features to accurately perform labeling tasks. In some cases, some categories in the dataset may have more samples than other categories, which causes the model to be biased towards the majority class, thereby affecting the accuracy of labeling the minority class. Summary of the invention
[0004] The present invention provides a method and device for intelligently annotating event text based on a pre-training model, so as to improve the accuracy of event text annotation.
[0005] According to one aspect of the present invention, a method for intelligently annotating event text based on a pre-trained model is provided, comprising:
[0006] Loading a pre-trained event text annotation model, wherein the event text annotation model includes a natural language processing sub-model and a deterministic policy gradient module, wherein the deterministic policy gradient module includes an annotation decision network;
[0007] Acquire the event text to be annotated and the status information of the event text to be annotated, input the event text to be annotated into the natural language processing sub-model for recognition, and obtain the text features of the event text to be annotated;
[0008] The text features and the state information are input into the labeling decision network to make a sequence labeling decision, determine the labeling decision of the event text to be labeled, and label the event text to be labeled based on the labeling decision.
[0009] According to another aspect of the present invention, there is provided an event text intelligent annotation device based on a pre-trained model, comprising:
[0010] An event text annotation model loading module, used to load a pre-trained event text annotation model, wherein the event text annotation model includes a natural language processing sub-model and a policy gradient module;
[0011] A text feature recognition module, used to obtain the event text to be annotated and the status information of the event text to be annotated, input the event text to be annotated into the natural language processing sub-model for recognition, and obtain the text features of the event text to be annotated;
[0012] The event text annotation module is used to input the text features and the state information into the annotation decision network to make a sequence annotation decision, determine the annotation decision of the event text to be annotated, and annotate the event text to be annotated based on the annotation decision.
[0013] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0014] at least one processor; and
[0015] a memory communicatively connected to the at least one processor; wherein,
[0016] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the event text intelligent annotation method based on the pre-training model described in any embodiment of the present invention.
[0017] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the event text intelligent annotation method based on a pre-trained model described in any embodiment of the present invention when executed.
[0018] The technical solution of the embodiment of the present invention is to load a pre-trained event text annotation model, the event text annotation model includes a natural language processing sub-model and a deterministic policy gradient module, and the deterministic policy gradient module includes an annotation decision network; obtain the event text to be annotated and the state information of the event text to be annotated, input the event text to be annotated into the natural language processing sub-model for recognition, and obtain the text features of the event text to be annotated; input the text features and state information into the annotation decision network for sequence annotation decision, determine the annotation decision of the event text to be annotated, and annotate the event text to be annotated based on the annotation decision. The natural language processing sub-model and the deterministic policy gradient module are combined, and the annotation strategy of the deterministic policy gradient module is continuously optimized through pre-training, thereby improving the accuracy of event text annotation.
[0019] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0021] Figure 1 It is a flow chart of an event text intelligent annotation method based on a pre-training model provided in the first embodiment of the present invention;
[0022] Figure 2 is a framework diagram of an event text annotation model provided in Embodiment 1 of the present invention;
[0023] Figure 3 is a labeling schematic diagram of the BIO sequence labeling mechanism provided in the first embodiment of the present invention;
[0024] Figure 4 It is a structural schematic diagram of an event text intelligent annotation device based on a pre-training model provided in Embodiment 2 of the present invention;
[0025] Figure 5 It is a structural schematic diagram of an electronic device provided in Embodiment 3 of the present invention. DETAILED DESCRIPTION
[0026] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention 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 data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0028] Embodiment 1
[0029] Figure 1 This is a flowchart of a method for intelligently annotating event text based on a pre-trained model provided in the first embodiment of the present invention. This embodiment is applicable to the case of annotating event text in an event text intelligent annotation task. The method can be executed by an intelligently annotating event text based on a pre-trained model. The intelligently annotating event text based on a pre-trained model can be implemented in the form of hardware and / or software. The intelligently annotating event text based on a pre-trained model can be configured in electronic devices such as computers or servers. Figure 1 As shown, the method includes:
[0030] S110, loading a pre-trained event text annotation model, wherein the event text annotation model includes a natural language processing sub-model and a deterministic policy gradient module, and the deterministic policy gradient module includes a annotation decision network.
[0031] In an embodiment of the present invention, the event text annotation model includes a natural language processing sub-model and a deterministic policy gradient module. The natural language processing sub-model is used to provide semantic understanding, and the deterministic policy gradient module is used to provide a dynamically optimized annotation strategy. Specifically, the natural language processing sub-model includes but is not limited to models such as BERT, ERNIE, and RoBERTa. The deterministic policy gradient module includes an annotation decision network and a value network. The annotation decision network and the value network are usually neural networks. The annotation decision network is used to learn deterministic strategies and output the annotation strategy of the event text; the value network is used to evaluate the value of the annotation strategy output by the annotation decision network.
[0032] On the basis of the above embodiments, optionally, the training method of the event text annotation model includes: obtaining sample data of the event text annotation task, the sample data including the first round of labeled sample data and the first round of unlabeled sample data; iteratively performing the following steps to obtain a trained event text annotation model when the first iteration stop condition is met: training the event text annotation model based on the labeled sample data of the current round to obtain an updated event text annotation model; predicting the unlabeled sample data of the current round based on the updated event text annotation model to obtain the label probability distribution of each unlabeled sample data of the current round; sampling and annotating the unlabeled sample data of the current round based on the label probability distribution of each unlabeled sample data of the current round to obtain labeled sample data of the next round.
[0033] In an embodiment of the present invention, the training process of the event text annotation model is as follows:
[0034] 1) Obtain sample data for the event text annotation task, the sample data includes the first round of annotated sample data and the first round of unlabeled sample data. The sample data is event text data, the sample data includes annotated sample data and unlabeled sample data, the number of annotated sample data is less than the number of unlabeled sample data, and the annotated sample data is used as the first round of training data.
[0035] 2) Execute the following steps 2.1-2.3, and obtain the trained event text annotation model when the first iteration stop condition is met:
[0036] 2.1) The event text annotation model is trained based on the annotated sample data of the current round to obtain an updated event text annotation model.
[0037] 2.2) Based on the updated event text annotation model, the unlabeled sample data of the current round is predicted to obtain the label probability distribution of each unlabeled sample data of the current round; wherein, the label probability distribution includes the probability that each character or word in the unlabeled sample data belongs to each label category, and for each character or word in the unlabeled sample data, the sum of the probabilities of each label category is 1. Specifically, the label probability distribution is related to the annotation mechanism used. For example, taking the BIO annotation mechanism as an example, the label probability distribution includes the probability that each character or word in the unlabeled sample data belongs to the three label categories of "B", "I" and "O".
[0038] 2.3) Based on the label probability distribution of each unlabeled sample data in the current round, the unlabeled sample data of the current round is sampled, and the sampled unlabeled sample data is labeled to obtain the labeled sample data of the next round. It should be noted that the unlabeled sample data obtained by sampling is the sample that is most helpful for model improvement.
[0039] It should be noted that the first iteration stop condition may be that all sample data have been labeled. Specifically, when all sample data have been labeled, the iteration is stopped to obtain a trained event text labeling model.
[0040] On the basis of the above embodiment, optionally, the event text annotation model is trained based on the annotated sample data to obtain an updated event text annotation model, including: fine-tuning the natural language processing sub-model based on the annotated sample data, identifying the annotated sample data based on the fine-tuned natural language processing sub-model, and extracting sample features of the annotated sample data; at each time step, inputting the sample features and the current state information of the annotated sample data into the annotation decision network for sequence annotation decision, obtaining an annotation decision for the current state of the annotated sample data, and interacting with the annotated sample data based on the annotation decision to determine an empirical data sample, and storing the empirical data sample The experience data samples are stored in the experience buffer; wherein the experience data samples include the current state information, the annotation decision, the reward value and the next state information; the following steps are iteratively performed to obtain the updated event text annotation model when the second iteration stop condition is met: a batch of experience data samples are obtained from the experience buffer, and the loss function of the value network is determined based on the batch of experience data samples; the network parameters of the value network are updated based on the loss function of the value network; the annotation decision is evaluated based on the updated value network to obtain the value of the annotation decision, the gradient of the annotation decision network is determined based on the value of the annotation decision, and the annotation decision network is updated based on the gradient.
[0041] Figure 2 is a framework diagram of the event text annotation model provided in the first embodiment of the present invention, following the Figure 2 The model framework shown in the embodiment of the present invention, the training process of each round of the event text annotation model is as follows:
[0042] 1) Fine-tune the pre-trained natural language processing sub-model based on the labeled sample data to adapt the natural language processing sub-model to the characteristics of the event text labeling task;
[0043] 2) Based on the fine-tuned natural language processing sub-model, the labeled sample data is identified and the sample features of the labeled sample data are extracted; wherein the sample features contain key information about the semantics and event structure of the labeled text data, specifically, the sample features include event trigger words, arguments and the predicted labels of each character or word in the labeled text data.
[0044] 3) At each time step, the sample features and the current state information of the labeled sample data are input into the labeling decision network for sequence labeling decision, and the labeling decision of the current state of the labeled sample data is obtained, and the labeling decision is executed in the labeled sample data, and the reward value and the next state information are determined based on the labeled sample data after execution, and the experience data sample is formed based on the current state information, the labeling decision, the reward value and the next state information, and the experience data sample is stored in the experience buffer.
[0045] Among them, the current state information is used to provide a reference for the current labeling decision. Specifically, the current state information includes the length of the text in the labeled sample data, the types of vocabulary contained, the syntactic structure, etc., as well as the accuracy of the labeled part of the labeled sample data, the labeling style, etc., which are not limited here. The labeling decision consists of continuous labeling actions, and each labeling action corresponds to the labeling type of a character or word in the labeled text data. The next state information is the state information of the labeled sample data after the labeling decision is executed. The reward value is used as a reward signal to guide the learning direction of the labeling decision network. The closer the true label of the labeled sample number is to the label corresponding to the labeling decision given by the labeling decision network, the greater the reward value. Specifically, the reward function of the reward value includes:
[0046]
[0047] Among them, R represents the reward value, n represents the number of characters and / or words in the labeled sample data, and y i represents the true label of the i-th character or word in the labeled sample data, x i represents the label corresponding to the labeling decision of the i-th character or word in the labeled sample data, I(·) is an indicator function. When y i =x i If true, the indicator function takes the value 1, otherwise it takes the value 0.
[0048] On the basis of the above embodiment, optionally, the sequence annotation mechanism used in the process of sequence annotation decision is a sequence annotation mechanism of word granularity. Specifically, the sequence annotation mechanism of word granularity includes but is not limited to BIO annotation mechanism, BIOES annotation mechanism, BMES annotation mechanism, etc., which are not limited here. Taking the BIO annotation mechanism as an example, in the event text intelligent annotation task, we use the BIO sequence annotation mechanism to identify entities related to events in the text, including trigger words and arguments. The trigger word is the word in the sentence that causes the event to occur. It is the key to understanding the event in the sentence and also represents the type of event. The arguments around it provide detailed information about the action or event. The argument refers to the word associated with the trigger word, and the rim provides the necessary information for the trigger word, such as participants, time, place, etc. The BIO sequence annotation mechanism provides a label of "B", "I" or "O" for each word or word in the sentence.
[0049] The event text annotation model uses the following rules to identify event information such as trigger words and arguments in event texts to complete the task of intelligent annotation:
[0050] B-label: used to mark the first word of the trigger word or argument.
[0051] I-tag: used to mark the subsequent words of a trigger word or argument.
[0052] O-tags: used to mark words that are not part of any trigger word or argument.
[0053] like Figure 3 As shown, Figure 3 This is the BIO annotation corresponding to the event text "John attended the meeting on the 29th". The BIO sequence annotation mechanism can help the model understand and extract event structure information in the text in the event text intelligent annotation, laying the foundation for further event analysis and information extraction.
[0054] 4) Iterate the following steps 4.1-4.2 to obtain an updated event text annotation model when the second iteration stop condition is met:
[0055] 4.1) Obtain a batch of experience data samples from the experience buffer, determine the loss function of the value network based on the batch of experience data samples; update the network parameters of the value network based on the loss function of the value network.
[0056] 4.2) Evaluate the labeling decision based on the updated value network to obtain the value of the labeling decision, determine the gradient of the labeling decision network based on the value of the labeling decision, and update the labeling decision network based on the gradient.
[0057] It should be noted that the second iteration stop condition may be whether the loss function of the value network converges. Specifically, when the loss function of the value network converges, the iteration is stopped to obtain an updated event text annotation model. The updated event text annotation model includes a fine-tuned natural language processing sub-model and a deterministic policy gradient module obtained by iterative training.
[0058] On the basis of the above embodiment, optionally, the loss function of the value network is determined based on the batch of experience data samples, including: for each experience data sample, evaluating the labeling decision based on the value network to obtain the predicted value of the labeling decision; and determining the target value based on the reward value, the discount factor and the maximum value of the next state; and determining the loss function of the value network based on the predicted value of the labeling decision and the target value.
[0059] In the embodiment of the present invention, for each experience data sample, the labeling decision is evaluated based on the value network to obtain the predicted value of the labeling decision; and the target value is determined based on the reward value, the discount factor and the maximum value of the next state. Specifically, the calculation formula of the target value is as follows:
[0060] y=r+γa′maxQ(s′,a′);
[0061] Among them, y represents the target value, r represents the reward value, γ is the discount factor, which usually ranges from 0 to 1, and Q(s′, a′) is the maximum value of the next state s′-labeled decision a′.
[0062] Further, the loss function of the value network is determined based on the predicted value and target value of the labeling decision. The loss function of the value network is used to measure the error between the predicted value and the target value of the value network. Exemplarily, assuming that the loss function of the value network is a mean square error loss function, the loss function of the value network is as follows:
[0063]
[0064] Where N represents the number of empirical data samples, y i represents the target value of the i-th empirical data sample, Q(s i , a i ,θ) represents the prediction value of the i-th empirical data sample, s i represents the current state in the i-th experience data sample, a i represents the current state labeling decision in the i-th experience data sample, and θ represents the parameters of the value network.
[0065] On the basis of the above embodiment, optionally, the unlabeled sample data of the current round is sampled and labeled based on the label probability distribution of each unlabeled sample data of the current round to obtain labeled sample data of the next round, including: determining the uncertainty index value of the updated event text annotation model for each unlabeled sample data based on the label probability distribution of each unlabeled sample data of the current round, the uncertainty index value is used to measure the uncertainty of the label probability distribution of the unlabeled sample data; sampling and labeling the unlabeled sample data of the current round based on the uncertainty index corresponding to each unlabeled sample data to obtain labeled sample data of the next round.
[0066] Among them, the uncertainty index value is used to measure the uncertainty of the label probability distribution of unlabeled sample data. The uncertainty index can be the entropy of the label probability distribution. Specifically, the calculation formula of the entropy of the label probability distribution is as follows:
[0067] H(P(y|x))=-∑ c∈Y P(y=c|x)logP(y=c|x);
[0068] Among them, H represents the entropy of the label probability distribution, P(y|x) represents the label probability distribution, y represents the label category, x represents the unlabeled sample data, and Y represents the set of all possible label categories. It should be noted that the higher the entropy, the greater the uncertainty of the updated event text annotation model for the unlabeled sample data.
[0069] In an embodiment of the present invention, the entropy of the label probability distribution is calculated based on the label probability distribution of each unlabeled sample data in the current round, and the entropy of the label probability distribution is used as the uncertainty index value of the updated event text annotation model for each unlabeled sample data; the unlabeled sample data of the current round is sampled based on the uncertainty index corresponding to each unlabeled sample data, and the sampled unlabeled sample data is labeled to obtain labeled sample data for the next round.
[0070] The embodiment of the present invention realizes active learning by designing a query strategy. It selects sample data that is difficult to distinguish by the current model for labeling based on uncertainty sampling, and then continues to input the labeled sample data into the model for training. Continuous iteration gradually improves the performance of the model and the accuracy of data labeling.
[0071] S120: Acquire the event text to be annotated and the status information of the event text to be annotated, input the event text to be annotated into the natural language processing sub-model for recognition, and obtain the text features of the event text to be annotated.
[0072] Wherein, the event text to be annotated refers to the event text to be annotated. It should be noted that the type of the event text to be annotated is the same as the type of sample data used by the event text annotation model in the training process. The state information refers to the state information of the event text to be annotated when it is not annotated. Specifically, the state information is the semantic content and context information describing the event text to be annotated. In an embodiment of the present invention, the event text to be annotated and the state information of the event text to be annotated are obtained, and the event text to be annotated is input into the natural language processing sub-model for identification to obtain the text features of the event text to be annotated. Wherein, the text features of the event text to be annotated include the event trigger words, arguments and predicted labels of each character or word of the event text to be annotated.
[0073] S130: Input the text features and the state information into the labeling decision network to perform sequence labeling decision, determine the labeling decision of the event text to be labeled, and label the event text to be labeled based on the labeling decision.
[0074] In an embodiment of the present invention, text features and state information are input into a labeling decision network of a deterministic policy gradient module to make a sequence labeling decision, determine a labeling decision for an event text to be labeled, and label the event text to be labeled based on the labeling decision to achieve labeling of the event text to be labeled.
[0075] It should be noted that in some online learning or model update scenarios, the labeling strategy of the labeling decision network in the deterministic policy gradient module can be updated to adapt to the event text to be labeled or the task requirements. The labeling strategy update process is the same as the training process of each round of the above event text labeling model, which will not be repeated here.
[0076] The technical solution of this embodiment is to load a pre-trained event text annotation model, the event text annotation model includes a natural language processing sub-model and a deterministic policy gradient module, and the deterministic policy gradient module includes an annotation decision network; obtain the event text to be annotated and the state information of the event text to be annotated, input the event text to be annotated into the natural language processing sub-model for recognition, and obtain the text features of the event text to be annotated; input the text features and state information into the annotation decision network for sequence annotation decision, determine the annotation decision of the event text to be annotated, and annotate the event text to be annotated based on the annotation decision. The natural language processing sub-model and the deterministic policy gradient module are combined, and the annotation strategy of the deterministic policy gradient module is continuously optimized through training, thereby improving the accuracy of event text annotation.
[0077] Embodiment 2
[0078] Figure 4 Schematic diagram of the structure of an event text intelligent annotation device based on a pre-training model provided in the second embodiment of the present invention. Figure 4 As shown, the device comprises:
[0079] An event text annotation model loading module 210 is used to load a pre-trained event text annotation model, wherein the event text annotation model includes a natural language processing sub-model and a policy gradient module;
[0080] The text feature recognition module 220 is used to obtain the event text to be annotated and the status information of the event text to be annotated, input the event text to be annotated into the natural language processing sub-model for recognition, and obtain the text features of the event text to be annotated;
[0081] The event text annotation module 230 is used to input the text features and the state information into the annotation decision network to perform sequence annotation decision, determine the annotation decision of the event text to be annotated, and annotate the event text to be annotated based on the annotation decision.
[0082] The technical solution of this embodiment is to load a pre-trained event text annotation model, the event text annotation model includes a natural language processing sub-model and a deterministic policy gradient module, and the deterministic policy gradient module includes an annotation decision network; obtain the event text to be annotated and the state information of the event text to be annotated, input the event text to be annotated into the natural language processing sub-model for recognition, and obtain the text features of the event text to be annotated; input the text features and state information into the annotation decision network for sequence annotation decision, determine the annotation decision of the event text to be annotated, and annotate the event text to be annotated based on the annotation decision. The natural language processing sub-model and the deterministic policy gradient module are combined, and the annotation strategy of the deterministic policy gradient module is continuously optimized through training, thereby improving the accuracy of event text annotation.
[0083] Based on the above embodiment, optionally, the device further includes a training module of an event text annotation model, which is used to:
[0084] Acquire sample data of the event text annotation task, wherein the sample data includes annotated sample data of the first round and unlabeled sample data of the first round;
[0085] Iterate the following steps to obtain a trained event text annotation model when the first iteration stop condition is met:
[0086] The event text annotation model is trained based on the annotated sample data of the current round to obtain an updated event text annotation model;
[0087] Predicting the unlabeled sample data of the current round based on the updated event text annotation model to obtain the label probability distribution of each unlabeled sample data of the current round;
[0088] Based on the label probability distribution of each unlabeled sample data in the current round, the unlabeled sample data in the current round is sampled and labeled to obtain labeled sample data for the next round.
[0089] Based on the above embodiment, optionally, the deterministic policy gradient module further includes a value network for evaluating the value of the labeling decision output by the labeling decision network;
[0090] The training module of the event text annotation model is used to:
[0091] Fine-tune the natural language processing sub-model based on the labeled sample data, recognize the labeled sample data based on the fine-tuned natural language processing sub-model, and extract sample features of the labeled sample data;
[0092] At each time step, the sample features and the current state information of the labeled sample data are input into the labeling decision network to perform a sequence labeling decision, and a labeling decision of the current state of the labeled sample data is obtained, and based on the labeling decision, the labeled sample data is interacted with to determine an experience data sample, and the experience data sample is stored in an experience buffer; wherein the experience data sample includes the current state information, the labeling decision, the reward value and the next state information;
[0093] The following steps are iteratively performed to obtain the updated event text annotation model when the second iteration stop condition is met:
[0094] Acquire a batch of experience data samples from the experience buffer, determine the loss function of the value network based on the batch of experience data samples; update the network parameters of the value network based on the loss function of the value network;
[0095] The labeling decision is evaluated based on the updated value network to obtain the value of the labeling decision, the gradient of the labeling decision network is determined based on the value of the labeling decision, and the labeling decision network is updated based on the gradient.
[0096] Based on the above embodiment, optionally, the training module of the event text annotation model is used to:
[0097] For each experience data sample, evaluating the labeling decision based on the value network to obtain a predicted value of the labeling decision; and determining a target value based on the reward value, the discount factor and the maximum value of the next state;
[0098] A loss function of the value network is determined based on the predicted value of the labeling decision and the target value.
[0099] Based on the above embodiment, optionally, the reward function of the reward value includes:
[0100]
[0101] Among them, R represents the reward value, n represents the number of characters and / or words in the labeled sample data, and y i represents the true label of the i-th character or word in the labeled sample data, represents the label corresponding to the labeling decision of the i-th character or word in the labeled sample data, and I(·) is an indicator function. When y i =x i If true, the indicator function takes on the value 1, otherwise it takes on the value 0.
[0102] Based on the above embodiment, optionally, the training module of the event text annotation model is used to:
[0103] Determine the uncertainty index value of the updated event text annotation model for each unlabeled sample data based on the label probability distribution of each unlabeled sample data in the current round, wherein the uncertainty index value is used to measure the uncertainty of the label probability distribution of the unlabeled sample data;
[0104] The unlabeled sample data of the current round are sampled and labeled based on the uncertainty index corresponding to each unlabeled sample data to obtain labeled sample data of the next round.
[0105] Based on the above embodiment, optionally, the sequence labeling mechanism used in the sequence labeling decision process is a word-granularity sequence labeling mechanism.
[0106] The event text intelligent annotation device based on the pre-training model provided in the embodiment of the present invention can execute the event text intelligent annotation method based on the pre-training model provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0107] Embodiment 3
[0108] Figure 5 1 is a schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present invention. The electronic device 10 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0109] like Figure 5 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, ROM 12 and RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0110] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0111] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The processor 11 executes the various methods and processes described above, such as the event text intelligent annotation method based on the pre-trained model.
[0112] In some embodiments, the event text intelligent annotation method based on the pre-trained model can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 10 via ROM12 and / or communication unit 19. When the computer program is loaded into RAM13 and executed by the processor 11, one or more steps of the event text intelligent annotation method based on the pre-trained model described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to execute the event text intelligent annotation method based on the pre-trained model by any other appropriate means (for example, by means of firmware).
[0113] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0114] The computer program for implementing the event text intelligent annotation method based on the pre-trained model of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program can be executed entirely on the machine, partially on the machine, partially on the machine as an independent software package and partially on a remote machine, or completely on a remote machine or server.
[0115] Embodiment 4
[0116] Embodiment 4 of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to execute an event text intelligent annotation method based on a pre-trained model, the method comprising:
[0117] Load the pre-trained event text annotation model, which includes a natural language processing sub-model and a deterministic policy gradient module. The deterministic policy gradient module includes an annotation decision network.
[0118] Acquire the event text to be annotated and the status information of the event text to be annotated, input the event text to be annotated into the natural language processing sub-model for recognition, and obtain the text features of the event text to be annotated;
[0119] The text features and state information are input into the labeling decision network to make sequence labeling decisions, determine the labeling decisions of the event text to be labeled, and label the event text to be labeled based on the labeling decisions.
[0120] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0121] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0122] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0123] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0124] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0125] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for intelligent annotation of event text based on a pre-trained model, characterized in that: include: Loading a pre-trained event text annotation model, wherein the event text annotation model includes a natural language processing sub-model and a deterministic policy gradient module, wherein the deterministic policy gradient module includes an annotation decision network; Acquire the event text to be annotated and the status information of the event text to be annotated, input the event text to be annotated into the natural language processing sub-model for recognition, and obtain the text features of the event text to be annotated; The text features and the state information are input into the labeling decision network to make a sequence labeling decision, determine the labeling decision of the event text to be labeled, and label the event text to be labeled based on the labeling decision.
2. The method according to claim 1, characterized in that The training method of the event text annotation model includes: Acquire sample data of the event text annotation task, wherein the sample data includes annotated sample data of the first round and unlabeled sample data of the first round; Iterate the following steps to obtain a trained event text annotation model when the first iteration stop condition is met: The event text annotation model is trained based on the annotated sample data of the current round to obtain an updated event text annotation model; Predicting the unlabeled sample data of the current round based on the updated event text annotation model to obtain the label probability distribution of each unlabeled sample data of the current round; Based on the label probability distribution of each unlabeled sample data in the current round, the unlabeled sample data in the current round is sampled and labeled to obtain labeled sample data for the next round.
3. The method according to claim 2, characterized in that The deterministic policy gradient module further includes a value network for evaluating the value of the labeling decision output by the labeling decision network; The training of the event text annotation model based on the annotated sample data to obtain an updated event text annotation model includes: Fine-tune the natural language processing sub-model based on the labeled sample data, recognize the labeled sample data based on the fine-tuned natural language processing sub-model, and extract sample features of the labeled sample data; At each time step, the sample features and the current state information of the labeled sample data are input into the labeling decision network to perform a sequence labeling decision, and a labeling decision of the current state of the labeled sample data is obtained, and based on the labeling decision, the labeled sample data is interacted with to determine an experience data sample, and the experience data sample is stored in an experience buffer; wherein the experience data sample includes the current state information, the labeling decision, the reward value and the next state information; The following steps are iteratively performed to obtain the updated event text annotation model when the second iteration stop condition is met: Acquire a batch of experience data samples from the experience buffer, determine the loss function of the value network based on the batch of experience data samples; update the network parameters of the value network based on the loss function of the value network; The labeling decision is evaluated based on the updated value network to obtain the value of the labeling decision, the gradient of the labeling decision network is determined based on the value of the labeling decision, and the labeling decision network is updated based on the gradient.
4. The method according to claim 3, characterized in that Determining the loss function of the value network based on the batch of empirical data samples includes: For each experience data sample, evaluating the labeling decision based on the value network to obtain a predicted value of the labeling decision; and determining a target value based on the reward value, the discount factor and the maximum value of the next state; A loss function of the value network is determined based on the predicted value of the labeling decision and the target value.
5. The method according to claim 3, characterized in that: The reward function of the reward value includes: Among them, R represents the reward value, n represents the number of characters and / or words in the labeled sample data, and y i represents the true label of the i-th character or word in the labeled sample data, x i represents the label corresponding to the labeling decision of the i-th character or word in the labeled sample data, I(·) is an indicator function. When y i =x i When the condition is met, the value of the indicator function is 1, otherwise it is 0.
6. The method according to claim 2, characterized in that The sampling and labeling of the unlabeled sample data of the current round based on the label probability distribution of each unlabeled sample data of the current round to obtain labeled sample data of the next round includes: Determine the uncertainty index value of the updated event text annotation model for each unlabeled sample data based on the label probability distribution of each unlabeled sample data in the current round, wherein the uncertainty index value is used to measure the uncertainty of the label probability distribution of the unlabeled sample data; The unlabeled sample data of the current round are sampled and labeled based on the uncertainty index corresponding to each unlabeled sample data to obtain labeled sample data of the next round.
7. The method according to claim 1 or 3, characterized in that: The sequence labeling mechanism used in the sequence labeling decision process is a word-granularity sequence labeling mechanism.
8. An event text intelligent annotation device based on a pre-trained model, characterized in that: include: An event text annotation model loading module, used to load a pre-trained event text annotation model, wherein the event text annotation model includes a natural language processing sub-model and a policy gradient module; A text feature recognition module, used to obtain the event text to be annotated and the status information of the event text to be annotated, input the event text to be annotated into the natural language processing sub-model for recognition, and obtain the text features of the event text to be annotated; The event text annotation module is used to input the text features and the state information into the annotation decision network to make a sequence annotation decision, determine the annotation decision of the event text to be annotated, and annotate the event text to be annotated based on the annotation decision.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the event text intelligent annotation method based on the pre-training model described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the event text intelligent annotation method based on a pre-training model described in any one of claims 1 to 7 when executed.
Citation Information
Patent Citations
Text labeling method and device
CN113051880A
Network model obtaining method and device, information processing method and device and electronic equipment
CN113450786A
Method, device and system for automatically generating saliency detection task annotation data
CN114120000A
Weak supervision-oriented text classification system, method and device
CN114647732A
Weak supervision text classification method and device based on noisy label learning
CN115080748A