Event extraction method and device, electronic device and storage medium
The text and argument feature vectors are extracted through the encoder and decoder, combined with the target extraction template, and the problem of event argument relationship modeling and multi-event argument matching in document-level event extraction is solved, achieving high accuracy and high efficiency Event extraction.
Patent Information
- Application Number
- CN202210453775.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2021-12-08
- Filing Date
- 2022-04-24
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2042-04-24
AI Technical Summary
Existing event extraction methods are not effective in document-level text, it is difficult to model the relationship between sentences, and it is difficult to identify multiple event arguments and matching argument roles.
The text feature vector and argument feature vector are extracted by encoder and decoder, and the relationship between event arguments is established through the target extraction template, so as to realize cross-sentence relationship modeling and simultaneous extraction of multiple event arguments.
It improves the accuracy and speed of event extraction, can accurately identify multiple event arguments in document-level text, and improves the efficiency and scale of building large-scale event knowledge graphs.
Smart Images

Figure CN114741516B_ABST
Abstract
Description
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority to Singapore patent application number 10202113631X, filed with the Singapore Patent Office on December 8, 2021, entitled “An event extraction method and device, electronic device and storage medium”. The entire contents of the Singapore patent application are hereby cited as a reference. Technical Field
[0003] The present application relates to the technical field of natural language processing, and relates to but is not limited to an event extraction method and device, an electronic device, and a storage medium. Background Art
[0004] Event extraction is an important issue in the field of information extraction. Event extraction refers to extracting corresponding trigger words and event arguments from text given a pre-given event type and argument role. Event extraction models have important applications in many fields, such as extracting corresponding structured information from large-scale texts in specific fields (such as law, medicine, and finance), or extracting relevant event-based knowledge when building large-scale knowledge graphs.
[0005] However, many current event extraction methods focus on the extraction of single-sentence text, treating the event extraction task as a question answering task. These methods have been proven to be ineffective in event extraction of document-level text. The main problems are: on the one hand, in the event extraction of document-level text, many event arguments are distributed in multiple sentences in the document, and the existing model cannot model the relationship between sentences well; on the other hand, there are multiple event arguments for the same event, and some event arguments may belong to the same argument role. When matching event arguments and argument roles, the existing model cannot well identify the argument roles corresponding to different event arguments. At the same time, it is also difficult to extract multiple arguments at the same time. Summary of the invention
[0006] In view of this, embodiments of the present application provide an event extraction method, apparatus, device and storage medium.
[0007] In a first aspect, an embodiment of the present application provides an event extraction method, the method comprising: obtaining input text; wherein the input text comprises a trigger word and at least one event argument; extracting a first text feature vector set corresponding to the input text through an encoder and a decoder; obtaining a target extraction template corresponding to the trigger word; decoding the target extraction template and the input text through the decoder to obtain an argument feature vector of each of the event arguments; and determining a value range corresponding to each of the event arguments based on the first text feature vector set and the argument feature vector of each of the event arguments.
[0008] In a second aspect, an embodiment of the present application provides a training method for an event extraction model, wherein the event extraction model includes an encoder, a decoder and an argument detection module, and the method includes: obtaining a training text and a target extraction template corresponding to the training text; extracting a first text feature vector set corresponding to the training text through the encoder and the decoder; encoding the target extraction template and the training text through the decoder to obtain an argument feature vector of each of the event arguments; determining a prediction range corresponding to each of the event arguments through the argument detection module based on the first text feature vector set and the argument feature vector of each of the event arguments; matching the prediction range of each of the event arguments with the true value range to obtain an optimal prediction range corresponding to each of the event arguments whose loss function value satisfies a second preset condition; determining the loss function value of the event extraction model based on the optimal prediction range of each of the event arguments; and training the event extraction model based on the loss function value.
[0009] In a third aspect, an embodiment of the present application provides an event extraction device, which includes: a first acquisition module, used to acquire input text; wherein the input text includes a trigger word and at least one event argument; a first extraction module, used to extract a first text feature vector set corresponding to the input text through an encoder and a decoder; a second acquisition module, used to acquire a target extraction template corresponding to the trigger word; a first decoding module, used to use the decoder to decode the target extraction template and the input text to obtain an argument feature vector of each of the event arguments; and a first determination module, used to determine a value range corresponding to each of the event arguments based on the first text feature vector set and the argument feature vector of each of the event arguments.
[0010] In a fourth aspect, an embodiment of the present application provides a training device for an event extraction model, the device comprising: a fourth acquisition module, used to acquire a training text and a target extraction template corresponding to the training text; a second extraction module, used to extract a first text feature vector set corresponding to the training text through an encoder and a decoder; a second encoding module, used to encode the target extraction template and the training text through the decoder to obtain an argument feature vector of each of the event arguments; a sixth determination module, used to determine a prediction range corresponding to each of the event arguments through the argument detection module based on the first text feature vector set and the argument feature vector of each of the event arguments; a matching module, used to match the prediction range of each of the event arguments with the true value range to obtain an optimal prediction range corresponding to each of the event arguments whose loss function value satisfies a second preset condition; a seventh determination module, used to determine the loss function value of the event extraction model based on the optimal prediction range of each of the event arguments; and a training module, used to train the event extraction model based on the loss function value.
[0011] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising: a memory and a processor, wherein the memory stores a computer program that can be executed on the processor, and the processor implements the steps in the above method when executing the computer program.
[0012] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the steps in the above method when executed by a processor.
[0013] In a seventh aspect, an embodiment of the present application provides a computer program product, comprising a computer-readable code, characterized in that when the computer-readable code is run on a device, a processor in the device executes steps for implementing the above method.
[0014] In the embodiment of the present application, first, the first text feature vector set corresponding to the input text is extracted through the encoder and the decoder, and then the target extraction template and the input text are decoded by the decoder to obtain the argument feature vector of each event argument. Since the target extraction template and the input text are decoded by the decoder together, the argument feature vector of each event argument obtained by decoding by the decoder incorporates the information of the input text, and the first text feature vector set is a text feature vector reflecting the context. In this way, based on the first text feature vector set and the argument feature vector of each event argument, the value range corresponding to each event argument is determined to be the value range reflecting the context, with a higher accuracy, thereby improving the accuracy of extracting event arguments. In addition, since the target extraction template contains argument roles and the relationship between argument roles, the establishment of cross-sentence relationships between multiple event arguments is realized. This not only solves the long distance problem between event arguments in sentence-level and document-level text event extraction, but also can predict multiple event arguments at one time, greatly improving the speed of event extraction. When building a large-scale event knowledge graph, the efficiency and scale of event knowledge graph construction are improved. At the same time, by introducing multiple slots for an argument role in the target extraction template, the situation in which an argument role cannot be matched to multiple event arguments in event extraction is effectively reduced, thereby improving the matching accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In the accompanying drawings (which are not necessarily drawn to scale), like reference numerals may describe similar components in different views. Like reference numerals with different letter suffixes may represent different examples of similar components. The accompanying drawings generally illustrate various embodiments discussed herein by way of example and not limitation.
[0016] Figure 1 A flowchart of an event extraction method provided in an embodiment of the present application;
[0017] Figure 2 A flowchart of another event extraction method provided in an embodiment of the present application;
[0018] Figure 3 A schematic diagram of a process for determining a value range corresponding to each event argument provided in an embodiment of the present application;
[0019] Figure 4 A flowchart of an event extraction model training method provided in an embodiment of the present application;
[0020] Figure 5 A flowchart of another event extraction method provided in an embodiment of the present application;
[0021] Figure 6A schematic diagram of the structure of an event extraction device provided in an embodiment of the present application;
[0022] Figure 7 A schematic diagram of the structure of a training device for an event extraction model provided in an embodiment of the present application;
[0023] Figure 8 A hardware entity schematic diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0024] The technical solution of the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments of the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0025] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0026] In the subsequent description, the suffixes such as "module", "component" or "unit" used to represent elements are only used to facilitate the description of the present application, and have no specific meanings. Therefore, "module", "component" or "unit" can be used in a mixed manner.
[0027] It should be pointed out that the terms "first\second\third" involved in the embodiments of the present application are merely to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.
[0028] The present application embodiment provides an event extraction method, such as Figure 1 As shown, the method includes:
[0029] S101: Acquire sentence-level or document-level input text; wherein the input text includes a trigger word and at least one event argument.
[0030] Here, the input text is used to describe the event content, and can be sentence-level or document-level text. Sentence-level text is text in a single-sentence form, and document-level text is text in a multi-sentence form.
[0031] Among them, the constituent elements of an event may include trigger words, event types, event arguments, and argument roles. Among them, trigger words refer to the core words of an event, which are mostly verbs and nouns, such as attack, discussion, etc. Event types refer to the categories of events, such as sports events, attack events, etc. Different data sets correspond to different types of event types. For example, the data set ACE2005 defines 8 event types and 33 subtypes, among which most event extractions use these 33 event types. Event arguments refer to the participants of an event, such as Zhang San (i.e., a specific person), school, etc. Argument roles refer to the roles played by event arguments in an event, such as attacker, location, time, etc.
[0032] The following incident is used as an example: The private Dogan news agency reported that more than 30 of those wounded in A, primarily children, were transferred to a hospital in B.
[0033] It showed footage of ambulances arriving at C hospital and medicalpersonnel <t> unloading< / t> a girl on stretchers.
[0034] The private Dogan News Agency reported that more than 30 injured people in location A were transferred to a hospital in location B, most of them children. The report showed footage of an ambulance arriving at hospital C and medical staff unloading a girl on a stretcher.
[0035] Among them, the event type is a motion event triggered by the trigger word "unloading", and the event arguments are "A", "ambulances", "C hospital", "medical personnel", and "a girl". Each event argument plays a specific role in this event, namely the origin (i.e. the place indicated by A), the vehicle (i.e. the vehicle indicated by ambulances), the destination (i.e. the place indicated by C hospital), the transporter (i.e. the transporter indicated by medical personnel) and the passenger (i.e. the passenger indicated by a girl).
[0036] In some embodiments, the input text may include a trigger word and at least one event argument, wherein the at least one may be one or at least two, depending on the content of the input text.
[0037] During implementation, first, an event extraction task is formulated, and then a series of event types E are predefined. Here, the predefined event types can be defined based on the dataset. For example, for the dataset ACE2005, there are 33 event types in total. For each event type t ∈ E, each event type t includes a series of argument roles R t , where For the sake of convenient description, the superscript indicating the event type t will be removed in the following text.
[0038] After that, the input text X of sentence-level or document-level text is obtained, where X = {x1, x2, x3... x n}, here, each x i corresponds to a token. When the input text X is in vector form, each x i corresponds to a token vector. Among them, the input text X includes a trigger word x trig and at least one event argument A ri , here, the event argument set A t = {A r1 , A r2 ... A rm}. The event extraction task is to extract the corresponding event argument A i for each argument role r ri in the input text X. Among them, each event argument A ri is the content corresponding to at least one token span in X. For example, the event argument is "Zhang San". The "Zhang" and "San" in "Zhang San" respectively correspond to a token, then the event argument "Zhang San" is the content corresponding to the two token spans of "Zhang" and "San".
[0039] S102: Extract the first text feature vector set corresponding to the input text through an encoder and a decoder.
[0040] Here, the first text feature vector set is a text feature vector that reflects the context, wherein the feature vector corresponding to each word unit is an h-dimensional vector. The encoder and decoder can adopt the encoder and decoder in the Transformer model. The Transformer model is a classic natural language processing (NLP) model proposed in 2017. The Transformer model uses a self-attention mechanism. Among them, the encoder includes a self-attention layer, and the decoder includes a self-attention layer and a cross-attention layer. The self-attention layer is used to focus on the relationship between multiple words in a single sentence of the input text, and the cross-attention layer is used to focus on the relationship between multiple sentences of the input text. The input text uses the attention mechanism of the attention layer to make different words in the input text interact with each other, and obtain the first text feature vector set considering the context.
[0041] In some embodiments, the encoder and decoder may also adopt a BERT model or a BART model, wherein the BERT model is a pre-trained language model that uses only the encoder (i.e., Transformer-Encoder) structure of the Transformer model, and the BART model is a pre-trained language model that uses the overall structure of the Transformer model.
[0042] In some embodiments, the implementation of step S102 may include S1021 and S1022:
[0043] S1021: Acquire trigger words of the input text, and identify the trigger words of the input text;
[0044] Here, the trigger words of the input text can be identified and marked manually or automatically by the device. In some embodiments, special symbols (see the following example) or other methods can be used to mark the trigger words, and the embodiment of the application does not limit the method of marking the input text trigger words.
[0045] The following are examples of trigger words:
[0046] The private Dogan news agency reported that more than 30 of those wounded in A,primarily children,were transferred to a hospital in B.
[0047] It showed footage of ambulances arriving at C hospital and medicalpersonnel <t> unloading< / t> a girl on stretchers.
[0048] Among them, "unloading" is the trigger word, <t> 、< / t> Mark it out.
[0049] Here, the expression for identifying trigger words in the input text can be:
[0050] Input text X = {x1,x2,x3...x n};
[0051] Identifies the input text after the trigger word
[0052] S1022: Extracting a first text feature vector set corresponding to the marked input text through an encoder and a decoder.
[0053] In the embodiment of the present application, by adopting a method of identifying trigger words in the input text, a first text feature vector set corresponding to the input text can be effectively extracted.
[0054] S103: Acquire a target extraction template corresponding to the trigger word.
[0055] Here, the target extraction template is a template composed of argument roles based on the relationship between argument roles in the event type. For example, the argument roles in the attack event are attacker, attacked, and location. The target extraction template can be obtained by splicing based on the relationship between multiple argument roles: (attacker) attacks (attacked) at (location).
[0056] The relationship between trigger words and target extraction templates can be one-to-one or many-to-one, that is, one trigger word corresponds to one target extraction template, or multiple trigger words correspond to one target extraction template. For example, the trigger words are contact and negotiate, and they both correspond to one target extraction template: participant communicated with participant about topic at place Among them, the position corresponding to each argument role is called a slot, and the above target extraction template has four slots: participant, participant, topic and place. Here, two slots correspond to one argument role "participant", that is, there is a situation in the target extraction template where one argument role corresponds to multiple slots.
[0057] Table 1 is an example of a target extraction template:
[0058] Table 1
[0059]
[0060] Among them, the underlined words represent each slot, and the brackets represent N-to-1 argument roles (that is, one argument role corresponds to multiple event arguments).
[0061] In some embodiments, the target extraction template may include multiple argument roles, and multiple event arguments corresponding to the multiple argument roles may be distributed in multiple sentences. For example, the input text is “The private Dogan news agency reported that more than 30 of those wounded in A, primarily children, were transferred to a hospital in B. It showed footage of ambulances arriving at C hospital and medical personnel <t> unloading< / t> a girl on stretchers".
[0062] Among them, the event argument "A" is in the first sentence, and the event argument "a girl" is in the second sentence. Therefore, when the target extraction template is used to extract event arguments, multiple event arguments in the target extraction template can be extracted at one time, and at the same time, extraction is performed in multiple sentences, thereby solving the problem of long distance and multiple event arguments between event arguments in sentence-level and document-level text event extraction.
[0063] In some embodiments, the target extraction template corresponding to the trigger word can be obtained manually or automatically by a device. During implementation, the target extraction template can be determined based on the trigger word.
[0064] Correspondingly, before the implementation of step S103, the following steps may be included:
[0065] S1031: Determine the target event type based on the trigger word;
[0066] S1032: Determine a target extraction template from a preset template library based on the target event type.
[0067] Here, the implementation of step S1032 "determining a target extraction template from a preset template library based on the target event type" may include S103a to S103d:
[0068] S103a: Determine an event type set corresponding to the text set, wherein the event type set includes at least one event type;
[0069] The text set is all the text data in the dataset. For example, if the dataset is ACE2005 and the corresponding text is 400, then the text set includes these 400 texts.
[0070] S103b: Determine at least two argument roles in each of the event types, and relationship information between the at least two argument roles;
[0071] S103c: for each of the event types, based on the relationship information between the at least two argument roles, concatenate the at least two argument roles to obtain an extraction template for each of the event types;
[0072] S103d: Forming the preset template library based on the extracted template of each event type in the event type set.
[0073] S104: Decoding the target extraction template and the input text by the decoder to obtain an argument feature vector of each event argument.
[0074] Here, the argument feature vector is a feature vector that integrates the input text information, and each argument feature vector corresponds to each argument role. R h represents an h-dimensional vector, r i Represents the argument role, and k represents each slot in the target extraction template. It should be noted that, in the embodiment of the present application, for one argument role, multiple slots can be introduced in the target extraction template. Since each argument feature vector corresponding to each slot is a feature vector that integrates the input text information, and there are slight differences between the contexts of each slot, for example, the input text is "Zhang San and Li Si are chatting in People's Park", since the slot corresponding to "Zhang San" and the slot corresponding to "Li Si" have different positions in the context, there are slight differences between the contexts of the slot corresponding to "Zhang San" and the slot corresponding to "Li Si", which tends to generate argument feature vectors with different meanings, which is conducive to identifying the situation where one argument role corresponds to multiple event arguments, and better achieving accurate extraction.
[0075] Since the starting search vector and the ending search vector of the argument feature vector described below need to calculate the inner product with the vector corresponding to each word in the first text feature vector described below, the vector dimension corresponding to each word in the first text feature vector should be the same as the dimension of the starting search vector and the ending search vector. Here, the input text will be subsequently converted into a vector form (i.e., the text word vector set described below), and then converted into the first text feature vector, and the argument feature vector will be converted into a starting search vector and an ending search vector. Therefore, in some embodiments, the dimension of the argument feature vector can be the same as the dimension of the vector corresponding to a word in the input text converted into a vector form, so as to facilitate subsequent calculation and processing.
[0076] In some embodiments, the input text may be a vector set obtained after the input text is encoded by an encoder, and the decoder obtains the argument feature vector of each event argument by decoding the target extraction template and the vector set.
[0077] S105: Determine a value range corresponding to each of the event arguments based on the first text feature vector set and the argument feature vector of each of the event arguments.
[0078] Here, the value range refers to the event argument A ri The indices of the corresponding start and end tokens in the input text X. For example, event argument A ri The indexes of the start token and the end token in the input text X are 3 and 4 respectively, then the event argument A ri The value range is (3,4).
[0079] In some embodiments, each event argument A may be ri The value range of A is determined from the input text, and each word corresponding to the value range is determined to obtain each event argument. For example, if the input text is "Zhang San and Li Si are chatting in People's Park", the event argument A ri The value range of is (1,2), (1,2) corresponds to "Zhang San" in the input text, then the event argument A ri For "Zhang San".
[0080] In some embodiments, the argument roles in the target extraction template may be more than the argument roles in the input text. In this case, the extracted event argument A ri The result may be no answer. For example, if the target extraction template is "(Participant A) and (Participant B) communicate (topic) at (location)", and the input text is "Zhang San and Li Si are chatting in People's Park", then the event argument corresponding to the argument role "topic" is empty. When extracting the content of the event argument corresponding to the argument role "topic", the result is no answer.
[0081] Here, the extracted event argument A ri The expression is:
[0082]
[0083] Among them, J ri is the argument role r i The corresponding event argument A ri The number of and It is the J ri Event Argument A ri The indices of the corresponding start and end tokens in the input text X.
[0084] Let's take the input text X as an example: Zhang San and Li Si are chatting in People's Park. ri The argument roles r corresponding to Zhang San and Li Si i are all participants, then J ri is the argument role r i When it is a participant, the corresponding event argument A ri The number of is 2, corresponding to the two event arguments Zhang San and Li Si. In the input text X, Zhang San is the first event argument, then and are the indices of the starting and ending tokens of the first event argument Zhang San in the input text X. For example, in the input text X, Zhang is the first token and San is the second token. Then, is (1,2).
[0085] In some embodiments, the argument feature vector of each event argument can be converted into a starting search vector representing a starting position and an ending search vector representing an ending position, and the value range corresponding to each event argument is determined by taking the inner product of the starting search vector and the ending search vector with the feature vector corresponding to each word in the first text feature vector set.
[0086] In the embodiment of the present application, first, the first text feature vector set corresponding to the input text is extracted through the encoder and the decoder, and then the target extraction template and the input text are decoded by the decoder to obtain the argument feature vector of each event argument. Since the target extraction template and the input text are decoded by the decoder together, the argument feature vector of each event argument obtained by decoding by the decoder incorporates the information of the input text, and the first text feature vector set is a text feature vector reflecting the context. In this way, based on the first text feature vector set and the argument feature vector of each event argument, the value range corresponding to each event argument is determined to be the value range reflecting the context, with a higher accuracy, thereby improving the accuracy of extracting event arguments. In addition, since the target extraction template contains argument roles and the relationship between argument roles, the establishment of cross-sentence relationships between multiple event arguments is realized. This not only solves the long distance problem between event arguments in sentence-level and document-level text event extraction, but also can predict multiple event arguments at one time, greatly improving the speed of event extraction, and improving the efficiency and scale of event knowledge graph construction when building a large-scale event knowledge graph. At the same time, by introducing multiple slots for an argument role in the target extraction template, the situation in which an argument role cannot be well matched to multiple event arguments in event extraction is effectively reduced, thereby improving the matching accuracy.
[0087] The present application also provides an event extraction method, such as Figure 2 As shown, the method includes S201 to S209:
[0088] S201: Obtain input text; wherein the input text includes a trigger word and at least one event argument.
[0089] S202: Acquire trigger words in the input text, and identify the trigger words in the input text.
[0090] Same as above, for example: input text X = {x1, x2, x3...x n};
[0091] Identifies the input text after the trigger word
[0092] S203: Convert the input text identifying the trigger word into a text word vector set.
[0093] Here, the embodiment of the present application does not limit the dimension of each word in the text word vector set. For example, for the BART basic version model, the dimension of each word can be 768 dimensions, and for the BART enhanced version model, the dimension of each word can be 1024 dimensions, where the BART basic version model uses a 6-layer encoder and decoder, and the BART enhanced version model uses a 12-layer encoder and decoder.
[0094] S204: Encode the text word vector set by the encoder to obtain a second text feature vector set.
[0095] Here, the second text feature vector set is a feature vector set that is fused with the input text information after being encoded by the self-attention layer in the encoder.
[0096] Taking the encoder in the BART model as an example, the expression of the second text feature vector set is:
[0097]
[0098] S205: Decoding the text word vector set and the second text feature vector set by the decoder to obtain a first text feature vector set corresponding to the input text.
[0099] Here, the first text feature vector set is a feature vector set that fuses the input text information after being decoded by the self-attention layer and the cross-attention layer in the decoder.
[0100] Taking the decoder in the BART model as an example, the expression of the first text feature vector set is:
[0101]
[0102] S206: Acquire a target extraction template corresponding to the trigger word.
[0103] S207: Convert the target extraction template into a template word vector set.
[0104] Here, the dimension corresponding to each word in the template word vector set can be the same as the dimension of each word in the text word vector set. For example, if the dimension of each word in the text word vector set is 768 dimensions, then the dimension corresponding to each word in the template word vector set can also be 768 dimensions to facilitate subsequent calculations and processing.
[0105] S208: Decoding the template word vector set and the second text feature vector set by the decoder to obtain an argument feature vector of each of the event arguments.
[0106] S209: Determine a value range corresponding to each of the event arguments based on the first text feature vector set and the argument feature vector of each of the event arguments.
[0107] Here, steps S208 and S209 may refer to steps S104 and S105.
[0108] In the embodiment of the present application, the input text and the target extraction template are converted into a text word vector set and a template word vector set, and then input into the encoder and the decoder, so as to facilitate the encoder and the decoder to process the data. At the same time, after the text word vector set is input into the encoder, a second text feature vector set is output from the encoder, and then the second text feature vector set is input into the decoder for decoding to obtain the first text feature vector set and the argument feature vector of each event argument.
[0109] In some embodiments, the implementation of step S208 "decoding the template word vector set and the second text feature vector set by the decoder to obtain the argument feature vector of each event argument" includes S2081 and S2082:
[0110] S2081: Decoding the template word vector set and the second text feature vector set by using the decoder to obtain a template feature vector set that integrates input text information;
[0111] Here, since the template feature vector set is obtained by decoding the template word vector set and the second text feature vector set through a decoder, and the second text feature vector set is a feature vector set that integrates the input text information, the template feature vector set also integrates the input text information.
[0112] Taking the decoder in the BART model as an example, the expression of the template feature vector set is:
[0113] Pt (dec) =BART-Decoder(Pt (t) ,H (enc) );
[0114] Among them, Pt (t) is a set of template word vectors.
[0115] S2082: Based on the position information of each argument role in the template word vector set, determine the argument feature vector of each event argument corresponding to each argument role from the template feature vector set.
[0116] Here, the template word vector set is obtained by converting the target extraction template into a vector form, and the target extraction template includes the position information of each argument role. Therefore, the position information of each argument role in the template word vector set can be known.
[0117] At the same time, since the template feature vector set is obtained by decoding the template word vector set and the second text feature vector set by the decoder, the argument feature vector of each event argument corresponding to each argument role can be determined in the template feature vector set through the position information of each argument role in the template word vector set.
[0118] For example, for the target extraction template " participant communicated with participant about topic at place "For example, the first word corresponds to the argument role" participant "After converting the target extraction template into a template word vector set, we can find the vector corresponding to the first word in the template word vector set and get the argument role " participant ” location information.
[0119] After the template word vector set is decoded by the decoder, the template feature vector set is obtained. Similarly, the argument role " participant "The vector where it is located is the argument role" participant " is the argument eigenvector of the event argument corresponding to .
[0120] In some embodiments, the implementation of step S2082 "determining, from the template feature vector set, the argument feature vector of each of the event arguments corresponding to each of the argument roles based on the position information of each of the argument roles in the template word vector set" includes S282a and S282b:
[0121] S282a: extracting, from the template feature vector set, a feature vector of each event argument corresponding to the argument role according to the position information of each argument role in the template word vector set;
[0122] S282b: Perform average pooling on the feature vector of each event argument to obtain the argument feature vector of the event argument.
[0123] Here, the role of average pooling is to average the feature vector of each event argument along the dimension of the text length, so that the dimension of each event argument feature vector remains consistent. Since the number of word units contained in each event argument is different, for example, the input text is "Zhang San and Li Si chat in People's Park", where the number of word units corresponding to the event argument "Zhang San" can be 2, and the number of word units corresponding to the event argument "People's Park" can be 4, then the dimensions of the event arguments "Zhang San" and "People's Park" along the text length are 2 and 4 respectively, and after average pooling, the dimensions of the event arguments "Zhang San" and "People's Park" along the text length can be 1. That is to say, after average pooling, the dimensions of the event arguments "Zhang San" and "People's Park" along the text length are the same. In some embodiments, the dimension of each event argument feature vector along the text length can be the same as the dimension of each word unit in the first text feature vector set along the text length.
[0124] In the embodiment of the present application, by performing average pooling on the feature vector of each event argument, the dimension of each event argument feature vector is made the same as the dimension of the vector corresponding to each word in the first text feature vector set, so as to facilitate subsequent calculation and processing.
[0125] In some embodiments, the implementation of step S105 "determining the value range corresponding to each of the event arguments based on the first text feature vector set and the argument feature vector of each of the event arguments" includes S1051 and S1052:
[0126] Step S1051: determining at least one candidate start and end range of each of the event arguments based on the number of word units corresponding to the first text feature vector set;
[0127] Here, the starting position of each event argument in the first text feature vector set should be smaller than the ending position of each event argument in the first text feature vector set.
[0128] Based on this, at least one candidate start and end range of each event argument can be determined according to the number of corresponding word units in the first text feature vector set. For example, if the number of corresponding word units in the first text feature vector set is 5, then at least one candidate start and end range of each event argument can be (1,2), (1,3), (1,4), (1,5), (2,3), (2,4), (2,5), (3,4), (3,5), (4,5), where the numbers in brackets represent the index of the corresponding word unit in the first text feature vector set, the first number represents the index corresponding to the starting position, and the second number represents the index of the ending position.
[0129] Step S1052: For each of the event arguments, based on at least one candidate start and end range of the event argument and the argument feature vector of the event argument, determine a value range corresponding to the event argument.
[0130] In some embodiments, Figure 3 As shown, the implementation of step S1052 "determining the value range corresponding to each event argument based on at least one candidate start and end range of each event argument and the argument feature vector of each event argument" includes S1521 to S1524:
[0131] Step S1521: Convert the argument feature vector of each of the event arguments into a start search vector representing a start position and an end search vector representing an end position.
[0132] When implementing, the argument eigenvector of each event argument is denoted by ψ k , then the starting search vector and end search vector The expression is:
[0133]
[0134]
[0135] Among them, R h represents a vector of dimension h, w (s) and w (e) are two learnable parameters, belonging to h-dimensional vectors, and o represents element-wise multiplication.
[0136] Here, since the argument eigenvector ψ k Also belongs to R h , so we can get the argument eigenvector ψ k and w (s) or (e) Performing element-wise multiplication, we get and Still belongs to R h .
[0137] Step S1522: Determine a first inner product result between a feature vector corresponding to each word in the first text feature vector set and each of the starting search vectors, and obtain a first inner product result set of each event argument candidate starting position.
[0138] Here, since the feature vector corresponding to each word in the first text feature vector set belongs to R h , Also belongs to R h Therefore, the feature vector and the starting search vector corresponding to each word in the first text feature vector set can be The inner product is calculated to obtain the first inner product result, and the inner product is calculated for each event argument to obtain the first inner product result set of each event argument candidate starting position.
[0139] Among them, the expression for finding the first inner product result set is:
[0140]
[0141] Here, k is each slot in the target extraction template, L is the number of word units corresponding to the first text feature vector set.
[0142] Step S1523: Determine the second inner product result of the feature vector corresponding to each word in the first text feature vector set and each of the end search vectors, and obtain a second inner product result set of each of the event argument candidate end positions.
[0143] Here, since the feature vector corresponding to each word in the first text feature vector set belongs to R h , Also belongs to R h Therefore, the feature vector corresponding to each word in the first text feature vector set and the end search vector The inner product is calculated to obtain the second inner product result, and the inner product is calculated for each event argument to obtain a second inner product result set of each event argument candidate end position.
[0144] Among them, the expression for finding the second inner product result set is:
[0145]
[0146] Here, k is each slot in the target extraction template, L is the number of word units corresponding to the first text feature vector set.
[0147] Step S1524: Determine a value range corresponding to each of the event arguments based on the first inner product result set of the candidate start position of each of the event arguments and the second inner product result set of the candidate end position.
[0148] Here, the value range corresponding to each event argument can be determined by calculating the sum of the first inner product result and the second inner product result in each candidate start-end range corresponding to each event argument. In some embodiments, when the sum of the first inner product result and the second inner product result in the candidate start-end range is the largest, the value range corresponding to the event argument.
[0149] For example, if the candidate start and end range is (1,2), then use the starting search vector Do the inner product with the feature vector corresponding to the first word in the first text feature vector set to get the first inner product result, and use the end search vector Make an inner product with the feature vector corresponding to the second word in the first text feature vector set to obtain a second inner product result, add the first inner product result and the second inner product result, and the candidate start and end range corresponding to the maximum sum of the first inner product result and the second inner product result is the value range of the corresponding event argument.
[0150] In some embodiments, a greedy search may be used to determine the value range corresponding to each event argument within the candidate start and end ranges.
[0151] Here, the expression for determining the value range corresponding to each event argument can be:
[0152]
[0153] in, is the value range corresponding to each event argument found, L is the number of words corresponding to the first text feature vector set, i represents the index of the word corresponding to the starting position of each event argument in the first text feature vector set, and j represents the index of the word corresponding to the ending position of each event argument in the first text feature vector set.
[0154] In an embodiment of the present application, the argument feature vector of the event argument is converted into a starting search vector representing a starting position and an ending search vector representing an ending position, and then the starting search vector and the ending search vector are used to perform inner products with the feature vectors corresponding to each word in the first text feature vector set, respectively, to obtain a first inner product result and a second inner product result, and then a greedy search is used to determine the starting and ending ranges in at least one candidate starting and ending ranges where the sum of the first inner product result and the second inner product result is the largest, to obtain the starting and ending ranges corresponding to the event argument, and finally the starting and ending ranges of each event argument are determined in turn to obtain the starting and ending ranges of all event arguments. In this way, not only is the event argument accurately extracted, but the extraction speed is also accelerated.
[0155] The present application embodiment provides a training method for an event extraction model, wherein the event extraction model includes an encoder, a decoder and an argument detection module, such as Figure 4 As shown, the method includes S401 to S407:
[0156] S401: Acquire a training text and a target extraction template corresponding to the training text.
[0157] S402: extracting a first text feature vector set corresponding to the training text through the encoder and the decoder.
[0158] S403: Encode the target extraction template and the training text through the decoder to obtain an argument feature vector of each event argument.
[0159] S404: Based on the first text feature vector set and the argument feature vector of each event argument, determine the prediction range corresponding to each event argument through the argument detection module.
[0160] Here, the implementation of steps S401 to S404 may refer to steps S101 to S105.
[0161] S405: Match the prediction range and the true value range of each of the event arguments to obtain the best prediction range corresponding to each of the event arguments whose loss function value satisfies the second preset condition.
[0162] Here, the true value range is the correct range corresponding to each event argument. In some embodiments, a bipartite graph matching method can be used to match the predicted range of each event argument with the true value range to obtain different matching schemes, and then the loss corresponding to different matching schemes is evaluated through a loss function.
[0163] Among them, the second preset condition may be that the loss function value is minimized. Then, based on the matching solution corresponding to the minimum loss function value, the optimal prediction range corresponding to each event argument may be obtained.
[0164] S406: Determine the loss function value of the event extraction model based on the optimal prediction range of each of the event arguments.
[0165] Here, the cross entropy method can be used to determine the loss function value of the event extraction model.
[0166] S407: Based on the loss function value, train the event extraction model.
[0167] Here, the smaller the loss function value is, the better the effect of the event extraction model is. In some embodiments, the parameters of the model can be optimized by the gradient descent method to improve the effect of the model.
[0168] In some embodiments, the implementation of step S405 "matching the prediction range and the true value range of each of the event arguments to obtain the best prediction range corresponding to each of the event arguments whose loss function value satisfies the second preset condition" includes S4051 to S4053:
[0169] S4051: using a bipartite graph matching method to match the prediction range and the true value range of each event argument to obtain a candidate matching group, wherein the candidate matching group includes at least one matching pair, and the matching pair includes the prediction range and the true value range of one event argument;
[0170] Here, the truth value range of all event arguments in data z (i.e., input text X) can be recorded as Among them, r is the argument role;
[0171] The prediction range of all event arguments in data z is recorded as Among them, m is the number of times the argument role r appears in the target extraction template, that is, the number of slots in the target extraction template.
[0172] The bipartite graph matching method is used to match the predicted range and true value range of each event argument to obtain a candidate matching group. For example, We can get two candidate matching groups. The first candidate matching group is: (s0, e0) corresponding to (s1,e1) corresponds to The second candidate matching group is: (s0, e0) corresponds to (s1,e1) corresponds to In the first candidate matching group, (s0,e0) and is a matching pair, (s1,e1) and is a matching pair.
[0173] S4052: Determine a loss function value for each of the candidate matching groups; wherein the loss function is used to represent the sum of the distances between each of the matching pairs in the candidate matching group;
[0174] Here, the loss function can be It is used to represent the sum of the distances between each matching pair in the candidate matching group. Among them, i is the true value range σ(i) is the index number of (s, e) in the true value range. For example, the first (s,e) in the true range matches the second in the predicted range. Then σ(i) is 2, for
[0175] When the number n of (s, e) in the true value range is greater than that in the prediction range When the number of is m, N is m, then only the matched (s, e) and When the number n of (s, e) in the true value range is smaller than that in the predicted range When the number of (s, e) in the true value range is equal to that in the predicted range, (0,0) is inserted into the true value range. The number of is equal, for example, in the forecast horizon The number m is 5, and the number n of (s, e) in the true value range is 3, then two (0,0) are inserted in the true value range to indicate that there is no answer and prevent over-prediction.
[0176] S4053: Select the candidate matching group whose loss function value satisfies the second preset condition, and obtain the best prediction range corresponding to each of the event arguments.
[0177] Among them, the second preset condition can be that the loss function value is the smallest, then the candidate matching group corresponding to the smallest loss function value is selected to obtain the best prediction range corresponding to each of the event arguments.
[0178] Here, the expression for selecting a candidate matching group whose loss function value satisfies the second preset condition is:
[0179]
[0180] Among them, i is the true value range The index number of (s, e) in the true value range, σ(i) is the corresponding prediction range of the i-th (s, e) in the true value range The index number, Γ N is N (s, e) and Matching method.
[0181] In some embodiments, the implementation of step S406 "determining the loss function value of the event extraction model based on the best prediction range of each of the event arguments" includes S4061 to S4063:
[0182] S4061: Obtaining a first inner product result corresponding to a starting position and a second inner product result corresponding to an ending position of the best prediction range of each event argument;
[0183] During implementation, for example, the best prediction range corresponding to the event argument (8,9)2 is (8,10)1, then the first inner product result corresponding to the starting position 8 and the second inner product result corresponding to the ending position 10 in (8,10)1 are obtained.
[0184] S4062: Normalize the first inner product result and the second inner product result;
[0185] Here, a softmax function may be used to normalize the obtained first inner product result and the second inner product result.
[0186] S4063: Based on the normalized first inner product result and the second inner product result, determine the loss function value of the model used by the method.
[0187] Here, the loss function value of the cross entropy calculation model can be used. In some embodiments, the expression of the loss function corresponding to an argument role r can be:
[0188]
[0189] Among them, r is the argument role, z is the data, Represents the starting position of the best prediction range s i The value of the corresponding first inner product result after normalization (i.e., the result obtained in step S4062), Represents the end position of the best prediction range e i The corresponding second inner product result is the value after normalization (i.e., the result obtained in step S4062), i is the true value range The index number of (s,e) in .
[0190] Correspondingly, the loss function expression of the model used by the method can be:
[0191] Among them, z is the data and r is the argument role.
[0192] That is, calculate the loss function value of all data and all argument roles.
[0193] In an embodiment of the present application, a prediction range that best matches the true value range is found through a bipartite graph matching loss method. In this way, the situation where one argument role corresponds to multiple event arguments can be better reduced. At the same time, based on the best match, the cross entropy method is used to determine the loss function value of the entire model to test the effectiveness of the model and facilitate the training and adjustment of the model.
[0194] The present application also provides a method for training an event extraction model. Figure 5 As shown, the method includes S501 to S509:
[0195] Step S501: obtaining a training text and a target extraction template corresponding to the training text;
[0196] Here, the training text is "In the first debate, Li Ming refuted Han Meimei's remarks that stop and frisk was ruled unconstitutional in New York."
[0197] The corresponding English sentence is: “In the first debate, Li Ming disputed Han Meimei's comment that stop and frisk was ruled unconstitutional in New York”.
[0198] In some embodiments, trigger words may be identified in the training text to facilitate a subsequent decoder to effectively extract a first text feature vector set corresponding to the training text.
[0199] The training text after identifying the trigger word is:
[0200] “In the first <t> debate< / t> In the report, Li Ming refuted Han Meimei's remarks that stop-and-frisk was ruled unconstitutional in New York."
[0201] The corresponding English is: "In the first <t> debate< / t> ,Li Ming disputed Han Meimei's comment that stop and frisk was ruled unconstitutional in New York".
[0202] The target extraction template corresponding to the training text is " Participant 1 and Participant 2 communicate topic exist Place ”.
[0203] The corresponding English is: participant communicated with participant about topic at place ” Among them, participant 1, participant 2, topic and location correspond to argument roles.
[0204] In some embodiments, the training text of the identification trigger word and the target extraction template corresponding to the training text can be converted into a vector form to facilitate the operation of the encoder and the decoder, wherein the training text of the identification trigger word converted into a vector form is a text word vector set The target extraction template converted into vector form is the template word vector set Pt (t) .
[0205] Step S502: Encode the text word vector set by an encoder to obtain a second text feature vector set;
[0206] Here, step S502 may refer to step S204.
[0207] Step S503: decoding the text word vector set and the second text feature vector set by a decoder to obtain a first text feature vector set corresponding to the input text;
[0208] Here, step S503 may refer to step S205. Figure 5Here, 101 is the first text feature vector set.
[0209] Step S504: using a decoder to decode the target extraction template converted into a vector form and the second text feature vector set to obtain a template feature vector set that integrates the input text information;
[0210] Here, step S504 may refer to step S2081. Figure 5 102 is a template feature vector set that fuses input text information.
[0211] Step S505: Based on the position information of each argument role in the target extraction template converted into a vector form, determine the argument feature vector of each event argument corresponding to each argument role from the template feature vector set.
[0212] Here, step S505 can refer to step S2082. Target extraction template " Participant 1 and Participant 2 exist Place communicate topic ", the positions corresponding to the first three words are the positions of the argument role "Participant 1 (participant)". After converting the target extraction template into a template word vector set, the vectors corresponding to the first three words can be found in the template word vector set to obtain the position information of the argument role "Participant 1" in the template word vector set.
[0213] After the template word vector set is decoded by the decoder, a template feature vector set is obtained. Similarly, the vector of the argument role "Participant 1" in the template word vector set can be found in the template feature vector set, which is the argument feature vector of the event argument corresponding to the argument role "Participant 1", thereby obtaining the argument feature vector of each event argument.
[0214] In some embodiments, the implementation of step S505 may include:
[0215] S505a: extracting a feature vector of each of the event arguments corresponding to each of the argument roles from the template feature vector set based on the position information of each argument role in the template word vector set;
[0216] S505b: Perform average pooling on the feature vector of each event argument to obtain the argument feature vector of the event argument.
[0217] Here, step S505a and step S505b may refer to step S282a and step S282b.
[0218] Figure 5103 is the argument feature vector of each event argument, among which, label 1 is the argument feature vector of the event argument corresponding to the first argument role “participant 1” in the target extraction template, label 2 is the argument feature vector of the event argument corresponding to the second argument role “participant 2” in the target extraction template, label 3 is the argument feature vector of the event argument corresponding to the third argument role “topic” in the target extraction template, and label 4 is the argument feature vector of the event argument corresponding to the fourth argument role “place” in the target extraction template.
[0219] Step S506: Determine a prediction range corresponding to each event argument based on the first text feature vector set and the argument feature vector of each event argument.
[0220] Here, the implementation of step S506 may include:
[0221] Step S5061: determining at least one candidate start and end range of each of the event arguments based on the number of word units corresponding to the first text feature vector set;
[0222] Here, step S5061 may refer to step S1051.
[0223] Step S5062: converting the argument feature vector of each event argument into a starting search vector indicating a starting position and an ending search vector indicating an ending position;
[0224] Step S5063: determining a first inner product result of a feature vector corresponding to each word in the first text feature vector set and each of the starting search vectors, and obtaining a first inner product result set of each of the event argument candidate starting positions;
[0225] Step S5064: determining a second inner product result of the feature vector corresponding to each word in the first text feature vector set and each of the end search vectors, and obtaining a second inner product result set of each of the event argument candidate end positions;
[0226] Step S5065: Determine the prediction range corresponding to each of the event arguments based on the first inner product result set of the candidate start position of each of the event arguments and the second inner product result set of the candidate end position.
[0227] Here, steps S5062 to S5065 may refer to steps S1521 to S1524.
[0228] In some embodiments, when the sum of the first inner product result and the second inner product result in the candidate start and end range is the largest, it corresponds to the prediction range of the event argument.
[0229] Here, step S506 corresponds to Figure 5 "Multi-event argument value range prediction" in . As can be seen from the figure, the predicted ranges are (8,10), (6,7), (11,11), (18,20), respectively. The position number corresponding to the predicted range is the index of the corresponding word in the first text feature vector set. (8,10)(6,7)(11,11)(18,20) correspond to "Han Meimei", "Li Ming", "Stop and Frisk", and "New York", respectively. That is, the event argument extracted by the first argument role "Participant 1" is "Han Meimei", the event argument extracted by the second argument role "Participant 2" is "Li Ming", the event argument extracted by the third argument role "Topic" is "Stop and Frisk", and the event argument extracted by the fourth argument role "Location" is "New York". It can be seen that the event arguments extracted by the argument roles "Participant 1" and "Participant 2" in the prediction scope are interchanged. In fact, the event argument extracted by the first argument role "Participant 1" should be "Li Ming", and the event argument extracted by the second argument role "Participant 2" should be "Han Meimei".
[0230] Step S507: Match the prediction range and the true value range of each event argument to obtain the best prediction range corresponding to each event argument whose loss function value satisfies the second preset condition.
[0231] In some embodiments, the implementation of step S507 may include:
[0232] S5071: using a bipartite graph matching method to match the prediction range and the true value range of each event argument to obtain a candidate matching group, wherein the candidate matching group includes at least one matching pair, and the matching pair includes the prediction range and the true value range of one event argument;
[0233] Here, the true value range of all event arguments in the training text is recorded as (8,9)2, (11,14)3, (18,20)4], where r is the argument role;
[0234] The prediction range of all event arguments in the training text is recorded as (6,7)2, (11,11)3, (18,20)4].
[0235] The bipartite graph matching method is used to match the predicted range and true value range of each event argument to obtain N candidate matching groups. For example, one of the candidate matching groups can be: (6,7)1 in the true value range is matched with (6,7)2 in the predicted range, (8,9)2 in the true value range is matched with (8,10)1 in the predicted range, (11,14)3 in the true value range is matched with (11,11)3 in the predicted range, (18,20)4 in the true value range is matched with (18,20)4 in the predicted range. Here, (6,7)1 in the true value range and (6,7)2 in the predicted range are a matching pair.
[0236] S5072: Determine a loss function value for each of the candidate matching groups; wherein the loss function is used to represent the sum of the distances between each of the matching pairs in the candidate matching group;
[0237] S5073: Select the candidate matching group whose loss function value satisfies the second preset condition, and obtain the optimal prediction range corresponding to each of the event arguments.
[0238] Here, step S5072 and step S5073 may refer to step S4052 and step S4053.
[0239] like Figure 5 As shown, for the training text "In the first debate, Li Ming refuted Han Meimei's remarks that stop-and-frisk was ruled unconstitutional in New York", the true value range is (6,7), (8,9), (11,14), (18,20). Through the above bipartite graph matching loss method, the best prediction range is (6,7), (8,10), (11,11), (18,20), that is, the event argument extracted from the first argument role "Participant 1" corresponds to "Li Ming", and the event argument extracted from the second argument role "Participant 2" corresponds to "Han Meimei", which changes the incorrect matching of the argument roles "Participant 1" and "Participant 2" in step S506. In this way, the situation where one argument role corresponds to multiple event arguments can be effectively reduced.
[0240] S508: Determine the loss function value of the event extraction model based on the optimal prediction range of each event argument;
[0241] In some embodiments, the implementation of step S508 may include:
[0242] S5081: Obtain the first inner product result corresponding to the starting position and the second inner product result corresponding to the ending position of the best prediction range of each event argument;
[0243] S5082: Normalize the first inner product result and the second inner product result;
[0244] S5083: Based on the normalized first inner product result and the second inner product result, determine the loss function value of the model used by the method.
[0245] Here, steps S5081 to S5083 may refer to steps S4061 to S4063.
[0246] S509: Based on the loss function value, train the event extraction model.
[0247] Here, step S509 may refer to step S407.
[0248] Based on the above method, corresponding verification was done on three datasets: ACE 2005, RAMS, and WIKIEVENT:
[0249] Among them, ACE 2005 focuses on event extraction from sentence-level text (Sentence-Level Event Argument Extraction, S-EAE), mainly from news articles. RAMS and WIKIEVENT focus on event extraction from document-level text (Document-Level Event Argument Extraction, D-EAE), from news and Wikipedia respectively. Table 2 shows the detailed statistics of different datasets in the event extraction process. The dataset preprocessing and partitioning methods in the relevant technology are followed, but no entity calibration is required.
[0250] Table 2
[0251] Dataset ACE 2005 RAMS WIKIEVENT Number of event arguments Training set 4859 17026 4552 Validation set 605 2188 428 Test Set 576 2023 566 Event Type 33 139 50 Argument Role 36 65 59 The number of event arguments per event 1.19 2.33 1.40
[0252] The present application example uses the standard element identification F1 score (Arg-I) and element classification F1 score (Arg-C) as evaluation indicators, where Arg-I is used to measure the position of the prediction range and Arg-C is used to measure whether the argument role is correctly predicted. For WIKIEVENT, the center word F1 is also evaluated, which only involves the matching of the center word.
[0253] Specific method: Train a basic or enhanced version of the pre-trained language model (PLM) on a single NVIDIA V100 and 1080Ti graphics card. The embodiment of the present application selects AdamW as the optimization method, and uses a linear learning rate with a warm-up rate of 0.1 as the scheduling strategy. Since the documents occupy a lot of memory, the number of batch processing is reduced, and the maximum number of training iterations is increased from 10,000 to 20,000. The model is also trained with a window size of about 500 trigger words to adapt to the graphics processing unit (GPU). The true value calibration missing rate during training is less than 0.1%. For a fair comparison, all documents in RAMS are used for evaluation. The learning rates of S-EAE and D-EAE are 4e respectively. -5 and 3e -5 .
[0254] Benchmarks: The following benchmarks are chosen because they achieve state-of-the-art performance in Event Argument Extraction (EAE) and are also based on PLM:
[0255] 1.EEQA is the first (machine) reading comprehension (Question Answering, QA) model designed for the S-EAE task.
[0256] 2. FEAE considers event argument interactions through knowledge distillation and extends the QA-based approach to D-EAE.
[0257] 3. ONEIE jointly extracts entities, relations, and events, which is different from QA-based models that rely on extracted entities as candidate parameters.
[0258] 4. BART-Gen generates event arguments sequentially through a sequence-to-sequence model instead of extracting the start and end ranges of event arguments from the article.
[0259] Table 3 shows the overall performance of different models.
[0260] Table 3
[0261]
[0262]
[0263] Among them, BERT-B is the basic version of BERT, BERT-L is the enhanced version of BERT, BART-B is the basic version of BART, BART-L is the enhanced version of BART, PAIE-B is the basic version of the model provided in the embodiment of the present application, PAIE-L is the enhanced version of the model provided in the embodiment of the present application, Arg-I is used to measure the position of the prediction range, Arg-C is used to measure whether the argument role is correctly predicted, and Head-C is used to measure the match of the central word.
[0264] Here, the higher the values of Arg-I, Arg-C, and Head-C under different data sets (ACE05, RAMS, and WIKIEVENT) corresponding to different models, the higher the prediction accuracy, that is, the higher the value of Arg-I, the more accurate the prediction range, the higher the value of Arg-C, the higher the probability that the argument role is correctly predicted, and the higher the value of Head-C, the more correct the match of the central word.
[0265] It can be observed that: (1) PAIE performs best compared with the baseline method on all datasets including S-EAE and D-EAE tasks. This proves that the method proposed in the embodiment of the present application has good generalization ability. It not only inherits the advantages of the basic QA-based EAE model, but also successfully solves the problem of long distances between event arguments, especially in document-level text event extraction. (2) As the backbone network of PLM, BART performs much better than BERT. The method provided in the embodiment of the present application can be further improved by BART-L, indicating that the use of template decoding can bring good performance. (3) Models that consider event argument interactions (FEAE, BART-Gen and PAIE) perform better than other models, especially in the D-EAE task. This is consistent with the expectations of the embodiment of the present application, that is, cross-sentence event arguments require long-distance dependencies, and implicitly or explicitly introducing dependency information between event arguments will improve the accuracy of model prediction.
[0266] Based on the foregoing embodiments, an embodiment of the present application provides an event extraction device, which includes the modules included, the sub-modules included in each module, the units included in each sub-module, and the sub-units included in each unit, all of which can be implemented by electronic devices; of course, they can also be implemented by specific logic circuits; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP) or a field programmable gate array (FPGA), etc.
[0267] Figure 6 A schematic diagram of the structure of an event extraction device provided in an embodiment of the present application is shown in FIG. Figure 6As shown, the event extraction device 600 includes a first acquisition module 601, a first extraction module 602, a second acquisition module 603, a first decoding module 604 and a determination module 605, wherein:
[0268] A first acquisition module 601 is used to acquire an input text; wherein the input text includes a trigger word and at least one event argument;
[0269] A first extraction module 602, configured to extract a first text feature vector set corresponding to the input text through an encoder and a decoder;
[0270] The second acquisition module 603 is used to acquire a target extraction template corresponding to the trigger word;
[0271] A first decoding module 604 is used to decode the target extraction template and the input text using a decoder to obtain an argument feature vector of each event argument;
[0272] The first determination module 605 is used to determine a value range corresponding to each of the event arguments based on the first text feature vector set and the argument feature vector of each of the event arguments.
[0273] In some embodiments, the apparatus further includes: a first conversion module 606: configured to convert the input text and the target extraction template into a text word vector set and a template word vector set, respectively.
[0274] In some embodiments, the extraction module 602 includes: an encoding submodule, used to encode the text word vector set using the encoder to obtain a second text feature vector set; a first decoding submodule, used to decode the text word vector set and the second text feature vector set using the decoder to obtain a first text feature vector set corresponding to the input text.
[0275] Correspondingly, the decoding module 604 includes: a second decoding submodule, configured to use the decoder to decode the template word vector set and the second text feature vector set to obtain an argument feature vector of each of the event arguments.
[0276] In some embodiments, the second decoding submodule includes: a decoding unit, used to use the decoder to decode the template word vector set and the second text feature vector set to obtain a template feature vector set that integrates input text information; a first determination unit, used to determine the argument feature vector of each of the event arguments corresponding to each of the argument roles from the template feature vector set based on the position information of each argument role in the template word vector set.
[0277] In some embodiments, the first determination unit includes: an extraction subunit, used to extract the feature vector of each event argument corresponding to each argument role from the template feature vector set based on the position information of each argument role in the template word vector set; a pooling subunit, used to perform average pooling on the feature vector of each event argument to obtain the argument feature vector of the event argument.
[0278] In some embodiments, the device further includes: a second determination module for determining a target event type based on the trigger word; and a third determination module for determining a target extraction template from a preset template library based on the target event type.
[0279] In some embodiments, the device also includes: a fourth determination module, used to determine a set of event types corresponding to a text set, wherein the event type set includes at least one event type; a fifth determination module, used to determine at least two argument roles in each of the event types, and the relationship information between the at least two argument roles; a splicing module, used to splice the at least two argument roles for each of the event types based on the relationship information between the at least two argument roles to obtain an extraction template for each of the event types; and a forming module, which forms the preset template library based on the extraction template of each of the event types in the event type set.
[0280] In some embodiments, the device also includes: a third acquisition module, used to obtain the trigger words of the input text and identify the trigger words of the input text; correspondingly, the extraction module 602 is used to extract the first text feature vector set corresponding to the identified input text through an encoder and a decoder.
[0281] In some embodiments, the first determination module 605 includes: a first determination submodule, used to determine at least one candidate start and end range of each of the event arguments based on the number of word units corresponding to the first text feature vector set; a second determination submodule, used to determine, for each of the event arguments, a value range corresponding to the event argument based on at least one candidate start and end range of the event argument and the argument feature vector of the event argument.
[0282] In some embodiments, the second determination submodule includes: a conversion unit, used to convert the argument feature vector of each of the event arguments into a starting search vector representing a starting position and an ending search vector representing an ending position; a second determination unit, used to determine the first inner product result of the feature vector corresponding to each word in the first text feature vector set and each of the starting search vectors, and obtain a first inner product result set of each candidate starting position of the event argument; a third determination unit, used to determine the second inner product result of the feature vector corresponding to each word in the first text feature vector set and each of the ending search vectors, and obtain a second inner product result set of each candidate ending position of the event argument; a fourth determination unit, used to determine the value range corresponding to each of the event arguments based on the first inner product result set of each candidate starting position of the event argument and the second inner product result set of the candidate ending position.
[0283] Figure 7 A schematic diagram of the structure of a training device for an event extraction model provided in an embodiment of the present application is shown in FIG. Figure 7 As shown, the training device 700 of the event extraction model includes:
[0284] The fourth acquisition module 701 is used to acquire a training text and a target extraction template corresponding to the training text;
[0285] A second extraction module 702 is used to extract a first text feature vector set corresponding to the training text through an encoder and a decoder;
[0286] A second encoding module 703 is used to encode the target extraction template and the training text through the decoder to obtain an argument feature vector of each event argument;
[0287] A sixth determination module 704, configured to determine a prediction range corresponding to each of the event arguments through the argument detection module based on the first text feature vector set and the argument feature vector of each of the event arguments;
[0288] A matching module 705 is used to match the prediction range and the true value range of each event argument to obtain the best prediction range corresponding to each event argument whose loss function value satisfies the second preset condition;
[0289] A seventh determination module 706, configured to determine a loss function value of the event extraction model based on the best prediction range of each event argument;
[0290] The training module 707 is used to train the event extraction model based on the loss function value.
[0291] In some embodiments, the matching module 705 includes: a matching submodule, which is used to use a bipartite graph matching method to match the prediction range and the true value range of each of the event arguments to obtain a candidate matching group, wherein the candidate matching group includes at least one matching pair, and the one matching pair includes the prediction range and the true value range of one of the event arguments; a third determination submodule, which is used to determine the loss function value of each of the candidate matching groups; wherein the loss function is used to represent the sum of the distances between each of the matching pairs in the candidate matching group; and a selection submodule, which is used to select the candidate matching group whose loss function value satisfies the second preset condition to obtain the optimal prediction range corresponding to each of the event arguments.
[0292] In some embodiments, the seventh determination module 706 includes: an acquisition submodule, used to obtain the first inner product result corresponding to the starting position of the optimal prediction range of each of the event arguments and the second inner product result corresponding to the end position; a normalization submodule, used to normalize the first inner product result and the second inner product result; a fourth determination submodule, used to determine the loss function value of the model used by the method based on the normalized first inner product result and the second inner product result.
[0293] The description of the above device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the device embodiment of the present application, please refer to the description of the method embodiment of the present application for understanding.
[0294] It should be noted that in the embodiments of the present application, if the above-mentioned event extraction method and related training method are implemented in the form of a software function module and sold or used as an independent product, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly reflected in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including a number of instructions to enable an electronic device (which can be a personal computer, server, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a ROM (Read Only Memory), a disk or an optical disk. In this way, the embodiments of the present application are not limited to any specific combination of hardware and software.
[0295] Correspondingly, an embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, it implements the steps of the event extraction method and related training method provided in the above embodiments.
[0296] Correspondingly, an embodiment of the present application provides a readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned event extraction method and related training methods are implemented.
[0297] It should be noted here that the description of the above storage medium and platform embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and platform embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0298] It should be noted that Figure 8 A hardware entity diagram of an electronic device according to an embodiment of the present application is shown in FIG. Figure 8 As shown, the hardware entity of the electronic device 800 includes: a processor 801, a communication interface 802 and a memory 803, wherein
[0299] The processor 801 generally controls the overall operation of the electronic device 800 .
[0300] The communication interface 802 may enable the electronic device 800 to communicate with other platforms or electronic devices or servers through a network.
[0301] The memory 803 is configured to store instructions and applications executable by the processor 801, and can also cache data to be processed or processed by the processor 801 and various modules in the electronic device 800 (for example, image data, audio data, voice communication data, and video communication data), which can be implemented through FLASH (flash memory) or random access memory (Random Access Memory, RAM).
[0302] An embodiment of the present application also provides a computer program product, including a computer-readable code, characterized in that when the computer-readable code is executed on a device, a processor in the device executes steps for implementing the aforementioned method.
[0303] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0304] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0305] In addition, all functional units in the embodiments of the present application can be integrated into one processing module, or each unit can be a separate unit, or two or more units can be integrated into one unit; the above integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional units. A person of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium, which, when executed, executes the steps of the above method embodiments; and the aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROM, RAM, disks or optical disks.
[0306] The methods disclosed in several method embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments.
[0307] The features disclosed in several product embodiments provided in this application can be arbitrarily combined without conflict to obtain new product embodiments.
[0308] The features disclosed in several method or device embodiments provided in this application can be arbitrarily combined without conflict to obtain new method embodiments or device embodiments.
[0309] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. An event extraction method, It is characterized in that include: Obtaining input text; wherein the input text includes a trigger word and at least one event argument; Extracting a first text feature vector set corresponding to the input text through an encoder and a decoder; Obtaining a target extraction template corresponding to the trigger word; Decoding the target extraction template and the input text by the decoder to obtain an argument feature vector of each event argument; Determine a value range corresponding to each of the event arguments based on the first text feature vector set and the argument feature vector of each of the event arguments; The method further comprises: Converting the input text and the target extraction template into a text word vector set and a template word vector set respectively; The step of extracting a first text feature vector set corresponding to the input text through an encoder and a decoder includes: Encoding the text word vector set by the encoder to obtain a second text feature vector set; Decoding the text word vector set and the second text feature vector set by the decoder to obtain a first text feature vector set corresponding to the input text; Correspondingly, the target extraction template and the input text are decoded by the decoder to obtain an argument feature vector of each event argument, including: Decoding the template word vector set and the second text feature vector set by using the decoder to obtain a template feature vector set that integrates input text information; Based on the position information of each argument role in the template word vector set, an argument feature vector of each event argument corresponding to each argument role is determined from the template feature vector set.
2. The method according to claim 1, It is characterized in that The determining, based on the position information of each argument role in the template word vector set, the argument feature vector of each event argument corresponding to each argument role from the template feature vector set comprises: According to the position information of each argument role in the template word vector set, a feature vector of each event argument corresponding to the argument role is extracted from the template feature vector set; Average pooling is performed on the feature vector of each event argument to obtain the argument feature vector of the event argument.
3. The method according to claim 1 or 2, It is characterized in that The method further comprises: Based on the trigger word, determining the target event type; A target extraction template is determined from a preset template library based on the target event type.
4. The method according to claim 3, It is characterized in that The method further comprises: Determine an event type set corresponding to the text set, wherein the event type set includes at least one event type; Determine at least two argument roles in each of the event types, and relationship information between the at least two argument roles; For each of the event types, the at least two argument roles are spliced based on the relationship information between the at least two argument roles to obtain an extraction template for each of the event types; The preset template library is formed based on the extracted template of each event type in the event type set.
5. The method according to claim 1 or 2, It is characterized in that The method further comprises: Acquire the trigger words of the input text, and identify the trigger words of the input text; The extracting, by means of an encoder and a decoder, a first text feature vector set corresponding to the input text comprises: Through the encoder and the decoder, a first text feature vector set corresponding to the marked input text is extracted.
6. The method according to claim 1 or 2, It is characterized in that The determining, based on the first text feature vector set and the argument feature vector of each event argument, a value range corresponding to each event argument comprises: Determining at least one candidate start and end range of each of the event arguments based on the number of word units corresponding to the first text feature vector set; For each of the event arguments, a value range corresponding to the event argument is determined based on at least one candidate start and end range of the event argument and an argument feature vector of the event argument.
7. The method according to claim 6, It is characterized in that The step of determining, for each of the event arguments, a value range corresponding to the event argument based on at least one candidate start and end range of the event argument and an argument feature vector of the event argument comprises: Converting the argument feature vector of each of the event arguments into a starting search vector representing a starting position and an ending search vector representing an ending position; Determine a first inner product result of a feature vector corresponding to each word in the first text feature vector set and each of the starting search vectors, and obtain a first inner product result set of each event argument candidate starting position; Determine a second inner product result of a feature vector corresponding to each word in the first text feature vector set and each of the end search vectors, and obtain a second inner product result set of each of the event argument candidate end positions; Based on the first inner product result set of each candidate start position of the event argument and the second inner product result set of the candidate end position, a value range corresponding to each event argument is determined.
8. A training method for an event extraction model, It is characterized in that The event extraction model includes an encoder, a decoder and an argument detection module, including: Obtaining a training text and a target extraction template corresponding to the training text; Extracting a first text feature vector set corresponding to the training text through the encoder and the decoder; Encoding the target extraction template and the training text by the encoder to obtain an argument feature vector of each event argument; Based on the first text feature vector set and the argument feature vector of each event argument, determining the prediction range corresponding to each event argument through the argument detection module; Matching the prediction range and the true value range of each of the event arguments to obtain the best prediction range corresponding to each of the event arguments whose loss function value satisfies the second preset condition; Determining a loss function value of the event extraction model based on the best prediction range of each of the event arguments; Based on the loss function value, training the event extraction model; The method further comprises: Converting the training text and the target extraction template into a text word vector set and a template word vector set respectively; The step of extracting a first text feature vector set corresponding to the training text through an encoder and a decoder includes: Encoding the text word vector set by the encoder to obtain a second text feature vector set; Decoding the text word vector set and the second text feature vector set by the decoder to obtain a first text feature vector set corresponding to the training text; Correspondingly, the target extraction template and the training text are decoded by the decoder to obtain the argument feature vector of each event argument, including: Decoding the template word vector set and the second text feature vector set by using the decoder to obtain a template feature vector set that integrates input text information; Based on the position information of each argument role in the template word vector set, an argument feature vector of each event argument corresponding to each argument role is determined from the template feature vector set.
9. The method according to claim 8, It is characterized in that The matching of the prediction range and the true value range of each of the event arguments to obtain the best prediction range corresponding to each of the event arguments whose loss function value satisfies the second preset condition includes: Using a bipartite graph matching method, matching the prediction range and the true value range of each event argument to obtain a candidate matching group, wherein the candidate matching group includes at least one matching pair, and the matching pair includes the prediction range and the true value range of one event argument; Determine a loss function value for each of the candidate matching groups; wherein the loss function value is used to represent the sum of the distances between each of the matching pairs in the candidate matching group; The candidate matching group whose loss function value satisfies the second preset condition is selected to obtain the best prediction range corresponding to each of the event arguments.
10. The method according to claim 8 or 9, It is characterized in that The determining of the loss function value of the event extraction model based on the best prediction range of each event argument includes: Obtain a first inner product result corresponding to a starting position and a second inner product result corresponding to an ending position of the best prediction range of each event argument; Normalizing the first inner product result and the second inner product result; Based on the normalized first inner product result and the second inner product result, a loss function value of the model used by the method is determined.
11. An event extraction device, It is characterized in that include: A first acquisition module is used to acquire an input text of a sentence level or a document level text; wherein the input text includes a trigger word and at least one event argument; A first extraction module, used for extracting a first text feature vector set corresponding to the input text through an encoder and a decoder; A second acquisition module, used to acquire a target extraction template corresponding to the trigger word; A first decoding module, configured to decode the target extraction template and the input text using the decoder to obtain an argument feature vector of each event argument; A first determination module, configured to determine a value range corresponding to each of the event arguments based on the first text feature vector set and the argument feature vector of each of the event arguments; The first extraction module is further used to encode the text word vector set using the encoder to obtain a second text feature vector set; and decode the text word vector set and the second text feature vector set using the decoder to obtain a first text feature vector set corresponding to the input text; The first decoding module is also used to use the decoder to decode the template word vector set and the second text feature vector set to obtain a template feature vector set that integrates the input text information; based on the position information of each argument role in the template word vector set, determine the argument feature vector of each event argument corresponding to each argument role from the template feature vector set.
12. A training device for an event extraction model, It is characterized in that include: A fourth acquisition module, used to acquire a training text and a target extraction template corresponding to the training text; A second extraction module, used to extract a first text feature vector set corresponding to the training text through an encoder and a decoder; A second encoding module, configured to encode the target extraction template and the training text through the encoder to obtain an argument feature vector of each event argument; a sixth determination module, configured to determine a prediction range corresponding to each of the event arguments through an argument detection module based on the first text feature vector set and the argument feature vector of each of the event arguments; A matching module, used for matching the prediction range and the true value range of each of the event arguments to obtain the best prediction range corresponding to each of the event arguments whose loss function value satisfies the second preset condition; A seventh determination module, configured to determine a loss function value of the event extraction model based on an optimal prediction range of each event argument; A training module, used for training the event extraction model based on the loss function value; The second extraction module is further used to encode the text word vector set through the encoder to obtain a second text feature vector set; decode the text word vector set and the second text feature vector set through the decoder to obtain a first text feature vector set corresponding to the training text; The second encoding module is also used to use the decoder to decode the template word vector set and the second text feature vector set to obtain a template feature vector set that integrates the input text information; based on the position information of each argument role in the template word vector set, determine the argument feature vector of each event argument corresponding to each argument role from the template feature vector set.
13. An electronic device comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, and the processor implements the steps of the method according to any one of claims 1 to 10 when executing the program.
14. A computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps in the method according to any one of claims 1 to 10 are implemented.
