A few-shot event temporal relation extraction method and device based on a prompt learning paradigm
By employing a prompt-based learning paradigm and utilizing the large-scale pre-trained language model RoBERTa along with custom templates and mappers, the problem of imbalanced label distribution in event temporal relation extraction is solved, achieving efficient extraction of temporal relations with few samples.
Patent Information
- Application Number
- CN202211643171.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-20
- Publication Date
- 2026-11-20
- Estimated Expiration
- 2042-12-20
AI Technical Summary
Existing event time-series relationship extraction models suffer from an imbalanced label distribution in the training data, especially with a very small number of "simultaneous relationship" samples, making it difficult for the model to effectively model and achieve satisfactory extraction results.
We adopt a prompt-based learning paradigm and utilize the large-scale pre-trained language model RoBERTa. By customizing templates and mappers, we transform the problem of extracting event temporal relationships into a masked language model problem. We design event temporal relationship templates and temporal label mappers, and optimize the model using gradient descent to mine temporal knowledge from the pre-trained language model.
It effectively reduces the difficulty of extracting temporal relationships, reduces the training data requirements, improves the accuracy of extracting temporal relationships with few samples, achieves rapid modeling and data adaptation, and alleviates the problem of insufficient training corpus.
Smart Images

Figure CN118227782B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to technologies such as deep learning, natural language processing, and knowledge graphs, specifically to a method and apparatus for extracting event temporal relationships based on a prompting learning paradigm. Background Technology
[0002] In recent years, with the rapid development of information technology, various portal websites and social media platforms generate massive amounts of news data daily. One of the most crucial aspects of this news data is understanding news events. Therefore, effectively extracting event-related information from news articles on various platforms can help clients understand news events, their evolution, and the latest trends. Event chronology refers to the sequential relationship between events over time, including before, after, and simultaneously, and is a vital component in understanding the development of events. Research on event chronology has become a highly practical and widely recognized research topic.
[0003] The task of extracting temporal relationships from events mainly faces the problem of extremely uneven label distribution in the training corpus, namely, a very high proportion of "sequential" relationship samples and a very low proportion of "simultaneous" relationship samples in the training data. This problem makes it difficult for temporal relationship extraction models to effectively model temporal relationships with few samples, such as "simultaneous" relationships, and thus fails to achieve satisfactory extraction results.
[0004] For example, most models achieve an F1 score of 0 for simultaneous relationships on multiple commonly used public datasets, which is far lower than the extraction accuracy of more than 70% for preceding and subsequent relationships. Summary of the Invention
[0005] To address the aforementioned technical problems, this invention proposes a method and apparatus for extracting event temporal relations based on a cue-based learning paradigm. By utilizing the large-scale pre-trained language model RoBERTa and customizing corresponding templates and mappers, the temporal relation extraction problem is transformed into a masked language model problem trained on a large-scale pre-trained corpus.
[0006] To solve the above-mentioned technical problems, the technical solution of the present invention is as follows:
[0007] A method for extracting temporal relationships from few-shot events based on a cue-based learning paradigm includes the following stages / steps:
[0008] The first stage is the event sequence relationship template configuration stage, which generates multiple candidate event sequence relationship templates by configuring template elements and template styles;
[0009] The second stage is the temporal label mapper configuration stage, which uses hard mapping and soft mapping to realize the mapping from the dictionary of the pre-trained language model to the set of event temporal relation labels, thus obtaining the temporal label mapper;
[0010] The third stage is the training stage of the event time-series relation classifier. The event time-series relation classifier consists of two main components: the event time-series relation template and the time-series label mapper. This stage completes the training of all parameters in the classifier.
[0011] The fourth stage is the event temporal relationship prediction stage. For the input sentence and the trigger words of the two events, the trained event temporal relationship classifier is used to determine the temporal relationship between the two events.
[0012] Furthermore, the event sequence relationship template configuration stage includes two steps: template element configuration and template style configuration.
[0013] 1) Configure template elements, including multiple slots such as input sentence, event trigger words, temporal relationships, hint symbols, and hint vectors. Each slot is filled with user-understandable words or phrases and machine-readable numerical vectors. Specifically, the sentence slot "(original sentence)" is used to fill the original input sentence; the event trigger word slot "(e1: event trigger word)" is used to fill the trigger word indicating that a certain event has occurred; the temporal relationship slot "[MASK]" is used to fill the words or phrases expressing a certain temporal relationship, called temporal masking words; the hint symbol slot "{hint symbol}" is used to fill the hint words or phrases that "help explain the meaning of other slots"; and the hint vector slot "{hint vector}" is filled with an n-dimensional numerical vector.
[0014] 2. Configure template styles, including three types: pre-prompt, post-prompt, and question-and-answer. Pre-prompt places the prompt symbol before the event trigger word, post-prompt places it after, and question-and-answer adds two questions about the timing relationship after the two event trigger words.
[0015] Furthermore, the time-series tag mapper configuration phase is used to configure two mapping methods for implementing the time-series tag mapper:
[0016] 1) Hard mapping method: Directly establish the association between temporal labels and temporal masking words (i.e., words or phrases expressing a certain temporal relationship), such as words or phrases expressing the "before," "prior," and "inadvance." Here, the temporal labels are the temporal labels in the event temporal relationship label set, and the temporal masking words are the words predicted by the pre-trained language model to be in the masked position.
[0017] 2) Soft mapping method: Train the time tag mapper to dynamically adjust the mapping relationship between time tags and time masking words during the training process, such as hash function mapping relationship.
[0018] Furthermore, in the training phase of the event time-series relation classifier, the parameters of the classifier are trained. The classifier includes the event time-series relation template and time-series label mapper designed in the previous phase, and on this basis, a fully connected layer, a regularization layer, and a softmax layer are added to output time-series relation labels. The training process includes two steps:
[0019] 1) In the initial screening stage of the template, the event sequence relationship templates designed in three ways—pre-prompt, post-prompt, and question-and-answer—were tested on the test dataset to predict the event sequence relationship using the F1 score, and the template style with the best performance was selected.
[0020] 2) In the classifier parameter fine-tuning stage, based on the template styles selected in the previous stage, the cue symbols and cue vectors in the template are fine-tuned according to the training dataset to obtain the best template.
[0021] Furthermore, the event time-series relationship prediction stage is based on the event time-series relationship classifier trained in the previous stage. The test data is input in batches to obtain the normalized label distribution, and the time-series label with the highest probability is selected as the output.
[0022] A device for extracting time-series relationships of few-shot events based on a cue-based learning paradigm, comprising:
[0023] The template configuration module is used to configure event sequence relationship templates;
[0024] The mapper configuration module is used to map from the dictionary of the pre-trained language model to the set of event time sequence relation labels through hard mapping and soft mapping, so as to obtain the time sequence label mapper;
[0025] A classifier training module is used to train an event time sequence relationship classifier, wherein the event time sequence relationship classifier includes the event time sequence relationship template and the time sequence label mapper;
[0026] The event sequence relationship prediction module is used to determine the temporal relationship between events based on the input sentence using a trained event sequence relationship classifier.
[0027] The beneficial effects of this invention are as follows:
[0028] This invention addresses the imbalanced temporal label sample problem commonly encountered in temporal relation extraction tasks by proposing an event-based temporal relation extraction method based on a cue-based learning paradigm. This method cleverly transforms the supervised learning problem into a Multi-Level Model (MLM) problem, which is well-suited for pre-trained language models. Specifically, an event-based temporal relation classifier is defined, with its two most important components being an event-based temporal relation template and a temporal label mapper. The event-based temporal relation template is designed by first selecting suitable template styles, and then fine-tuning the selected templates during training based on the characteristics of the dataset to better extract potential temporal relation knowledge from the pre-trained language model. The temporal label mapper is designed by either manually specifying hard mapping relationships or establishing soft mapping relationships through model training, ultimately selecting the most effective method as the label mapper implementation. The soft-method temporal label mapper first establishes a random mapping relationship between temporal masking words and temporal labels, and then continuously adjusts and optimizes the mapping relationship during training using the steepest descent method. Once the model converges, the optimal mapping relationship between temporal masking words and temporal labels is obtained.
[0029] This invention transforms the supervised learning task into an MLM task, which is well-suited to pre-trained language tasks. By mining the temporal knowledge inherent in large-scale pre-trained language models, it effectively reduces the difficulty of extracting temporal relationships, decreases the amount of data required for training, and achieves excellent temporal relationship extraction results. Furthermore, during model training, the model is automatically optimized using gradient descent to fill in the required slot information, enabling rapid modeling and data adaptation for event temporal relationship recognition tasks, effectively alleviating the problem of insufficient model training caused by a lack of training corpus. Attached Figure Description
[0030] Figure 1 The flowchart illustrates the event sequence relationship extraction method based on the prompting learning paradigm provided in this embodiment of the invention. Detailed Implementation
[0031] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below through specific embodiments and in conjunction with the accompanying drawings.
[0032] Figure 1 The detailed flowchart of the event time-series relationship extraction method based on the prompting learning paradigm in this embodiment is shown in the figure. The method mainly includes four stages: event time-series relationship template configuration stage, time-series label mapper configuration stage, event time-series relationship classifier training stage, and event time-series relationship prediction stage.
[0033] (I) Event Sequence Relationship Template Configuration Phase
[0034] Step 1: The sentence slot "(original sentence)" is used to fill the original input sentence. RobertaLarge is selected as the pre-trained language model, and RobertaLarge is used to transform the sentence into word vector representations.
[0035] H = (h1, h2, ..., h N ) = RoBERTa(t1,t2,…,t N )
[0036] Where h i The feature representation of the i-th word position, t i This represents the input word corresponding to the i-th word position.
[0037] Step 2, the event trigger word slot "(e1: event trigger word)" is used to fill in the trigger word that indicates the occurrence of an event. It is usually a verb or noun. The content of the filling is directly obtained from the input and filled in. It is used to represent the word group information of the temporal relationship to be mined to the pre-trained language model.
[0038] Step 3: The temporal relation slot "[MASK]" is used to fill words or phrases expressing a certain temporal relation, such as before, prior, and in advance. These words are directly predicted by the pre-trained language model. Based on the contextual information and the temporal knowledge implied by PLMs, the prediction results of the masked words are predicted, resulting in a set of candidate word vectors for temporal relations.
[0039] Step 4: The prompt symbol slot “{prompt symbol}” is used to fill with prompt words or phrases that “help explain the meaning of other slots”, which are used to explain the attribute information related to the event trigger words, such as event modifier information such as “event”, “trigger”, “the trigger”.
[0040] Step 5: The prompt vector slot “{prompt vector}” is filled with an n-dimensional numerical vector to modify the trigger word and its modifiers. It is learned during the training phase of the event sequence relation classifier and is composed of computer vectors. Its meaning cannot be recognized by the user.
[0041] Step 6: Configure the template style, including three types: prompt before, prompt after, and question and answer.
[0042] (II) Time Tag Mapper Configuration Phase
[0043] Step 1, Configure a hard-mapped time tag mapper: Directly establish the association between time tags and time masking words, such as words or phrases that indicate a "before" time relationship, such as before, prior, in advance.
[0044] Step 2, Configure the time-series label mapper using the soft mapping method: Map time-series masking words to time-series labels {MaskSet}→{Label}. Initially, the mapping relationship is randomly established, and then the mapping function between time-series masking words and time-series labels is dynamically adjusted through training.
[0045] (III) Training Phase of Event Sequence Relationship Classifier
[0046] The candidate word vector set is mapped to the labels. During training, the objective function is continuously optimized based on the mapping relationship using the gradient descent algorithm. The optimization formula used is:
[0047]
[0048] Where l represents the total loss function, l CE represents the model cross-entropy loss function, used to calculate whether the predicted label is consistent with the true label, w represents the model parameters, ||w||2 represents L2 norm regularization, and α represents the loss function balancing factor, used to balance the loss weights in the training of the event time-series relation classifier.
[0049] (iv) Event Sequence Relationship Prediction Stage
[0050] After the model is trained, the sentences are input into the event time sequence classifier, the test data is input into the converged model, the trained classifier model is switched to evaluation mode, gradient backpropagation and other functions are disabled, and the data is sent to the corresponding label classifier as the time sequence label score. The output label score of the model is p:
[0051] p = softmax(W·tanh(wH)) T )+b)
[0052] Where w and W represent the weights that the deep learning model can learn, b represents the function bias, tanh represents the activation function, and softmax represents the normalization function. After obtaining the normalized label distribution, the argmax function is used to complete the time-series label prediction.
[0053] The following provides an example of the overall input and output of the model of this invention:
[0054] Input: Any decision to (e1:expel) sinn fein must be (e2:agreed) jointly by the governments of both britain and the irish republic.
[0055] Phase 1: Event sequence relationship template configuration, including template element configuration and template style configuration, as shown in Table 1 and Table 2 respectively.
[0056] Table 1. Template Element Configuration
[0057]
[0058] Table 2. Template Style Configuration
[0059]
[0060] The template generated using the prompt-after-prompt method for the input sentence is as follows:
[0061] (e1:expel)(Trigger)[clip vector][MASK](e2:agreed)(Trigger).
[0062] Phase 2: Time-Sequence Tag Mapper Configuration Phase.
[0063] Table 3 shows an example of the mapping relationship between time sequence tags and time sequence masking words (hard mapping method):
[0064] Table 3. Examples of mapping relationships
[0065]
[0066] The third stage: The optimal template style obtained in the coarse screening stage of model training is "hint-post" (i.e., template style 2), and the optimal time tag mapper adopts the "soft mapping" method.
[0067] Fourth stage: The time series relationship predicted by the model is labeled After.
[0068] As can be seen from the above scheme, this scheme addresses the challenge of predicting time-series relation labels with few samples in time-series relation extraction. It proposes an event-series relation extraction method based on prompting learning, which can improve the quality of the model's extraction of time-series labels and has good practicality.
[0069] Another embodiment of the present invention provides a few-sample event temporal relationship extraction device based on a cue-based learning paradigm, comprising:
[0070] The template configuration module is used to configure event sequence relationship templates;
[0071] The mapper configuration module is used to map from the dictionary of the pre-trained language model to the set of event time sequence relation labels through hard mapping and soft mapping, so as to obtain the time sequence label mapper;
[0072] A classifier training module is used to train an event time sequence relationship classifier, wherein the event time sequence relationship classifier includes the event time sequence relationship template and the time sequence label mapper;
[0073] The event sequence relationship prediction module is used to determine the temporal relationship between events based on the input sentence using a trained event sequence relationship classifier.
[0074] For the specific implementation process of each module, please refer to the description of the method of the present invention above.
[0075] Another embodiment of the present invention provides a computer device (computer, server, smartphone, etc.) including a memory and a processor, the memory storing a computer program configured to be executed by the processor, the computer program including instructions for performing the steps of the method of the present invention.
[0076] Another embodiment of the present invention provides a computer-readable storage medium (such as ROM / RAM, disk, optical disk) storing a computer program that, when executed by a computer, implements the various steps of the method of the present invention.
[0077] The specific embodiments of the present invention disclosed above are intended to help understand the content of the present invention and to implement it accordingly. Those skilled in the art will understand that various substitutions, changes, and modifications are possible without departing from the spirit and scope of the present invention. The present invention should not be limited to the content disclosed in the embodiments of this specification; the scope of protection of the present invention is defined by the claims.
Claims
1. A method for extracting temporal relationships from few-shot events based on a cue-based learning paradigm, characterized in that, Includes the following steps: Configure event sequence relationship template; By using both hard and soft mapping methods, a mapping is achieved from the dictionary of the pre-trained language model to the set of event temporal relation labels, resulting in a temporal label mapper. Train an event time sequence relationship classifier, wherein the event time sequence relationship classifier includes the event time sequence relationship template and the time sequence label mapper; For the input sentence, the trained event temporal relationship classifier is used to determine the temporal relationship between events; The configuration event sequence relationship template includes: The configuration template elements include sentence slots, event trigger word slots, temporal relationship slots, hint symbol slots, and hint vector slots. Sentence slots are used to fill in the original input sentence; event trigger word slots are used to fill in trigger words indicating the occurrence of a certain event; temporal relationship slots are used to fill in words or phrases expressing a certain temporal relationship, called temporal masking words; hint symbol slots are used to fill in hint words or phrases that "help explain the meaning of other slots"; and hint vector slots are filled with n-dimensional numerical vectors. Configure template styles, including three types: prompt before, prompt after, and question and answer. The prompt before place the prompt symbol before the event trigger word, the prompt after place the prompt symbol after the event trigger word, and the question and answer adds two questions about the timing relationship after the two event trigger words. The hard mapping method directly establishes the association between time-series tags and time-series masking words; the soft mapping method initially establishes a mapping relationship between time-series masking words and time-series tags randomly, and then dynamically adjusts the mapping relationship between time-series masking words and time-series tags through training. The training process of the event time sequence classifier includes a template coarse screening stage and a classifier parameter fine-tuning stage. In the template coarse screening stage, the event sequence relationship templates designed in three ways—pre-prompt, post-prompt, and question-and-answer—are first tested on the test dataset to predict the event sequence relationship using the F1 score, and the template style with the best performance is selected. In the classifier parameter fine-tuning stage, based on the template styles selected in the template coarse screening stage, the cue symbols and cue vectors in the templates are fine-tuned according to the training dataset to obtain the optimal template.
2. The method according to claim 1, characterized in that, The event time sequence classifier is based on the event time sequence template and the time sequence label mapper, with the addition of a fully connected layer, a regularization layer and a softmax layer, to output time sequence label.
3. The method according to claim 1, characterized in that, The event sequence relationship classifier employs a gradient descent algorithm during training, continuously optimizing the objective function as training progresses. The optimization formula used is: in, The model's cross-entropy loss function is used to calculate whether the predicted labels match the true labels. `w` represents the model parameters. This indicates L2 norm regularization. This represents the loss function balancing factor, which balances the loss weights during time series model training.
4. The method according to claim 1, characterized in that, For the input sentence, the step of using a trained event temporal relationship classifier to determine the temporal relationship between events includes: The test data is input into the trained event time-series classifier in batches to obtain the normalized label distribution, and the time-series label with the highest probability is selected as the output.
5. A device for extracting temporal relationships from few-sample events based on a cue-based learning paradigm, characterized in that, The apparatus for performing the method according to any one of claims 1 to 4 comprises: The template configuration module is used to configure event sequence relationship templates; The mapper configuration module is used to map from the dictionary of the pre-trained language model to the set of event time sequence relation labels through hard mapping and soft mapping, so as to obtain the time sequence label mapper; A classifier training module is used to train an event time sequence relationship classifier, wherein the event time sequence relationship classifier includes the event time sequence relationship template and the time sequence label mapper; The event sequence relationship prediction module is used to determine the temporal relationship between events based on the input sentence using a trained event sequence relationship classifier.
6. A computer device, characterized in that, It includes a memory and a processor, the memory storing a computer program configured to be executed by the processor, the computer program including instructions for performing the method of any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when executed by a computer, implements the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Event sequential relation extraction method based on dynamic attention mechanism
CN114153942A
Time series data prediction method and device based on transfer learning and storage medium
CN114239859A
