Event extraction method, device, equipment and medium
By combining a pre-defined event encoding model, a label classification model, and an event extraction model, event extraction without trigger words is achieved, improving the accuracy and efficiency of event extraction and solving the problems of low efficiency and low accuracy in existing technologies.
Patent Information
- Application Number
- CN202211619612.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-15
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2042-12-15
AI Technical Summary
Existing technologies for event extraction are inefficient and inaccurate, especially due to the difficulty in identifying or the ambiguity of trigger words, which leads to a decrease in accuracy.
The text to be extracted is encoded by a pre-set event encoding model, the event is identified by a label classification model, the event labels are encoded into the text to be extracted by an event extraction model, and finally the subject is identified by the target text vector by the event extraction model, thus achieving event extraction without trigger words.
It improves the accuracy and efficiency of event extraction, reduces reliance on trigger words, and lowers the need for trigger word annotation.
Smart Images

Figure CN115952767B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, and in particular to an event extraction method and device, equipment and medium. BACKGROUND
[0002] With the continuous development of science and technology, a large amount of data has poured into people's life. In order to quickly process large-scale data and mine information with potential value in data, people's demand for information extraction technology is increasing. Event extraction is to detect the occurrence of events in unstructured text, judge the type of event, extract important elements participating in the event, and present the results in a structured manner.
[0003] In the prior art, event extraction is often performed by first identifying trigger words and then performing event extraction based on the trigger words. However, in many texts, event trigger words are difficult to identify or have ambiguity, so if the trigger word identification is not accurate, the accuracy of the final event extraction will be reduced. SUMMARY
[0004] The embodiments of the present application provide an event extraction method, device, equipment and medium to solve the problems of low efficiency and low accuracy of event extraction in the prior art.
[0005] An event extraction method comprises:
[0006] Obtaining at least one text to be extracted, encoding all the text to be extracted by a preset event encoding model to obtain a to-be-extracted vector corresponding to each text to be extracted;
[0007] Obtaining a label classification model, performing event recognition on all the to-be-extracted vectors by the label classification model to obtain an event label corresponding to each text to be extracted;
[0008] Obtaining an event extraction model, respectively encoding all the event labels to the text to be extracted corresponding to each event label by the encoding end of the event extraction model to obtain a target text vector corresponding to each event label;
[0009] Performing event subject recognition on all the target text vectors by the decoding end of the event extraction model to obtain an event text corresponding to each target text vector.
[0010] An event extraction device comprises:
[0011] A text encoding module is configured to obtain at least one text to be extracted, encode all the text to be extracted by a preset event encoding model to obtain a to-be-extracted vector corresponding to each text to be extracted;
[0012] An event recognition module is used to obtain a label classification model, and to perform event recognition on all the vectors to be extracted using the label classification model to obtain event labels corresponding to each of the texts to be extracted.
[0013] The event fusion module is used to obtain an event extraction model, and to encode all the event tags into the text to be extracted corresponding to each event tag through the encoding end in the event extraction model, so as to obtain the target text vector corresponding to each event tag;
[0014] The event extraction module is used to perform event subject identification on all the target text vectors through the decoding end in the event extraction model, so as to obtain the event text corresponding to each target text vector.
[0015] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the above-described event extraction method.
[0016] A computer-readable storage medium storing a computer program, characterized in that the computer program, when executed by a processor, implements the above-described event extraction method.
[0017] This invention provides an event extraction method, apparatus, device, and medium. The method encodes the text to be extracted using a preset event encoding model, thereby acquiring the extracted quantities and improving the accuracy of subsequent event recognition. It identifies events in the extracted vector using a label classification model, specifically by identifying events in the extracted quantities using BIO tags, thus acquiring event labels and improving event recognition accuracy. The event tags are encoded into the text to be extracted using an event extraction model, thereby acquiring the target text vector. The event extraction model then performs subject recognition on the target text vector, identifying the event subject in the target text vector based on the event tags, thus acquiring the event text. This achieves event extraction without trigger words, further reducing reliance on trigger words, lowering the need for trigger word annotation, improving the accuracy and efficiency of event extraction. Attached Figure Description
[0018] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1is a schematic diagram of an application environment of an event extraction method in an embodiment of the present application;
[0020] Figure 2 is a flowchart of an event extraction method in an embodiment of the present application;
[0021] Figure 3 is a flowchart of step S30 of the event extraction method in an embodiment of the present application;
[0022] Figure 4 is a flowchart of step S40 of the event extraction method in an embodiment of the present application;
[0023] Figure 5 is a principle block diagram of an event extraction device in an embodiment of the present application;
[0024] Figure 6 is a schematic diagram of a computer device in an embodiment of the present application. DETAILED DESCRIPTION
[0025] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of the present application.
[0026] The event extraction method provided in the embodiments of the present application can be applied in an application environment as shown in Figure 1 . Specifically, the event extraction method is applied in an event extraction device, which includes a client and a server as shown in Figure 1 . The client and the server communicate through a network, and are used to solve the problems of low efficiency and low accuracy of event extraction in the prior art. The server can be an independent server, or a cloud server providing basic cloud computing services such as cloud service, cloud database, cloud computing, cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, content delivery network (CDN), and big data and artificial intelligence platform. The client, also known as the user end, is a program that provides classification services for clients and corresponds to the server. The client can be installed on, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices.
[0027] In an embodiment, as shown in Figure 2 , an event extraction method is provided, and the server in Figure 1 is taken as an example for illustration, including the following steps:
[0028] S10: Obtain at least one text to be extracted, encode all the text to be extracted by a preset event encoding model, and obtain a to-be-extracted vector corresponding to each of the text to be extracted.
[0029] Understandably, the text to be extracted can be collected from different databases by crawler technology, or can be sent to the server by the user from the client. The text to be extracted is the text that needs to be extracted, for example, some news needs to extract events as a title, or extract financial events from financial industry information. The preset event encoding model is a general transformer type model, such as a bert model. The to-be-extracted vector is obtained by encoding the text to be extracted by the preset event encoding model.
[0030] Specifically, the preset event encoding model is called from the database, and in this embodiment, the preset event encoding model adopts the bert model to encode the text to be extracted, that is, the text to be extracted is processed by the preset event encoding model to split the text to be extracted into multiple words. A CLS flag is added before all the words of each content are split, representing the identification of the overall semantics of the content. And respectively after all the words of each content are split from the text to be extracted, a SEP flag is added as a separation identifier to form an input vector. Further, the input vector is sequentially processed by the preset event encoding model to obtain an attention vector corresponding to each input vector. And all the attention vectors are predicted by the prediction layer to obtain a to-be-extracted vector corresponding to each text to be extracted.
[0031] S20: Obtain a label classification model, and identify events of all the to-be-extracted vectors by the label classification model to obtain an event label corresponding to each of the text to be extracted.
[0032] Understandably, the label classification model is denoted as a multi-label classifier, and the events in the to-be-extracted vector are labeled by BIO labels. The event label is used to represent the event in the text to be extracted.
[0033] Specifically, after obtaining the to-be-extracted vectors corresponding to the to-be-extracted texts, the label classification model is called, all to-be-extracted vectors are input into the label classification model, and event recognition is performed on each to-be-extracted vector by the label classification model, that is, the events in the to-be-extracted vectors are recognized by using BIO labels, that is, the start word of the event in the to-be-extracted vector is labeled by using the B label, the content other than the start word of the event is labeled by using the I label, and the content not belonging to the event in the to-be-extracted vector is labeled by using the O label. Then, the event labels in the to-be-extracted text are determined according to the B label, the I label and the O label corresponding to the same to-be-extracted text. When a to-be-extracted text includes multiple events, all events are sequentially predicted, that is, the start word of each event is labeled by using the B label, the content other than the start word is labeled by using the I label, and the content not belonging to the event is labeled by using the O label, and then the B label, the I label and the O label corresponding to the same event are fused to obtain the event labels corresponding to each event.
[0034] In S30, an event extraction model is obtained, and all event labels are encoded into the to-be-extracted texts corresponding to the event labels by the encoding end of the event extraction model, to obtain target text vectors corresponding to the event labels.
[0035] Understandably, the event extraction model is a transformer model, which is used for event subject extraction of the target text vector. The target text vector includes the event label and the to-be-extracted text, that is, the fusion of the event label and the to-be-extracted text. The event extraction model includes an encoding end and a decoding end, the encoding end includes an input layer, an attention layer and an output layer, and the decoding end includes a linear transformation layer and a prediction layer.
[0036] Specifically, after obtaining the event labels corresponding to each to-be-extracted text, the event extraction model is called, all event labels corresponding to each to-be-extracted text and all to-be-extracted texts are input into the event extraction model, and the event extraction model encodes the event labels corresponding to each to-be-extracted text and the to-be-extracted texts, to obtain label vectors corresponding to each event label and text vectors corresponding to each to-be-extracted text. Then, the label vectors corresponding to each event label and the text vectors corresponding to each to-be-extracted text corresponding to the same to-be-extracted text are respectively subjected to attention processing by the attention layer of the encoding end of the event extraction model, that is, the label vectors corresponding to each event label are encoded into the text vectors corresponding to each to-be-extracted text, to obtain fusion vectors corresponding to each to-be-extracted text. Then, the fusion vectors corresponding to each to-be-extracted text are respectively subjected to prediction processing by the fully connected layer of the encoding end of the event extraction model, to obtain target text vectors corresponding to each event label.
[0037] S40: performing event subject identification on all the target text vectors through a decoding end in the event extraction model to obtain event texts corresponding to each of the target text vectors.
[0038] It can be understood that the event text is the subject of the event in the to-be-extracted text. For example, the event label is a stock decline, and the event text is Tencent; or the event label is brake failure, and the event text is Tesla; or the event label is a stock rise, and the event text is Ping An of China, and the like.
[0039] Specifically, after obtaining all the target text vectors, event subject identification is performed on all the target text vectors through a decoding end in the event extraction model, that is, the event subject is extracted according to the event label and the CLS flag and the SEP flag in the target text vector. That is, all the target text vectors are converted by the decoding end linear transformation layer in the event extraction model to obtain a conversion vector corresponding to each target text vector. All the conversion vectors are identified and extracted by the decoding end prediction layer in the event extraction model, so as to obtain an event text corresponding to each to-be-extracted text.
[0040] In an event extraction method in an embodiment of the present application, the to-be-extracted text is encoded by a preset event encoding model, so as to realize the acquisition of the to-be-extracted vector, and further improve the accuracy of subsequent event identification. The event of the to-be-extracted vector is identified by a label classification model, that is, the event of the to-be-extracted vector is identified by a BIO label, so as to realize the acquisition of the event label, and further improve the accuracy of event identification. The event label is encoded into the to-be-extracted text by the event extraction model, so as to realize the acquisition of the target text vector. The event subject in the target text vector is identified by the event extraction model, that is, the event subject in the target text vector is identified according to the event label, so as to realize the acquisition of the event text, and further realize the extraction of the event without triggering words, further reduce the dependence on the triggering words, reduce the demand for triggering word labeling, improve the accuracy of event extraction, and improve the efficiency of event extraction.
[0041] In an embodiment, in step S10, that is, acquiring at least one to-be-extracted text, includes:
[0042] S101: acquiring at least one initial text, and performing word segmentation processing on all the initial texts to obtain at least one to-be-processed word corresponding to each of the initial texts.
[0043] It can be understood that the to-be-processed word is the result of cutting the to-be-extracted text. The word segmentation result is the to-be-processed word obtained after cutting. The directed acyclic graph is a graph without loops and with directions.
[0044] Specifically, after obtaining the initial text, the initial text is processed by a Chinese word segmentation algorithm, and the initial text is fully segmented and path-selected according to the relationship between the context features to obtain at least one word to be processed corresponding to the initial text. The full segmentation path selection cutting process is to list all possible cutting results, select the best cutting path, and form a directed acyclic graph by cutting the results. The cutting results can be used as nodes, and the edges between words can be weighted to find the path with the smallest weight, which is the final result. For example, the total word frequency can be used as the weight to find the path with the maximum total word frequency, which can be considered as the best path.
[0045] S102, the part-of-speech tagging and entity recognition of all the words to be processed are performed to obtain an entity recognition result corresponding to each of the words to be processed.
[0046] Understandably, the entity recognition model can be obtained by supervised training of a model based on a neural network using labeled text. Part-of-speech tagging is to set a word class label for a word, and entity recognition is a process of extracting entity information from the text to be extracted. The entity recognition result is the entity information extracted from the text to be extracted.
[0047] Specifically, the part-of-speech tagging of all the words to be processed is performed, and each word or phrase is labeled with a word class label, such as an adjective, a verb, a noun, etc. This allows the words to be processed to incorporate more useful information in subsequent processing. The initial text after part-of-speech tagging of each word to be processed is input into an entity recognition model, and the initial text is subjected to entity recognition by the entity recognition model. For example, the entity type of each word to be processed is determined based on the part-of-speech of each word to be processed, and the entity type is determined as an entity recognition result. That is, important entity information such as time or location is extracted from the given text to be extracted based on the relationship between the context features, the sentence, and the part-of-speech of the words.
[0048] S103, according to the entity recognition result corresponding to each of the words to be processed in the same initial text, the words to be processed are filtered from all the initial texts to obtain at least one text to be extracted.
[0049] Specifically, after obtaining the entity recognition result corresponding to each of the words to be processed, the noise words such as stop words and mood words in all the entity recognition results are filtered by a pre-set dictionary library, i.e. the noise words in the initial text are filtered and deleted, and all the entity recognition results after filtering are arranged into the text to be extracted. Among them, the stop word deletion is determined according to the specific scene, for example, in some text to be extracted, the mood words and exclamation marks have certain significance in expressing the degree of mood and emotional color, and should be retained.
[0050] The embodiment of the present application realizes the division of the initial text by performing word segmentation processing on the initial text. The part-of-speech tagging of the word to be processed is realized by the part-of-speech coding table, so as to realize the acquisition of the entity recognition result. The extraction of the entity information in the initial text is realized by the entity recognition result, the deletion of the words without effect in the initial text is realized by the filtering processing, so as to realize the acquisition of the text to be extracted, and further improve the accuracy of the subsequent event extraction.
[0051] In an embodiment, in step S10, the preset event coding model encodes all the texts to be extracted to obtain the extraction vectors corresponding to each of the texts to be extracted, including:
[0052] S106, pre-processing the text to be extracted by the input layer of the preset event coding model to obtain an embedding vector.
[0053] Understandably, the embedding vector is obtained by encoding the text to be extracted.
[0054] Specifically, a preset event coding model is obtained, all the texts to be extracted are input into the preset event coding model, the text to be extracted is pre-processed by the input layer of the preset event coding model, that is, all the texts to be extracted are encoded by the preset event coding model. First, all the texts to be extracted are segmented by the coding layer, then a CLS flag is added before all the words as an identifier representing the overall semantics of the text to be extracted, and a SEP flag is added after all the words as a separation identifier, forming an input vector. Each word, CLS flag and SEP flag in the input vector are vectorized to obtain a word vector corresponding to each word, a flag vector corresponding to the CLS flag and a flag vector corresponding to the SEP flag, and a corresponding position vector is added to each word vector by learning. Then, all the word vectors, position vectors and flag vectors corresponding to the same text to be extracted are spliced to obtain an embedding vector corresponding to the text to be extracted.
[0055] S107, attention processing the embedding vector by the attention layer of the preset event coding model to obtain an attention vector.
[0056] S108, predicting the attention vector by the fully connected layer of the preset event coding model to obtain an extraction vector corresponding to the text to be extracted.
[0057] Understandably, the attention vector is obtained by attention processing the embedding vector. The extraction vector is a vectorized representation of the text to be extracted.
[0058] Specifically, after obtaining the embedding vectors, all embedding vectors are processed through multiple sets of attention mechanisms, that is, the Q vectors, K vectors and V vectors of the embedding vectors are calculated through multiple sets of attention mechanisms, that is, the correlation scores between the target word vectors are obtained by using the dot product method, that is, the dot product of each target word vector in Q and each target word vector in K is calculated, and the correlation scores between the target word vectors in the input sequence are normalized. Then, through the softmax function, the score vector between the target word vectors is converted into a probability distribution between 0 and 1, and then according to the probability distribution between the target word vectors, the corresponding Values value is multiplied to obtain the attention result. Finally, the attention results of different groups are spliced to obtain a combined vector. The combined vector is normalized to obtain a normalized combined vector, so as to avoid degradation of the vector after multiple attention processing. Further, the normalized combined vector is nonlinearly transformed through the feedforward neural network in the full connection layer, and the normalized combined vector is activated to obtain an activated combined vector. The activated combined vector is residual processed, and the multiple encoding layer processes are repeated, so as to obtain the extracted vector corresponding to the to-be-extracted text.
[0059] The embodiment of the present application encodes the to-be-extracted text through the preset event encoding model, so as to realize the vectorization of each word in the to-be-extracted text, and further realize the acquisition of the embedding vector. Then, the to-be-extracted vector is processed through the preset event encoding model, so as to realize the acquisition of the to-be-extracted vector, and further improve the accuracy of subsequent event recognition.
[0060] In an embodiment, in step S20, that is, acquiring the label classification model, includes:
[0061] S201, acquiring a sample training data set, the sample training data set including at least one sample training data; one sample training data is associated with one sample label.
[0062] Understandably, the sample training data is a text used for training the model. The sample training data can be collected from different websites through a crawler technology, or collected from different databases, or sent from the client to the server by the user, and then a sample training data set is constructed according to all the acquired sample training data. A sample label is set for each sample training data, and the sample label is used to represent the event in the sample training data.
[0063] S202, acquiring a preset training model, and performing prediction processing on the sample training data through the preset training model to obtain a predicted label.
[0064] It can be understood that the preset training model is a model set in advance for style transfer of the sample training data. The predicted label is obtained by event recognition of the sample training data by the preset training model.
[0065] Specifically, after obtaining the sample training data and the sample label, the sample training data and the sample label are input into the preset training model, and the sample training data is predicted by the preset training model, that is, the events in the sample training data are identified by using BIO labels, that is, the start word of the event in the sample training data is labeled by using the B label, the content of the event except the start word is labeled by using the I label, and the content not belonging to the event is labeled by using the O label. Then, the B label, the I label and the O label corresponding to the same text to be extracted are fused to obtain the predicted label. When a sample training data includes multiple events, all the events are predicted in turn, that is, the prediction results of the events are determined according to each group of B label, I label and O label, and the prediction results are verified to avoid label fusion errors caused by multiple events, so as to obtain the predicted label corresponding to each event.
[0066] S203, determining a prediction loss value of the preset training model according to the sample label corresponding to the same sample training data and the predicted label.
[0067] It can be understood that the prediction loss value is generated in the process of predicting the prediction label of the sample training data, and is used to represent the difference between the sample label and the prediction label.
[0068] Specifically, after obtaining the predicted label, all the sample labels corresponding to the sample training data are arranged in the order of the sample training data in the sample training data set, and then the predicted label associated with the sample training data is compared with the sample label of the sample training data with the same sequence; that is, according to the sample training data sorting, the sample label corresponding to the first sample training data is compared with the predicted label corresponding to the first sample training data, and the loss value between the sample label and the predicted label is determined by using the loss function; then the sample label corresponding to the second sample training data is compared with the predicted label corresponding to the second sample training data, until all the sample labels and the predicted labels are compared, that is, the prediction loss value of the preset training model can be determined.
[0069] S204, when the prediction loss value does not reach a preset convergence condition, iteratively updating the initial parameters in the preset training model until the prediction loss value reaches the convergence condition, and recording the preset training model after convergence as a label classification model.
[0070] Understandably, the convergence condition can be a condition that the prediction loss value is less than a set threshold, that is, when the prediction loss value is less than the set threshold, the training is stopped; the convergence condition can also be a condition that the prediction loss value is very small and cannot be further reduced after 500 calculations, that is, when the prediction loss value is very small and cannot be reduced after 500 calculations, the training is stopped, and the preset training model after convergence is recorded as a label classification model.
[0071] Specifically, after determining the prediction loss value of the sample training data, when the prediction loss value does not reach the preset convergence condition, the initial parameters of the preset training model are adjusted according to the prediction loss value, and all sample training data are re-input into the preset training model after adjusting the initial parameters, so that other sample training data in the sample training data set are selected when the prediction loss value of the sample training data reaches the preset convergence condition, and the steps S201 to S203 are executed, and the prediction loss value corresponding to the preset training model after adjusting the initial parameters is obtained, and when the prediction loss value does not reach the preset convergence condition, the initial parameters of the preset training model are adjusted again according to the prediction loss value, so that the prediction loss value of the preset training model after adjusting the initial parameters again reaches the preset convergence condition.
[0072] In this way, after the preset training model is trained by all sample training data, the result output by the preset training model can be continuously close to the accurate result, so that the prediction accuracy is higher and higher, and when the prediction loss value of all sample training data reaches the preset convergence condition, the preset training model after convergence is recorded as a label classification model.
[0073] The embodiment of the application trains the preset training model by a large amount of sample training data, and determines the prediction loss value between the predicted label and the sample label by a preset loss function. The initial parameters of the preset training model are adjusted according to the prediction loss value until the model converges, so as to realize the acquisition of the label classification model, and further ensure that the label classification model has a high prediction accuracy.
[0074] In an embodiment, in step S20, that is, event recognition is performed on all the to-be-extracted vectors by the label classification model to obtain event labels corresponding to each of the to-be-extracted texts, and the step S20 further includes:
[0075] S205, input the to-be-extracted vector into the label classification model, and perform label prediction on the to-be-extracted vector by the label classification model to obtain at least one event recognition text.
[0076] S206, fuse all the event recognition texts corresponding to the same to-be-extracted vector to obtain the event label corresponding to the to-be-extracted text.
[0077] It can be understood that the event recognition text is content or words corresponding to each label.
[0078] Specifically, after obtaining the to-be-extracted vector corresponding to the to-be-extracted text, a label classification model is called, all to-be-extracted vectors are input into the label classification model, and the embedding vectors in the to-be-extracted vectors are respectively predicted by the label classification model, that is, the label classification model predicts the label from the first embedding vector in the to-be-extracted vector, when an event is predicted, the vector corresponding to the first word of the event is labeled by using the B label, and the identifier CLS is added before the first word of the event, and the to-be-extracted vector is re-divided. Then, the non-event content after the event is predicted, when the vector corresponding to the first word of the event is predicted, the O label is used for labeling, and then the vectors other than the first one of the event are labeled by using the I label, to obtain the event recognition text corresponding to each label, so that at least one event recognition text corresponding to the to-be-extracted text can be obtained. Further, after predicting a to-be-extracted vector, the event is extracted according to the event recognition text corresponding to the identifiers CLS, B label, I label and O label in the to-be-extracted vector, that is, the event recognition text corresponding to the identifiers CLS, B label, I label and O label is fused, so as to obtain the event label corresponding to each to-be-extracted text.
[0079] In an embodiment, when there are multiple events in a to-be-extracted text, the identifiers CLS, B label, I label and O label in the to-be-extracted vector are determined as a combined label, and the content corresponding to all combined labels in the to-be-extracted text is extracted, so that all event labels in the to-be-extracted text can be obtained. For example, the first event corresponding BIO label in the to-be-extracted vector is found, the label corresponding to the start word of the first event is determined as the B label, then the words with continuous I label after the start word of the first event in the to-be-extracted vector are taken out until the O label appears, the words corresponding to the B label are taken out and spliced after the start word of the first to-be-extracted vector, as the first event label extracted. Then the second event corresponding BIO label in the to-be-extracted vector is found, the label corresponding to the start word of the second event is determined as the B label, then the words with continuous I label after the start word of the second event in the to-be-extracted vector are taken out until the O label appears, the words corresponding to the B label are taken out and spliced after the start word of the second event, as the second event label extracted.
[0080] The embodiment of the present application realizes the acquisition of event recognition text by predicting the label of the to-be-extracted vector through the label classification model. The embodiment of the present application realizes the acquisition of event label by fusing all event recognition texts corresponding to the same to-be-extracted vector, thereby improving the accuracy and efficiency of subsequent event extraction, and further realizing the extraction of event subject without trigger words.
[0081] In an embodiment, as shown in Figure 3 In step S30, that is, through the encoding end in the event extraction model, all the event labels are respectively encoded into the to-be-extracted text corresponding to each event label, and the target text vector corresponding to each event label is obtained, including:
[0082] S301, the event label and the to-be-extracted text are respectively encoded by the input layer, and the label vector corresponding to the event label and the text vector corresponding to the to-be-extracted text are obtained.
[0083] Understandably, the label vector is used to represent the event label, which is obtained by encoding the event label through the encoding end input layer of the event extraction model. The text vector is used to represent the to-be-extracted text, which is obtained by encoding the to-be-extracted text through the encoding end input layer of the event extraction model.
[0084] Specifically, after obtaining the event label, the event extraction model is acquired, and the event label and the to-be-extracted text are input into the event extraction model. First, the encoding end input layer of the event extraction model is used to perform word segmentation processing on all to-be-extracted texts and event labels respectively, and then a CLS flag is added before all the words as an identifier representing the overall semantics of the to-be-extracted text and the event label. And a SEP flag is added after all the words as a separation identifier, forming an input vector. Each word, CLS flag and SEP flag in the input vector are vectorized to obtain a word vector corresponding to each word, a flag vector corresponding to the CLS flag and a flag vector corresponding to the SEP flag, and a corresponding position vector is added to each word vector through the event extraction model, thereby obtaining a label vector corresponding to the event label and a text vector corresponding to the to-be-extracted text.
[0085] S302, the attention layer is used to perform attention processing on the label vector and the text vector, and a fusion vector is obtained.
[0086] S303, the output layer is used to perform prediction processing on the fusion vector, and the target text vector is obtained.
[0087] Specifically, after obtaining the label vectors corresponding to the event labels and the text vectors corresponding to the text to be extracted, the attention layer at the encoding end of the event extraction model performs attention processing on the label vectors and text vectors. This involves using multiple attention mechanisms to process all label vectors and text vectors, specifically calculating the Q, K, and V vectors of the label and text vectors respectively, to obtain the label attention result corresponding to the label vector and the text attention result corresponding to the text vector. The label attention results from different groups or the text attention results from different groups are then concatenated to obtain the label combination vector and the text combination vector. The label combination vector and the text combination vector are then normalized to obtain the normalized label combination vector and the normalized text combination vector, preventing vector degradation after multiple attention processing layers. Based on the CLS and SEP flags, the activated label combination vector and the standard text combination vector corresponding to the same text to be extracted are concatenated to obtain the fused vector. Furthermore, the fused vector is nonlinearly transformed by the feedback neural network in the fully connected layer, and then activated to obtain the activated fused vector. After residual processing and repeating the encoding layer process multiple times, the target text vector can be obtained.
[0088] This invention employs an event extraction model to encode event labels and the text to be extracted, thereby acquiring label vectors and text vectors. Attention processing is applied to the label vectors and text vectors using the event extraction model, thus enabling the acquisition of the target text vector and improving the accuracy of subsequent event extraction.
[0089] In one embodiment, such as Figure 4 As shown, in step S40, that is, by using the decoding end in the event extraction model to perform event subject identification on all the target text vectors to obtain the event text corresponding to each target text vector, including:
[0090] S401, the linear transformation layer is used to transform all the target text vectors to obtain the transformation vector corresponding to each target text vector.
[0091] S402, the prediction layer identifies and extracts all the transformation vectors to obtain the event text corresponding to each of the texts to be extracted.
[0092] Understandably, the transformation vector is a multi-dimensional vector obtained by transforming the target text vector through a linear transformation layer. The event text is the event body corresponding to the event label in the target text vector.
[0093] Specifically, after obtaining all target text vectors, the linear transformation layer at the decoding end of the event extraction model transforms all target text vectors, converting them into multi-dimensional vectors, and further into 3-dimensional vectors due to the use of BIO tags. Then, the prediction layer at the decoding end of the event extraction model identifies and extracts all transformed vectors, yielding the event text corresponding to each text to be extracted. The cross-entropy loss function is used. The decoding process is similar to the encoding process. Compared to each individual decoding and encoding layer, an encoding-decoding attention layer is added between the attention layer and the fully connected layer to calculate the relationship between the current similar template vector and the address template vector. The first layer in the decoding layer is a prediction attention layer. Masking is used because future time information cannot be obtained at the current time when predicting a sentence. The second layer is the same as the encoding layer, but the sources of the Q, K, and V vectors are different. The Q vector comes from the output of the previous decoding layer, while the K and V vectors come from the output of the last encoding layer. The subsequent layers are the same as the encoding layer and will not be described further. Finally, the event text is obtained by passing a linear layer and a prediction layer (softmax layer) to complete the final output.
[0094] This invention transforms all target text vectors into multi-dimensional vectors by converting them at the decoding end of the event extraction model. The event subject is then predicted using a softmax layer on the multi-dimensional vectors, thereby acquiring the event text. This enables event extraction without trigger words, improving accuracy, reducing reliance on trigger words, lowering the need for trigger word annotation, and ultimately increasing efficiency.
[0095] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0096] In one embodiment, an event extraction device is provided, which corresponds one-to-one with the event extraction methods described in the above embodiments. For example... Figure 5 As shown, the event extraction device includes a text encoding module 11, an event recognition module 12, an event fusion module 13, and an event extraction module 14. Detailed descriptions of each functional module are as follows:
[0097] The text encoding module 11 is used to acquire at least one text to be extracted, and to encode all the texts to be extracted using a preset event encoding model to obtain the extraction vector corresponding to each text to be extracted.
[0098] The event recognition module 12 is configured to obtain a label classification model, perform event recognition on all the to-be-extracted vectors through the label classification model, and obtain event labels corresponding to the to-be-extracted texts.
[0099] The event fusion module 13 is configured to obtain an event extraction model, encode all the event labels into the to-be-extracted texts corresponding to the event labels through an encoding end in the event extraction model, and obtain target text vectors corresponding to the event labels.
[0100] The event extraction module 14 is configured to perform event subject recognition on all the target text vectors through a decoding end in the event extraction model, and obtain event texts corresponding to the target text vectors.
[0101] In an embodiment, the text encoding module 11 comprises:
[0102] The word segmentation unit is configured to obtain at least one initial text, perform word segmentation on all the initial texts respectively, and obtain at least one to-be-processed word corresponding to each initial text.
[0103] The labeling unit is configured to perform part-of-speech tagging and entity recognition on all the to-be-processed words, and obtain an entity recognition result corresponding to each to-be-processed word.
[0104] The filtering unit is configured to filter the words in the initial texts according to the entity recognition results corresponding to the to-be-processed words in the same initial text, and obtain at least one to-be-extracted text.
[0105] In an embodiment, the text encoding module 11 further comprises:
[0106] The encoding module is configured to pre-process the to-be-extracted texts through an input layer of the preset event encoding model, and obtain embedding vectors.
[0107] The attention module is configured to perform attention processing on the embedding vectors through an attention layer of the preset event encoding model, and obtain attention vectors.
[0108] The prediction module is configured to perform prediction processing on the attention vectors through a fully connected layer of the preset event encoding model, and obtain to-be-extracted vectors corresponding to the to-be-extracted texts.
[0109] In an embodiment, the event recognition module 12 comprises:
[0110] The sample obtaining module is configured to obtain a sample training data set, wherein the sample training data set comprises at least one sample training data; and one sample training data is associated with one sample label.
[0111] The label prediction module is used to obtain a preset training model, and to perform prediction processing on the sample training data through the preset training model to obtain the predicted label.
[0112] The prediction loss module is used to determine the prediction loss value of the preset training model based on the sample label and the prediction label corresponding to the same sample training data.
[0113] The model convergence module is used to iteratively update the initial parameters in the preset training model when the predicted loss value does not reach the preset convergence condition, until the predicted loss value reaches the convergence condition, and then record the converged preset training model as a label classification model.
[0114] In one embodiment, the event recognition module 12 further includes:
[0115] An event recognition module is used to input the vector to be extracted into the label classification model, and perform label prediction on the vector to be extracted through the label classification model to obtain at least one event recognition text.
[0116] The text fusion module is used to fuse all the event recognition texts corresponding to the same extraction vector to obtain the event label corresponding to the extraction text.
[0117] In one embodiment, the event fusion module 13 includes:
[0118] The vector encoding module is used to encode the event label and the text to be extracted through the input layer to obtain the label vector corresponding to the event label and the text vector corresponding to the text to be extracted.
[0119] The vector fusion module is used to perform attention processing on the label vector and the text vector through the attention layer to obtain a fused vector;
[0120] The vector prediction module is used to perform prediction processing on the fused vector through the output layer to obtain the target text vector.
[0121] In one embodiment, the event extraction module 14 includes:
[0122] The text conversion module is used to convert all the target text vectors through the linear transformation layer to obtain a conversion vector corresponding to each target text vector.
[0123] The vector recognition module is used to identify and extract all the transformation vectors through the prediction layer to obtain the event text corresponding to each of the texts to be extracted.
[0124] The specific limitation of the event extraction device can refer to the limitation of the event extraction method in the above, which will not be repeated here. Each module in the event extraction device described above can be realized by software, hardware and their combination in whole or in part. The above-mentioned modules can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory in the computer device in software form, so as to call and execute the operation corresponding to each module by the processor.
[0125] In one embodiment, a computer device is provided, which can be a server, and its internal structure diagram can be as shown in Figure 6 The computer device includes a processor, a memory, a network interface and a database connected by a system bus. Among them, the processor of the computer device is used to provide computing and control ability. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store the data used by the event extraction method in the above embodiment. The network interface of the computer device is used to communicate with the external terminal through the network connection. The computer program is executed by the processor to realize an event extraction method.
[0126] In one embodiment, a computer device is provided, which includes a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor executes the computer program to realize the event extraction method described above.
[0127] In one embodiment, a computer readable storage medium is provided, which stores a computer program, characterized in that the computer program is executed by the processor to realize the event extraction method described above.
[0128] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when executed, can include the processes of the above-mentioned embodiment methods. Any reference to memory, storage, database or other medium used in the embodiments provided by the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0129] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is exemplified, and in actual application, the above-mentioned functions can be completed by different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above.
[0130] The above-mentioned embodiments are only used to illustrate the technical solutions of the present application, but not limit it. Although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for part of the technical features. Such modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.
Claims
1. An event extraction method, characterized in that, include: At least one text to be extracted is obtained, and all the texts to be extracted are encoded using a preset event encoding model to obtain the extraction vector corresponding to each text to be extracted. Obtain a label classification model, and use the label classification model to perform event recognition on all the vectors to be extracted, so as to obtain event labels corresponding to each of the texts to be extracted; Obtain the event extraction model, and encode all the event tags into the text to be extracted corresponding to each event tag through the encoding end in the event extraction model, to obtain the target text vector corresponding to each event tag; The event subject is identified by the decoding end of the event extraction model for all the target text vectors to obtain the event text corresponding to each target text vector. The decoding end includes a linear transform layer and a prediction layer; The step of identifying the event subject of all the target text vectors through the decoding end of the event extraction model to obtain the event text corresponding to each target text vector includes: The linear transformation layer is used to transform all the target text vectors to obtain a transformed vector corresponding to each target text vector. The prediction layer identifies and extracts all the transformation vectors to obtain the event text corresponding to each of the texts to be extracted. The acquisition of the label classification model includes: Obtain a sample training dataset, wherein the sample training dataset includes at least one sample training data; One sample training data point is associated with one sample label; Obtain a preset training model, and use the preset training model to perform prediction processing on the sample training data to obtain the predicted label; The prediction loss value of the preset training model is determined based on the sample label and the prediction label corresponding to the same sample training data. When the predicted loss value does not reach the preset convergence condition, the initial parameters in the preset training model are iteratively updated until the predicted loss value reaches the convergence condition. Then, the preset training model after convergence is recorded as a label classification model.
2. The event extraction method as described in claim 1, characterized in that, The step of obtaining at least one text to be extracted includes: Obtain at least one initial text, and perform word segmentation on all the initial texts respectively to obtain at least one word to be processed corresponding to each initial text; Part-of-speech tagging and entity recognition are performed on all the words to be processed to obtain entity recognition results corresponding to each word to be processed. Based on the entity recognition results corresponding to each of the words to be processed in the same initial text, word filtering is performed on all the initial texts to obtain at least one of the texts to be extracted.
3. The event extraction method as described in claim 1, characterized in that, The step of encoding all the texts to be extracted using a preset event encoding model to obtain an extraction vector corresponding to each text includes: The text to be extracted is preprocessed through the input layer of the preset event encoding model to obtain an embedding vector; The embedding vector is processed by the attention layer of the preset event encoding model to obtain an attention vector; The attention vector is predicted by the fully connected layer of the preset event encoding model to obtain the extraction vector corresponding to the text to be extracted.
4. The event extraction method as described in claim 1, characterized in that, The step of performing event identification on all the vectors to be extracted using the label classification model to obtain event labels corresponding to each of the texts to be extracted includes: The vector to be extracted is input into the label classification model, and the label classification model is used to predict the label of the vector to be extracted to obtain at least one event recognition text. All event recognition texts corresponding to the same extraction vector are fused to obtain the event tag corresponding to the extraction text.
5. The event extraction method as described in claim 1, characterized in that, The event extraction model includes an encoding end and a decoding end; the encoding end includes an input layer, an attention layer, and an output layer; The step of encoding all event tags into the text to be extracted corresponding to each event tag through the encoding end in the event extraction model to obtain the target text vector corresponding to each event tag includes: The input layer encodes the event tag and the text to be extracted to obtain a tag vector corresponding to the event tag and a text vector corresponding to the text to be extracted. The attention layer performs attention processing on the label vector and the text vector to obtain a fused vector; The target text vector is obtained by performing prediction processing on the fused vector through the output layer.
6. An event extraction apparatus for implementing the method according to any one of claims 1-5, characterized in that, include: The text encoding module is used to acquire at least one text to be extracted, and to encode all the texts to be extracted using a preset event encoding model to obtain the extraction vector corresponding to each text to be extracted. An event recognition module is used to obtain a label classification model, and to perform event recognition on all the vectors to be extracted using the label classification model to obtain event labels corresponding to each of the texts to be extracted. The event fusion module is used to obtain an event extraction model, and to encode all the event tags into the text to be extracted corresponding to each event tag through the encoding end in the event extraction model, so as to obtain the target text vector corresponding to each event tag; The event extraction module is used to perform event subject identification on all the target text vectors through the decoding end in the event extraction model, so as to obtain the event text corresponding to each target text vector.
7. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the event extraction method as described in any one of claims 1 to 5.
8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the event extraction method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Structured event extraction method and device based on generative network, , and processor
CN111339311A
Function word extraction method, model training method, electronic equipment and medium
CN114611503A