Event extraction method and device based on context enhancement

By providing an enhancement of event extraction related components and using text retrieval models to add event extraction in large language models, the problem of insufficient information accuracy and integrity in event extraction in event extraction is solved, and more efficient event information extraction has been achieved.

CN119357371AActive Publication Date: 2025-01-24BEIJING DP TECH CO LTD

Patent Information

Application Number
CN202411469725.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-21
Publication Date
2025-01-24
Estimated Expiration
2044-10-21

AI Technical Summary

Technical Problem

The large language model has problems such as insufficient information accuracy and insufficient information integrity in event extraction tasks, mainly because its attention mechanism is too complex when dealing with long text sequences, resulting in lost context content.

Method used

Based on the feature extraction component of the large language model, trigger word prediction, event type prediction, event element annotation and event information fusion components are added to build an event extraction model, and use the text retrieval model to provide a context enhancement mechanism.

Benefits of technology

It improves the accuracy and completeness of event information extraction and enhances the model's ability to utilize global document context information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119357371A_ABST
    Figure CN119357371A_ABST
Patent Text Reader

Abstract

The embodiment of the invention relates to an event extraction method and device based on context enhancement. The method comprises the steps that a large language model is selected, and a text retrieval model and an event extraction model are customized; creating a training data set for the two customized models based on the large language model, and training the two customized models based on the data set; receiving a text input by the user after training is finished, and performing text sentence segmentation on the current user text; inputting each clause text and the corresponding other text sequence into a text retrieval model for text retrieval, and splicing each clause text and the corresponding retrieval text to obtain a context enhanced text; inputting the de-duplicated context enhanced texts into an event extraction model for event information extraction; and forming an event extraction record by each event information text, the clause text and the context enhancement text, and feeding back all the obtained event extraction records to a user. According to the invention, the accuracy and integrity of the event can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a method and device for event extraction based on context enhancement. Background Art

[0002] Large Language Models (LLMs) perform well in a variety of natural language processing (NLP) tasks such as text generation, text translation, and intelligent question answering. However, we have found in practical applications that if large language models are used directly to process event extraction (EE) tasks, problems such as insufficient accuracy and completeness of extracted information often occur. Analysis shows that the main reason is that the attention mechanism of the large language model has too high processing complexity when processing long text sequences, which easily leads to loss of contextual content, which makes it impossible for the model to effectively use the contextual information of the global document to extract event information, resulting in problems such as insufficient accuracy and completeness of extracted information. If you want to retain the natural language understanding ability of the large language model and improve the event extraction performance of the model, you need to customize the event extraction model on the basis of retaining the encoding component of the large language model, and provide a processing mechanism that can enhance contextual information for this customized model, which is the technical problem that the present invention needs to solve. Summary of the invention

[0003] The purpose of the present invention is to provide a method, device, electronic device and computer-readable storage medium for event extraction based on context enhancement in view of the defects of the prior art. The present invention selects a class of large language models as the corresponding first large language model, and constructs a text retrieval model for text retrieval, and adds trigger word prediction, event type prediction, event element annotation and event information fusion components related to event extraction on the basis of the feature extraction component of the first large language model to form an event extraction model for event information extraction; and uses the powerful text generation task processing capability of the first large language model to automatically create a large amount of model training data sets for the text retrieval model and the event extraction model, and trains the text retrieval model and the event extraction model separately based on the two obtained data sets; and after the model training is completed, the text retrieval model is used to perform text retrieval on the maximum associated sentences in the full text of each sentence in the user input text, and the text splicing of each sentence and its corresponding retrieval text forms a corresponding context enhanced text; and each context enhanced text after deduplication is input into the event extraction model for event information extraction processing to obtain the corresponding event information text, and all the obtained event information texts are fed back to the user. The customized event extraction model of the present invention retains the encoding components of the first language model and adds exclusive components related to the event extraction task. The customized text retrieval model of the present invention can provide a context enhancement mechanism for the event extraction model. Through the two customized models of the present invention, the extraction accuracy and extraction completeness of event information can be improved when processing the event extraction task of large text; in addition, the present invention also uses the powerful text generation task processing capability of the first language model to create corresponding training data sets for the two customized models. This processing method can not only improve the model training speed, but also improve the generalization of the model.

[0004] To achieve the above object, a first aspect of an embodiment of the present invention provides an event extraction method based on context enhancement, the method comprising:

[0005] Select a class of large language models as the corresponding first large language model; and construct a text retrieval model for text retrieval; and add trigger word prediction, event type prediction, event element annotation and event information fusion components related to event extraction on the basis of the feature extraction component of the first large language model to form an event extraction model for event information extraction;

[0006] Based on the text generation task processing capability of the first language model, corresponding model training data sets are created for the text retrieval model and the event extraction model, which are recorded as corresponding first data sets and second data sets; and the text retrieval model is trained based on the first data set; and the event extraction model is trained based on the second data set;

[0007] After the model training is completed, the input text received from the user is recorded as the corresponding user text of the current time;

[0008] Performing text sentence processing on the current user text to obtain a corresponding sentence text sequence; the sentence text sequence is formed by sequentially sorting a plurality of sentence texts;

[0009] Each of the sentence texts is used as the corresponding current text; and all the sentence texts other than the current text in the sentence text sequence form a corresponding other text sequence; and the current text and the corresponding other text sequence are input into the text retrieval model to perform text retrieval to obtain the corresponding current retrieval text; and the current text and the corresponding current retrieval text are text spliced ​​to obtain a corresponding context-enhanced text;

[0010] Deduplication processing is performed on all the obtained context-enhanced texts; and each of the deduplicated context-enhanced texts is input into the event extraction model to perform event information extraction processing to obtain corresponding event information texts;

[0011] Each event information text, the corresponding sentence text and the context enhanced text form a corresponding event extraction record; and all the obtained event extraction records form a corresponding extraction record sequence to be fed back to the user.

[0012] Preferably, the first large language model is implemented based on the Transformer model architecture; the large language model implemented based on the Transformer model architecture includes at least a GPT series model and a BERT series model; the first large language model has completed model pre-training based on the full-domain text corpus and has completed model fine-tuning based on the text corpus of the first specific knowledge field, and can correctly understand and generate natural language text and can correctly handle a variety of natural language processing tasks; the multiple natural language processing tasks include at least text generation tasks; the full domain includes at least the biomedical knowledge field, the battery material knowledge field, the financial knowledge field, the legal knowledge field, the architectural knowledge field and the autonomous driving knowledge field; the first specific knowledge field is any knowledge field in the full domain;

[0013] The first language model is used to perform corresponding natural language text generation processing based on the natural language understanding of the first input text input to the model and output the corresponding first generated text when processing the text generation task;

[0014] The text retrieval model is used to perform associated text retrieval processing on a second text sequence input by the model according to a first text input by the model and output a corresponding first retrieval text; the second text sequence is formed by sorting a plurality of second texts; the first and second texts are each a sentence text; the first text is different from all the second texts in the second text sequence; when the first retrieval text is not empty, it matches one of the second texts in the second text sequence;

[0015] The event extraction model is used to perform event information extraction processing on a third text input into the model and output a corresponding first event information text; the third text is a sentence text; the first event information text, when not empty, is composed of a first event trigger word, a first event type and a first event element set; the first event element set includes a plurality of first event elements; the first event element includes a first element type and a first element object;

[0016] The first data set includes a plurality of first data records; the first data record includes a first training text, a first comparison text sequence and a first label index; the first comparison text sequence includes a plurality of first comparison texts; when the first label index is empty, it means that all the first comparison texts in the first comparison text sequence are irrelevant to the first training text; when the first label index is not empty, it means that the first comparison text in the first comparison text sequence whose sequence index matches the first label index has the greatest correlation with the first training text;

[0017] The second data set includes multiple second data records; the second data records include a second training text and a first label event information text; the first label event information text consists of a first label event trigger word, a first label event type and a first label event element set; the first label event element set includes multiple first label event elements; the first label event element includes a first label element type and a first label element object.

[0018] Preferably, the large language model input end of the first large language model is used to receive the corresponding first input text, and the large language model output end is used to output the corresponding first generated text;

[0019] The internal model component of the first large language model at least includes a first word embedding encoding module, a first feature extraction module and a first text generation module; the input end of the first word embedding encoding module is connected to the input end of the large language model, and the output end is connected to the input end of the first feature extraction module; the output end of the first feature extraction module is connected to the input end of the first text generation module; the output end of the first text generation module is connected to the output end of the large language model;

[0020] The first word embedding encoding module is used to perform word segmentation processing on the first input text to obtain a corresponding first word segmentation text sequence; and based on a preset word embedding encoding model, each first word segmentation text of the first word segmentation text sequence is subjected to word embedding encoding processing to obtain a corresponding first word segmentation encoding vector and send it to the first feature extraction module; the first word segmentation text sequence is formed by sequentially sorting a plurality of the first word segmentation texts; the word embedding encoding model at least includes an N-gram encoding model and a Word2Vec encoding model; the first word segmentation encoding vector is formed by sequentially sorting a plurality of first word segmentation encodings, and the first word segmentation encoding corresponds to the first word segmentation text in one-to-one correspondence;

[0021] The first feature extraction module is implemented based on the Encoder or Decoder module of the Transformer model; the first feature extraction module is used to perform deep learning encoding on the associated features of each word segmentation code and other word segmentation codes in the first word segmentation code vector to obtain a corresponding first text feature vector and send it to the first text generation module; the first text feature vector is composed of multiple first text features, and the first text features correspond to the first word segmentation text one by one;

[0022] The first text generation module is implemented based on a type of text generator model; it is used to perform feature decoding and text generation processing according to the first text feature vector to obtain the corresponding first generated text and output it.

[0023] Preferably, the first retrieval model input end of the text retrieval model is used to receive the corresponding first text, the second retrieval model input end is used to receive the corresponding second text sequence, and the retrieval model output end is used to output the corresponding first retrieval text;

[0024] The internal model components of the text retrieval model at least include a first MLP module, a second MLP stacking module, a similarity comparison module and a text screening module; the input end of the first MLP module is connected to the input end of the first retrieval model, and the output end is connected to the first input end of the similarity comparison module; the input end of the second MLP stacking module is connected to the input end of the second retrieval model, and the output end is connected to the second input end of the similarity comparison module; the output end of the similarity comparison module is connected to the first input end of the text screening module; the second input end of the text screening module is connected to the input end of the second retrieval model, and the output end is connected to the output end of the retrieval model;

[0025] The first MLP module is implemented based on the MLP model structure; the first MLP module is used to extract text features from the first text to obtain a corresponding first text feature vector and send it to the similarity comparison module;

[0026] The second MLP stacking module is composed of a plurality of parallel second MLP modules, and the second MLP modules correspond one to one with the second texts; each second MLP module is implemented based on the MLP model structure; the second MLP stacking module is used to count the total number of texts in the second text sequence to obtain the corresponding total number of texts N; and dynamically stack N parallel second MLP modules, and create a one-to-one correspondence between the second MLP module and the second text of the second text sequence; and each second MLP module extracts text features from the corresponding second text to obtain a corresponding second text feature vector; and all the obtained second text feature vectors are sorted according to the text sorting order of the second text sequence to form a corresponding second text feature vector sequence and sent to the similarity comparison module;

[0027] The similarity comparison module is used to calculate the vector similarity between the first text feature vector and each of the second text feature vectors in the second text feature vector sequence according to the cosine vector similarity algorithm to obtain the corresponding first similarity; and use the first similarity with the highest similarity as the corresponding maximum similarity; and identify whether the maximum similarity exceeds a preset similarity threshold; if the maximum similarity exceeds the similarity threshold, extract the sorting index of the second text feature vector corresponding to the maximum similarity in the second text feature vector sequence as the corresponding first sorting index; if the maximum similarity does not exceed the similarity threshold, set the corresponding first sorting index to empty; and send the obtained first sorting index to the text screening module;

[0028] The text screening module is used to identify whether the first sorting index is empty; if the first sorting index is not empty, the second text corresponding to the first sorting index in the second text sequence is extracted as the corresponding first search text; if the first sorting index is empty, the corresponding first search text is set to empty; and the obtained first search text is output.

[0029] Preferably, the extraction model input end of the event extraction model is used to receive the corresponding third text, and the extraction model output end is used to output the corresponding first event information text;

[0030] The internal model components of the event extraction model at least include the first word embedding encoding module, the first feature extraction module, the first trigger word prediction module, the first event type prediction module, the first event element labeling module and the first event information fusion module;

[0031] The input end of the first word embedding encoding module is connected to the input end of the extraction model, and the first and second output ends are respectively connected to the input end of the first feature extraction module and the third input end of the first event information fusion module; the first, second and third output ends of the first feature extraction module are respectively connected to the input end of the first trigger word prediction module, the second input end of the first event type prediction module and the input end of the first event element labeling module; the output end of the first trigger word prediction module is connected to the first input end of the first event type prediction module; the output end of the first event type prediction module is connected to the first input end of the first event information fusion module; the output end of the first event element labeling module is connected to the second input end of the first event information fusion module; the output end of the first event information fusion module is connected to the output end of the extraction model;

[0032] The first word embedding encoding module is used to perform word segmentation processing on the third text to obtain a corresponding second word segmentation text sequence and send it to the first event information fusion module; and based on the word embedding encoding model, each second word segmentation text of the second word segmentation text sequence is subjected to word embedding encoding processing to obtain a corresponding second word segmentation encoding vector and send it to the first feature extraction module; the second word segmentation text sequence is formed by sequentially sorting a plurality of second word segmentation texts; the second word segmentation encoding vector is formed by sequentially sorting a plurality of second word segmentation encodings, and the second word segmentation encoding corresponds to the second word segmentation text in one-to-one correspondence;

[0033] The first feature extraction module is used to perform deep learning encoding on the associated features of each word segmentation code and other word segmentation codes in the second word segmentation code vector to obtain a corresponding second text feature vector and send it to the first trigger word prediction module, the first event type prediction module and the first event element labeling module respectively; the second text feature vector is composed of multiple second text features, and the second text features correspond to the second word segmentation text one by one;

[0034] The first trigger word prediction module is implemented based on a type of neural network classifier; the first trigger word prediction module is used to perform corresponding event trigger word probability prediction processing according to the second text feature vector to obtain a corresponding first trigger word prediction vector and send it to the first event type prediction module; the neural network classifier at least includes a classifier model implemented based on an MLP model, a classifier model implemented based on a CNN model, and a classifier model implemented based on an RNN model; the first trigger word prediction vector is composed of multiple first trigger word prediction probabilities; the first trigger word prediction probability corresponds to the second word segmentation text one by one; the first trigger word prediction probability is the prediction probability that the corresponding second word segmentation text is identified as an event trigger word;

[0035] The first event type prediction module is used to perform feature fusion processing on the first trigger word prediction vector and the second text feature vector to obtain a corresponding first text fusion feature vector; and based on another type of the neural network classifier, perform corresponding event type classification prediction processing on the first word segmentation fusion feature vector to obtain a corresponding first event type prediction vector; and record the first trigger word prediction probability with the largest probability value in the first trigger word prediction vector as the corresponding maximum trigger word prediction probability; and identify whether the maximum trigger word prediction probability exceeds a preset trigger word prediction probability threshold; if the maximum trigger word prediction probability exceeds the trigger word prediction probability threshold, the sorted index in the first trigger word prediction vector is extracted as the corresponding first trigger word index; if the maximum trigger word prediction probability does not exceed the trigger word prediction probability threshold, the corresponding first trigger word index is set to empty; and the first event type prediction probability with the largest probability in the first event type prediction vector is taken as the corresponding maximum event type prediction probability; and identify whether the maximum event type prediction probability exceeds the preset event type prediction probability threshold; if the maximum event type prediction probability exceeds the event type prediction probability threshold, the event type corresponding to the maximum event type prediction probability is used as the corresponding first event type; if the maximum event type prediction probability does not exceed the event type prediction probability threshold, the corresponding first event type is set to empty; and the obtained first trigger word index and the first event type are sent to the first event information fusion module; the first text fusion feature vector is formed by sequentially sorting a plurality of first text fusion features, the first text fusion feature corresponds to the second word segmentation text one by one, and each of the first text fusion features is formed by splicing the corresponding first trigger word prediction probability and the second text feature in a data vector splicing manner; the first event type prediction vector is composed of a plurality of first event type prediction probabilities; each of the first event type prediction probabilities corresponds to a class of the event type;

[0036] The first event element labeling module is implemented based on a conditional random field model; the first event element labeling module is used to perform corresponding event element labeling processing according to the second text feature vector to obtain a corresponding first labeling label vector and send it to the first event information fusion module; the first labeling label vector is formed by sequentially sorting a plurality of first labeling labels, and the first labeling label corresponds to the second word segmentation text one by one; the first labeling label is the event element label of the corresponding second word segmentation text; the label type of the first labeling label includes multiple categories of B-event element labels, multiple categories of I-event element labels and O labels; each category of the B-event element label or the I-event element label corresponds to a specified event element type; the second word segmentation text corresponding to each of the B-event element labels is the starting word segmentation of the element object text corresponding to a category of the event element type, and the second word segmentation text corresponding to each of the I-event element labels is the middle word segmentation of the element object text corresponding to a category of event element type event element type; the second word segmentation text corresponding to each of the O labels is a word segmentation that cannot correspond to any of the event element types;

[0037] The first event information fusion module is used to identify the first trigger word index and the first event type; if the first trigger word index is empty or the first event type is empty, the corresponding first event information text is set to be empty; if both the first trigger word index and the first event type are not empty, the second segmentation text corresponding to the first trigger word index in the second segmentation text sequence is used as the corresponding first event trigger word, and the first element subset corresponding to the first event type in the preset event element set is used as the corresponding current element subset, and each of the event element types in the current element subset is used as a corresponding first element type, and the first annotation label in the first annotation label vector that does not correspond to all the first element types is reset to the O label , and extract and process the element objects corresponding to each first element type according to the reset first annotation label vector and the second word segmentation text sequence to obtain the corresponding first element object, and form a corresponding first event element by each first element type and the corresponding first element object, and form a corresponding first event element set by all the obtained first event elements, and form the corresponding first event information text by the obtained first event trigger word, the first event type and the first event element set; and output the first event information text obtained this time; wherein, the event element set includes multiple first element subsets, each of which corresponds to a class of the event type; the first element subset consists of one or more of the event element types.

[0038] Furthermore, the extracting and processing the element objects corresponding to each of the first element types according to the reset first annotation label vector and the second word segmentation text sequence to obtain the corresponding first element objects specifically includes:

[0039] Step 61, the first event information fusion module records the first second segmented word text of the second segmented word text sequence as the corresponding current segmented word text;

[0040] Step 62, and record the first annotation label corresponding to the current segmentation text in the first annotation label vector as the corresponding current annotation label; and identify the current annotation label; if the current annotation label is the B-event element label, initialize a corresponding empty sequence for the first element type corresponding to the current annotation label as the corresponding first object segmentation sequence, and add the current segmentation text to the first object segmentation sequence created this time; if the current annotation label is the I-event element label, add the current segmentation text to the first object segmentation sequence corresponding to the first element type corresponding to the current annotation label;

[0041] Wherein, the first object segmentation sequence corresponds one-to-one to the first element type;

[0042] Step 63, identifying whether the current segmented text is the last second segmented text in the second segmented text sequence; if so, going to step 64; if not, taking the next second segmented text in the second segmented text sequence as the new current segmented text and going back to step 62;

[0043] Step 64, sequentially concatenate all the second segmented word texts in each of the first object segmented word sequences to obtain a corresponding first concatenated text; and use the first concatenated text corresponding to each of the first element types as the corresponding first element object.

[0044] Preferably, the text generation task processing capability based on the first large language model creates corresponding model training data sets for the text retrieval model and the event extraction model, recorded as corresponding first data sets and second data sets, specifically including:

[0045] Step 71, initialize the first counter to 0; and increment the counter from 2 to the preset sentence total threshold n. amax The integer value range between is used as the corresponding value range R; and the first positive and negative sample states are initialized as positive sample states;

[0046] Wherein, the value range R is [2,n amax ], the total number of sentences threshold n amaxis an integer greater than 2; the first positive and negative sample states include a positive sample state and a negative sample state;

[0047] Step 72, randomly selecting an integer in the value range R as the corresponding first sentence total number; bringing the first specific knowledge domain, the first sentence total number and the first positive and negative sample states into a preset first record generation instruction template to perform instruction text splicing to obtain a corresponding first instruction text; inputting the first instruction text into the first large language model to perform corresponding record text generation processing to obtain a corresponding first record text; and extracting the corresponding first training text, the first comparison text sequence and the first label index from the first record text to form a corresponding first data record;

[0048] Where 2≤the total number of the first sentence≤the total number of sentences threshold n amax ;

[0049] The first record generation instruction template is a formatted text configuration template; the first record generation instruction template is used to take the first specific knowledge domain, the first total number of sentences and the first positive and negative sample states as the corresponding current knowledge domain, the current total number of comparison texts n c and the current positive and negative sample states; and inform the first language model through a preset narrative text to generate a creative sentence based on the current knowledge field as the corresponding first training text, and to generate the total number of current comparison texts n based on the current knowledge field c The creative sentences of the first comparison text sequence are composed of the first comparison text sequence, and when the current positive and negative sample state is a negative sample state, each of the first comparison texts in the first comparison text sequence is required to be irrelevant to the first training text and the corresponding first label index is set to be empty, and when the current positive and negative sample state is a positive sample state, at least one of the first comparison texts in the first comparison text sequence is required to be relevant to the first training text and the sequence index of the first comparison text with the highest correlation with the first training text in the first comparison text sequence is used as the corresponding first label index, and the first training text, the first comparison text sequence and the first label index are obtained to form the corresponding first record text and output it;

[0050] Step 73, identifying whether the first counter exceeds a preset first counting threshold; if the first counter does not exceed the first counting threshold, randomly selecting one of the positive sample state and the negative sample state to reset the first positive and negative sample state; if the first counter exceeds the first counting threshold, statistically analyzing the positive and negative sample ratios of the first data record that has been generated to obtain the corresponding first positive and negative sample ratios, and identifying whether the first positive and negative sample ratio exceeds a preset first positive and negative sample ratio threshold, if so, resetting the first positive and negative sample state to a negative sample state, if not, resetting the first positive and negative sample state to a positive sample state;

[0051] The first positive-negative sample ratio is a ratio of the total number of the first data records in which the first positive-negative sample state is a positive sample state to the total number of the first data records in which the first positive-negative sample state is a negative sample state;

[0052] Step 74, adding 1 to the first counter; and identifying whether the first counter after adding 1 exceeds a preset first record total threshold; if not, returning to step 72; if so, forming the corresponding first data set from all the first data records obtained and going to step 75;

[0053] Step 75, initializing the second counter to 0; and initializing the first event text attribute to descriptive text;

[0054] Wherein, the first event text attributes include descriptive text, action text and position text;

[0055] Step 76, bringing the first specific knowledge domain and the first event text attribute into a preset second record generation instruction template to perform instruction text splicing to obtain a corresponding second instruction text; and inputting the second instruction text into the first large language model to perform corresponding record text generation processing to obtain a corresponding second record text; and extracting the corresponding second training text and the first label event information text from the second record text to form a corresponding second data record;

[0056] Wherein, the second record generation instruction template is a formatted text configuration template; the second record generation instruction template is used to take the first specific knowledge domain and the first event text attribute as the corresponding current knowledge domain and current text attribute; and inform the first large language model through a preset narrative text to randomly select a type of event type from all event types in the current knowledge domain as the corresponding current event type, and generate a creative event information text based on the current event type as the corresponding first label event information text, and randomly generate a creative sentence matching the current text attribute based on the first label event information text as the corresponding second training text, and the corresponding second record text is composed of the obtained second training text and the first label event information text and output, and the first label event information text is required to be composed of the first label event trigger word, the first label event type and the first label event element set, and the first label event element set is required to be composed of one or more of the first label event elements, and the first label event element is required to be composed of the first label element type and the first label element object;

[0057] Step 77, identifying whether the second counter exceeds a preset second counting threshold; if the second counter does not exceed the second counting threshold, randomly selecting one of the descriptive text, the action text and the positional text to reset the first event text attribute; if the second counter exceeds the second counting threshold, the descriptive text, the action text and the positional text ratios of the first data record that have been generated are counted to obtain the corresponding first, second and third ratios, and the first event text attribute is reset based on the descriptive text, the action text or the positional text corresponding to the minimum ratio among the first, second and third ratios;

[0058] The first ratio is the ratio of the total number of the first data records whose first event text attribute is descriptive text to the total number of all the first data records that have been generated; the second ratio is the ratio of the total number of the first data records whose first event text attribute is action text to the total number of all the first data records that have been generated; the third ratio is the ratio of the total number of the first data records whose first event text attribute is positional text to the total number of all the first data records that have been generated;

[0059] Step 78, adding 1 to the second counter; and identifying whether the second counter after adding 1 exceeds the preset second record total threshold; if not, returning to step 76; if so, all the obtained second data records form the corresponding second data set.

[0060] Preferably, the training of the text retrieval model based on the first data set specifically includes:

[0061] Step 81, dividing the first data set into sub-datasets based on a preset first segmentation ratio to obtain a corresponding first training set and a first evaluation set;

[0062] Wherein, both the first training set and the first evaluation set are composed of a plurality of the first data records; the ratio of the total number of records in the first training set to the total number of records in the first evaluation set satisfies the first segmentation ratio;

[0063] Step 82, taking the first first data record of the first training set as the corresponding current training record;

[0064] Step 83, taking the first training text, the first comparison text sequence and the first label index of the current training record as the corresponding current training text, the current comparison text sequence and the current label index;

[0065] Step 84, inputting the current training text and the current comparison text sequence into the text retrieval model, and having the text retrieval model perform associated text retrieval processing on the current comparison text sequence input into the model according to the current training text input into the model, and using the retrieval text output by the text retrieval model as the corresponding current predicted text;

[0066] Step 85, whether the current predicted text is one of the first compared texts in the current compared text sequence is identified; if so, the sequence index of the current predicted text in the current compared text sequence is extracted as the corresponding current predicted index; if not, the corresponding current predicted index is set to empty; and two all-zero vectors whose lengths are consistent with the total number of compared texts in the current compared text sequence are initialized as the corresponding first predicted vector and first label vector; and when the current predicted index is not empty, the vector data corresponding to the vector sorting index and the current predicted index in the first predicted vector is reset to 1; and when the current label index is not empty, the vector data corresponding to the vector sorting index and the current label index in the first label vector is reset to 1;

[0067] The first prediction vector and the first label vector are both formed by sequentially sorting a plurality of vector data; when the first prediction vector and the first label vector are initialized, all vector data inside each of them is 0;

[0068] Step 86: Substitute the first prediction vector and the first label vector into a preset first model loss function L M1; and based on the preset first model optimizer, move towards making the first model loss function L M1 Performing a round of optimization on the model parameters of the first MLP module and all the second MLP modules of the text retrieval model in the direction of reaching the minimum value;

[0069] Among them, the first model loss function L M1 for:

[0070]

[0071] v pre is the first prediction vector, v tag is the first label vector;

[0072] The first model optimizer includes at least an SGD optimizer and an ADAM optimizer;

[0073] Step 87, identifying whether the current training record is the last first data record of the first training set; if so, going to step 88; if not, extracting the next first data record of the first training set as the new current training record and returning to step 83;

[0074] Step 88, perform a round of traversal on all the first data records of the first evaluation set; and in this round of traversal, use the first data record currently traversed as the corresponding current evaluation record; and use the first training text, the first comparison text sequence and the first label index of the current evaluation record as the corresponding current training text, the current comparison text sequence and the current label index; and input the current training text and the current comparison text sequence into the text retrieval model, and the text retrieval model performs associated text retrieval processing on the current comparison text sequence input into the model according to the current training text input into the model, and use the retrieval text output by the text retrieval model as the corresponding current predicted text; and identify whether the current predicted text is one of the first comparison texts in the current comparison text sequence, and if so, extract the sequence index of the current predicted text in the current comparison text sequence as the corresponding current prediction index, and if not, set the corresponding current prediction The index is empty; and two all-zero vectors whose lengths are consistent with the total number of comparison texts of the current comparison text sequence are initialized as the corresponding second prediction vector and second label vector; and when the current prediction index is not empty, the vector data corresponding to the vector sorting index and the current prediction index in the second prediction vector is reset to 1; and when the current label index is not empty, the vector data corresponding to the vector sorting index and the current label index in the second label vector is reset to 1; and the second prediction vector and the second label vector corresponding to the current evaluation record form a corresponding first prediction-label pair; and at the end of this round of traversal, a confusion matrix A is constructed based on the construction principle of the confusion matrix according to all the first prediction-label pairs obtained; and based on the confusion matrix A, the corresponding accuracy, precision and recall statistics are performed to obtain the corresponding first accuracy, first precision and first recall; and based on the first precision and the first recall, the corresponding F1 score is calculated to obtain the corresponding first F1 score;

[0075] Step 89, identifying the first accuracy rate and the first F1 score obtained this time; if the first accuracy rate does not meet the preset first accuracy rate range or the first F1 score does not meet the preset first F1 score range, returning to step 82 to continue training; if the first accuracy rate meets the first accuracy rate range and the first F1 score meets the first F1 score range, stopping training and confirming the completion of text retrieval model training.

[0076] Preferably, the training of the event extraction model based on the second data set specifically includes:

[0077] Step 91, dividing the second data set into sub-data sets based on a preset second segmentation ratio to obtain corresponding second training sets and second evaluation sets;

[0078] Wherein, both the second training set and the second evaluation set are composed of a plurality of the second data records; the ratio of the total number of records in the second training set to the total number of records in the second evaluation set satisfies the second segmentation ratio;

[0079] Step 92, taking the first second data record of the second training set as the corresponding current training record;

[0080] Step 93, taking the second training text and the first label event information text of the current training record as the corresponding current training text and current label event information text;

[0081] Step 94, inputting the current training text into the event extraction model, allowing the event extraction model to extract event information from the current training text input into the model, and using the event information text output by the event extraction model as the corresponding current predicted event information text;

[0082] Step 95: Substitute the current predicted event information text and the current label event information text into the preset second model loss function L M2 ; and based on the preset second model optimizer, move towards making the second model loss function L M2 Performing a round of optimization on the model parameters of the first trigger word prediction module, the first event type prediction module, and the first event element labeling module of the event extraction model in the direction of reaching the minimum value;

[0083] Among them, the second model loss function L M2 for:

[0084]

[0085] is the trigger word text N-gram encoding vector of the first event trigger word of the current predicted event information text. If the first event trigger word of the current predicted event information text is empty, the corresponding encoding vector is set to an all-zero vector;

[0086] is the trigger word text N-gram encoding vector of the first tag event trigger word of the current tag event information text. If the first tag event trigger word of the current tag event information text is empty, the corresponding encoding vector is set to an all-zero vector;

[0087] The encoding vector The vector lengths of the first event trigger word and the first label event trigger word in the current predicted event information text and the current label event information text are inconsistent, the encoding vector is padded with zeros to make the encoding vector shorter. The vector length of is consistent;

[0088] An event type one-hot encoding vector of the first event type of the current predicted event information text; The event type one-hot encoding vector of the first label event type of the current label event information text; the one-hot encoding vector The vector lengths of are consistent, and are composed of multiple event type one-hot encodings, each of which corresponds to a class of event types, and the total number of event type one-hot encodings is consistent with the preset total number of event types; the one-hot encoding vector In the one-hot encoding vector, only the event type corresponding to the first event type of the current predicted event information text is one-hot encoded as 1, and all other event types are one-hot encoded as 0; Only the event type corresponding to the first label event type of the current label event information text is one-hot encoded as 1, and all other event types are one-hot encoded as 0;

[0089] M is the total number of types of the statistical type set G, and the total number of types of statistics M is a positive integer; the statistical type set G is the statistical result obtained by performing type statistics on the element types of all event elements in the current predicted event information text and the current label event information text, and the statistical type set G consists of M types of statistical types g i Composition, each of the statistical types g i The element type corresponding to a class of event elements; 1≤type index i≤M;

[0090] The first element type and the statistic type g of the i-th category in the current prediction event information text i The object text N-gram encoding vector of the first element object of the first event element that matches, if the current predicted event information text does not contain a statistical type g of the i-th category i The first element type that matches the corresponding encoding vector is set to an all-zero vector;

[0091] The first tag element type and the statistic type g of the i-th category in the current tag event information text iThe object text N-gram encoding vector of the first tag element object of the first tag event element that matches, if the current tag event information text does not contain a statistical type g of the i-th category i The encoding vector corresponding to the first tag element type that matches is set to an all-zero vector;

[0092] The encoding vector The vector length should be consistent. If the current predicted event information text and the current label event information text have the same statistical type g as the i-th category i If the object text lengths of the first element object and the first tag element object are inconsistent, the encoding vector with the shorter length is padded with zeros to make the encoding vector The vector length of is consistent;

[0093] The second model optimizer includes at least an SGD optimizer and an ADAM optimizer;

[0094] Step 96, identifying whether the current training record is the last second data record of the second training set; if so, going to step 97; if not, extracting the next second data record of the second training set as the new current training record and returning to step 93;

[0095] Step 97, perform a round of traversal on all the second data records of the second evaluation set; and in this round of traversal, use the second data record currently traversed as the corresponding current evaluation record; and use the second training text and the first label event information text of the current evaluation record as the corresponding current training text and current label event information text; and input the current training text into the event extraction model, and the event extraction model performs event information extraction processing on the current training text input into the model, and use the event information text output by the event extraction model as the corresponding current predicted event information text; and form a corresponding second prediction-label pair with the current predicted event information text and the corresponding current label event information text; and at the end of this round of traversal, bring all the obtained second prediction-label pairs into the preset model evaluation function F A Performing an evaluation value calculation to obtain a corresponding first evaluation value;

[0096] The model evaluation function F A for:

[0097]

[0098] n a is the total number of the second prediction-label pairs, 1≤indexj≤na ;

[0099] f er () is MAE error function or MSE error function;

[0100] The trigger word text N-gram encoding vector corresponding to the first event trigger word of the predicted event information text of the jth second prediction-label pair; is the N-gram encoding vector of the trigger word text of the first label event trigger word of the label event information text of the jth second prediction-label pair; a pair of encoding vectors corresponding to each second prediction-label pair The vector lengths of should be consistent. If a pair of encoding vectors If the lengths of the vectors are inconsistent, the shorter encoding vector is padded with zeros to make the lengths of the two vectors consistent;

[0101] is the event type one-hot encoding vector of the first event type of the predicted event information text of the j-th second prediction-label pair; is the event type one-hot encoding vector of the first label event type of the label event information text of the jth second prediction-label pair; a pair of one-hot encoding vectors corresponding to each second prediction-label pair The vector lengths of are consistent;

[0102] M j is the statistical type set G of the jth second prediction-label pair j The total number of species statistics, the total number of species statistics M j is a positive integer; the statistical type set G j is a statistical result obtained by performing type statistics on the element types of all event elements in the predicted event information text and the label event information text of the jth second prediction-label pair, wherein the statistical type set G j By M j Class statistic type g j,k Composition, each of the statistical types g j,k The element type corresponding to a class of event elements; in each of the statistical type sets G j , 1≤type index k≤M j ;

[0103] The first element type and the corresponding statistical type set G in the predicted event information text of the jth second prediction-label pair j The statistical type g in the kth category j,kan object text N-gram encoding vector of the first element object of the matched first event element;

[0104] The first label element type and the corresponding statistical type set G in the label event information text of the jth second prediction-label pair j The statistical type g described in the kth category j,k the object text N-gram encoding vector of the first tag element object of the matched first tag event element;

[0105] Each of the second prediction-label pairs corresponds to a pair of encoding vectors The vector length should be consistent. If a pair of the encoding vector If the lengths of the vectors are inconsistent, the shorter encoding vector is padded with zeros to make the lengths of the two vectors consistent;

[0106] Step 98, identifying whether the first evaluation value satisfies a preset first evaluation value range; if not, returning to step 92 to continue training; if satisfied, stopping training and confirming that the event extraction model training is completed.

[0107] The second aspect of the embodiment of the present invention provides a device for implementing the event extraction method based on context enhancement described in the first aspect, the device comprising: a model construction module, a model training module, a text receiving module, a text sentence segmentation module, a context enhancement module, an event extraction module and an event feedback module;

[0108] The model building module is used to select a class of large language models as the corresponding first large language model; and to build a text retrieval model for text retrieval; and to add trigger word prediction, event type prediction, event element annotation and event information fusion components related to event extraction on the basis of the feature extraction component of the first large language model to form an event extraction model for event information extraction;

[0109] The model training module is used to create corresponding model training data sets for the text retrieval model and the event extraction model based on the text generation task processing capability of the first large language model, recorded as corresponding first data sets and second data sets; and train the text retrieval model based on the first data set; and train the event extraction model based on the second data set;

[0110] The text receiving module is used to receive the user's input text as the corresponding current user text after the model training is completed;

[0111] The text sentence segmentation module is used to perform text sentence segmentation processing on the current user text to obtain a corresponding sentence text sequence; the sentence text sequence is formed by sequentially sorting a plurality of sentence texts;

[0112] The context enhancement module is used to take each of the sentence texts as the corresponding current text; and to form a corresponding other text sequence from all the sentence texts in the sentence text sequence except the current text; and to input the current text and the corresponding other text sequence into the text retrieval model to perform text retrieval to obtain the corresponding current retrieval text; and to perform text splicing on the current text and the corresponding current retrieval text to obtain a corresponding context enhanced text;

[0113] The event extraction module is used to perform deduplication processing on all the context-enhanced texts obtained; and input each of the deduplicated context-enhanced texts into the event extraction model to perform event information extraction processing to obtain corresponding event information texts;

[0114] The event feedback module is used to form a corresponding event extraction record from each of the event information texts, the corresponding sentence texts and the context enhanced text; and to form a corresponding extraction record sequence from all the obtained event extraction records to provide feedback to the user.

[0115] A third aspect of an embodiment of the present invention provides an electronic device, including: a memory, a processor, and a transceiver;

[0116] The processor is used to be coupled to the memory, read and execute instructions in the memory, so as to implement the method steps described in the first aspect above;

[0117] The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.

[0118] A fourth aspect of an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions. When the computer instructions are executed by a computer, the computer executes the instructions of the method described in the first aspect above.

[0119] The embodiment of the present invention provides an event extraction method, device, electronic device and computer-readable storage medium based on context enhancement. As can be seen from the above content, the embodiment of the present invention selects a class of large language models as the corresponding first large language model, and constructs a text retrieval model for text retrieval, and adds trigger word prediction, event type prediction, event element annotation and event information fusion components related to event extraction on the basis of the feature extraction component of the first large language model to form an event extraction model for event information extraction; and uses the powerful text generation task processing capability of the first large language model to automatically create a large amount of model training data sets for the text retrieval model and the event extraction model, and trains the text retrieval model and the event extraction model separately based on the obtained two data sets; and after the model training is completed, the text retrieval model is used to perform text retrieval on the largest associated sentence in the full text of each sentence in the user input text, and the text splicing of each sentence and its corresponding retrieval text forms a corresponding context enhanced text; and each context enhanced text after deduplication is input into the event extraction model for event information extraction processing to obtain the corresponding event information text, and all the obtained event information texts are fed back to the user. The event extraction model customized by the embodiment of the present invention retains the encoding components of the first large language model and adds exclusive components related to the event extraction task. The customized text retrieval model can provide a context enhancement mechanism for the event extraction model. Using the two customized models provided by the embodiment of the present invention to process the event extraction task of large text can not only improve the extraction accuracy of event information, but also improve the extraction completeness of event information. In addition, the embodiment of the present invention also uses the powerful text generation capability of the first large language model to automatically create corresponding training data sets for the two customized models. This processing method of the embodiment of the present invention not only improves the model training speed, but also improves the generalization of the model. BRIEF DESCRIPTION OF THE DRAWINGS

[0120] Figure 1 A schematic diagram of an event extraction method based on context enhancement provided in Embodiment 1 of the present invention;

[0121] Figure 2 A module structure diagram of the first language model provided in the first embodiment of the present invention;

[0122] Figure 3 A module structure diagram of a text retrieval model provided in the first embodiment of the present invention;

[0123] Figure 4 A module structure diagram of an event extraction model provided in Embodiment 1 of the present invention;

[0124] Figure 5 A module structure diagram of an event extraction device based on context enhancement provided in Embodiment 2 of the present invention;

[0125] Figure 6 A schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present invention. DETAILED DESCRIPTION

[0126] In order to make the purpose, technical solution and advantages of the present invention clearer, the present invention will be further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0127] Embodiment 1 of the present invention provides an event extraction method based on context enhancement, such as Figure 1 As shown in the schematic diagram of a context-enhanced event extraction method provided in the first embodiment of the present invention, the method mainly includes the following steps:

[0128] Step 1, select a class of large language models as the corresponding first large language model; and build a text retrieval model for text retrieval; and add trigger word prediction, event type prediction, event element annotation and event information fusion components related to event extraction on the basis of the feature extraction component of the first large language model to form an event extraction model for event information extraction.

[0129] The following will introduce the above three types of models respectively.

[0130] 1) The first language model:

[0131] The first large language model of the embodiment of the present invention is a large language model based on the Transformer model architecture. This type of large language model based on the Transformer model architecture includes at least the GPT series model and the BERT series model, wherein the GPT series model uses the Decoder module of the Transformer model as the feature extraction module when processing text generation tasks, and the corresponding text generator performs corresponding feature decoding and text generation processing according to the output features of the feature extraction module, and the BERT series model uses the Encoder module of the Transformer model as the feature extraction module when processing text generation tasks, and the corresponding text generator performs corresponding feature decoding and text generation processing according to the output features of the feature extraction module.

[0132] It should be noted that the first language model in the embodiment of the present invention has completed model pre-training based on the full-domain text corpus and has completed model fine-tuning based on the text corpus of the first specific knowledge field. That is to say, the first language model in the embodiment of the present invention can correctly understand and generate natural language text and can correctly handle a variety of natural language processing tasks. The multiple natural language processing tasks here include at least text generation tasks, text translation tasks and intelligent question and answer tasks; the full domain mentioned above includes at least the biomedical knowledge field, the battery material knowledge field, the financial knowledge field, the legal knowledge field, the architectural knowledge field and the autonomous driving knowledge field; the first specific knowledge field mentioned above is any knowledge field in the full domain.

[0133] It should also be noted that the first language model of the embodiment of the present invention is used to perform corresponding natural language text generation processing based on the natural language understanding of the first input text input to the model and output the corresponding first generated text when processing the text generation task. Figure 2 As shown in the module structure diagram of the first large language model provided in Embodiment 1 of the present invention, the large language model input end of the first large language model is used to receive the corresponding first input text, and the large language model output end is used to output the corresponding first generated text.

[0134] like Figure 2 As shown, the internal model components of the first large language model include at least a first word embedding encoding module, a first feature extraction module and a first text generation module.

[0135] The connection relationship between the internal model components of the first large language model is: the input end of the first word embedding encoding module is connected to the input end of the large language model, and the output end is connected to the input end of the first feature extraction module; the output end of the first feature extraction module is connected to the input end of the first text generation module; the output end of the first text generation module is connected to the output end of the large language model.

[0136] The functions of the internal model components of the first language model are described as follows.

[0137] 1-a) First word embedding encoding module:

[0138] The first word embedding coding module of the first large language model is used to perform word segmentation processing on the first input text to obtain a corresponding first word segmentation text sequence; and based on a preset word embedding coding model, each first word segmentation text of the first word segmentation text sequence is subjected to word embedding coding processing to obtain a corresponding first word segmentation coding vector and send it to the first feature extraction module.

[0139] Here, the first word segmentation text sequence is formed by sequentially sorting multiple first word segmentation texts; the word embedding coding model includes at least an N-gram coding model and a Word2Vec coding model; the first word segmentation coding vector is formed by sequentially sorting multiple first word segmentation codes, and the first word segmentation code corresponds to the first word segmentation text one by one.

[0140] 1-b) The first feature extraction module:

[0141] The first feature extraction module of the first large language model is implemented based on the Encoder or Decoder module of the Transformer model; the first feature extraction module is used to perform deep learning encoding on the associated features of each word segmentation code and other word segmentation codes in the first word segmentation code vector to obtain the corresponding first text feature vector and send it to the first text generation module.

[0142] Here, the first text feature vector is composed of a plurality of first text features, and the first text features correspond one-to-one to the first segmented text.

[0143] 1-c) First text generation module:

[0144] The first text generation module of the first large language model is implemented based on a type of text generator model; the first text generation module is used to perform feature decoding and text generation processing according to the first text feature vector to obtain the corresponding first generated text and output it.

[0145] 2) Text retrieval model:

[0146] The text retrieval model of the embodiment of the present invention is used to perform associated text retrieval processing on the second text sequence input by the model according to the first text input by the model and output the corresponding first retrieval text; wherein the second text sequence is formed by sorting multiple second texts; the first and second texts are each a sentence text; the first text is different from all the second texts in the second text sequence; when the first retrieval text is not empty, it matches a second text in the second text sequence.

[0147] like Figure 3 As shown in the module structure diagram of the text retrieval model provided in the first embodiment of the present invention, the first retrieval model input end of the text retrieval model of the embodiment of the present invention is used to receive the corresponding first text, the second retrieval model input end is used to receive the corresponding second text sequence, and the retrieval model output end is used to output the corresponding first retrieval text.

[0148] like Figure 3 As shown, the internal model components of the text retrieval model include at least a first MLP module, a second MLP stacking module, a similarity comparison module and a text screening module.

[0149] The connection relationship of the internal model components of the text retrieval model is: the input end of the first MLP module is connected to the input end of the first retrieval model, and the output end is connected to the first input end of the similarity comparison module; the input end of the second MLP stacking module is connected to the input end of the second retrieval model, and the output end is connected to the second input end of the similarity comparison module; the output end of the similarity comparison module is connected to the first input end of the text screening module; the second input end of the text screening module is connected to the input end of the second retrieval model, and the output end is connected to the output end of the retrieval model.

[0150] The functions of the internal model components of the text retrieval model are described as follows.

[0151] 2-a) The first MLP module:

[0152] The first MLP module of the text retrieval model is implemented based on the MLP model structure; the first MLP module is used to extract text features from the first text to obtain a corresponding first text feature vector and send it to the similarity comparison module.

[0153] 2-b) Second MLP stacking module:

[0154] The second MLP stacking module of the text retrieval model is composed of multiple parallel second MLP modules, and the second MLP modules correspond to the second texts one by one; each second MLP module is implemented based on the MLP model structure; the second MLP stacking module is used to count the total number of texts in the second text sequence to obtain the corresponding total number of texts N; and dynamically stack N parallel second MLP modules, and create a one-to-one correspondence between the second MLP module and the second text of the second text sequence; and each second MLP module extracts text features from the corresponding second text to obtain a corresponding second text feature vector; and all the obtained second text feature vectors are sorted according to the text sorting order of the second text sequence to form a corresponding second text feature vector sequence and sent to the similarity comparison module.

[0155] 2-c) Similarity comparison module:

[0156] The similarity comparison module of the text retrieval model is used to calculate the vector similarity between the first text feature vector and each second text feature vector in the second text feature vector sequence according to the cosine vector similarity algorithm to obtain the corresponding first similarity; and use the first similarity with the highest similarity as the corresponding maximum similarity; and identify whether the maximum similarity exceeds a preset similarity threshold; if the maximum similarity exceeds the similarity threshold, extract the sorting index of the second text feature vector corresponding to the maximum similarity in the second text feature vector sequence as the corresponding first sorting index; if the maximum similarity does not exceed the similarity threshold, set the corresponding first sorting index to empty; and send the obtained first sorting index to the text screening module.

[0157] Here, the similarity threshold is a preset threshold parameter.

[0158] 2-d) Text filtering module:

[0159] The text screening module of the text retrieval model is used to identify whether the first sorting index is empty; if the first sorting index is not empty, the second text corresponding to the first sorting index in the second text sequence is extracted as the corresponding first retrieval text; if the first sorting index is empty, the corresponding first retrieval text is set to empty; and the obtained first retrieval text is output.

[0160] 3) Event Extraction Model:

[0161] The event extraction model of an embodiment of the present invention is used to perform event information extraction processing on a third text input to the model and output a corresponding first event information text; wherein the third text is a sentence text; when the first event information text is not empty, it is composed of a first event trigger word, a first event type and a first event element set; the first event element set includes multiple first event elements; the first event element includes a first element type and a first element object.

[0162] like Figure 4 As shown in the module structure diagram of the event extraction model provided in the first embodiment of the present invention, the extraction model input end of the event extraction model of the embodiment of the present invention is used to receive the corresponding third text, and the extraction model output end is used to output the corresponding first event information text.

[0163] like Figure 4 As shown, the internal model components of the event extraction model include at least a first word embedding encoding module, a first feature extraction module, a first trigger word prediction module, a first event type prediction module, a first event element labeling module and a first event information fusion module.

[0164] The connection relationship of the internal model components of the event extraction model is as follows: the input end of the first word embedding encoding module is connected to the input end of the extraction model, and the first and second output ends are respectively connected to the input end of the first feature extraction module and the third input end of the first event information fusion module; the first, second and third output ends of the first feature extraction module are respectively connected to the input end of the first trigger word prediction module, the second input end of the first event type prediction module, and the input end of the first event element labeling module; the output end of the first trigger word prediction module is connected to the first input end of the first event type prediction module; the output end of the first event type prediction module is connected to the first input end of the first event information fusion module; the output end of the first event element labeling module is connected to the second input end of the first event information fusion module; and the output end of the first event information fusion module is connected to the output end of the extraction model.

[0165] The functions of the internal model components of the event extraction model are described as follows.

[0166] 3-a) First word embedding encoding module:

[0167] The first word embedding coding module of the event extraction model is a direct reference to the first word embedding coding module of the first large language model, and differs from the first large language model only in the distribution of process data; the first word embedding coding module of the event extraction model is used to perform word segmentation processing on the third text to obtain the corresponding second word segmentation text sequence and send it to the first event information fusion module; and based on the word embedding coding model, each second word segmentation text of the second word segmentation text sequence is word embedded in the coding model to obtain the corresponding second word segmentation coding vector and send it to the first feature extraction module.

[0168] Here, the second word segmentation text sequence is formed by sequentially sorting a plurality of second word segmentation texts; the second word segmentation encoding vector is formed by sequentially sorting a plurality of second word segmentation encodings, and the second word segmentation encodings correspond one-to-one to the second word segmentation texts.

[0169] 3-b) The first feature extraction module:

[0170] The first feature extraction module of the event extraction model is a direct reference to the first feature extraction module of the first large language model, and differs from the first large language model only in the distribution of process data; the first feature extraction module of the event extraction model is used to perform deep learning encoding on the associated features of each word segmentation code and other word segmentation codes in the second word segmentation code vector to obtain the corresponding second text feature vector and send it to the first trigger word prediction module, the first event type prediction module and the first event element labeling module respectively.

[0171] Here, the second text feature vector is composed of a plurality of second text features, and the second text features correspond one-to-one to the second segmented text.

[0172] 3-c) The first trigger word prediction module:

[0173] The first trigger word prediction module of the event extraction model is implemented based on a class of neural network classifiers; the first trigger word prediction module is used to perform a corresponding event trigger word probability prediction process according to the second text feature vector to obtain a corresponding first trigger word prediction vector and send it to the first event type prediction module;

[0174] Here, the neural network classifier mentioned in the embodiment of the present invention includes at least a classifier model implemented based on an MLP model, a classifier model implemented based on a CNN model, and a classifier model implemented based on an RNN model; the first trigger word prediction vector is composed of multiple first trigger word prediction probabilities; the first trigger word prediction probability corresponds to the second word segmentation text one by one; the first trigger word prediction probability is the prediction probability that the corresponding second word segmentation text is recognized as an event trigger word.

[0175] 3-d) First event type prediction module:

[0176] The first event type prediction module of the event extraction model is used to perform feature fusion processing on the first trigger word prediction vector and the second text feature vector to obtain the corresponding first text fusion feature vector; and based on another type of neural network classifier, perform corresponding event type classification prediction processing on the first word segmentation fusion feature vector to obtain the corresponding first event type prediction vector; and record the first trigger word prediction probability with the largest probability value in the first trigger word prediction vector as the corresponding maximum trigger word prediction probability; and identify whether the maximum trigger word prediction probability exceeds a preset trigger word prediction probability threshold; if the maximum trigger word prediction probability exceeds the trigger word prediction probability threshold, the sorted index in the first trigger word prediction vector is extracted as the corresponding first trigger word index. Introduction; if the maximum trigger word prediction probability does not exceed the trigger word prediction probability threshold, the corresponding first trigger word index is set to empty; and the first event type prediction probability with the largest probability in the first event type prediction vector is used as the corresponding maximum event type prediction probability; and whether the maximum event type prediction probability exceeds the preset event type prediction probability threshold is identified; if the maximum event type prediction probability exceeds the event type prediction probability threshold, the event type corresponding to the maximum event type prediction probability is used as the corresponding first event type; if the maximum event type prediction probability does not exceed the event type prediction probability threshold, the corresponding first event type is set to empty; and the obtained first trigger word index and first event type are sent to the first event information fusion module.

[0177] Here, the first text fusion feature vector of the embodiment of the present invention is formed by sequentially sorting multiple first text fusion features, the first text fusion features correspond to the second word segmentation texts one by one, and each first text fusion feature is formed by splicing the corresponding first trigger word prediction probability and the second text feature in a data vector splicing manner; the first event type prediction vector is composed of multiple first event type prediction probabilities; each first event type prediction probability corresponds to a class of event types; the trigger word prediction probability threshold and the event type prediction probability threshold are two pre-set threshold parameters.

[0178] 3-e) First event element annotation module:

[0179] The first event element labeling module of the event extraction model is implemented based on the Conditional Random Field (CRF) model; the first event element labeling module is used to perform corresponding event element labeling processing according to the second text feature vector to obtain the corresponding first label vector and send it to the first event information fusion module.

[0180] Here, the CRF model is a commonly used processing model for sequence labeling, and the embodiment of the present invention uses the CRF model to implement event element labeling. The first labeling label vector is formed by sequentially sorting a plurality of first labeling labels, and the first labeling labels correspond one-to-one to the second segmentation text; the first labeling label is the event element label of the corresponding second segmentation text; the label type of the first labeling label includes multiple types of B-event element labels, multiple types of I-event element labels and O labels; each type of B-event element label or I-event element label corresponds to a specified event element type; the second segmentation text corresponding to each B-event element label is the starting segmentation of the element object text corresponding to a type of event element type, and the second segmentation text corresponding to each I-event element label is the middle segmentation of the element object text corresponding to a type of event element type; the second segmentation text corresponding to each O label is a segmentation that cannot correspond to any event element type.

[0181] For example, it is known that text 1 is "Xiao Ming plans to go to the cafeteria to eat at three o'clock in the afternoon". The second segmented text sequence obtained after the first word embedding encoding module segmented the words is {Xiao Ming, plans, afternoon, three o'clock, go, to, the cafeteria, eat, meal}; it is known that the event element type set includes location elements, time elements, character elements, and food elements, then the first annotation label vector output by the first event element annotation module may be {B-character element label, O label, B-time element label, I-time element label, O label, B location element label, O label, B-food element label}.

[0182] 3-f) First event information fusion module:

[0183] The first event information fusion module of the event extraction model is used to identify the first trigger word index and the first event type; if the first trigger word index is empty or the first event type is empty, the corresponding first event information text is set to be empty; if neither the first trigger word index nor the first event type is empty, the second segmentation text corresponding to the first trigger word index in the second segmentation text sequence is used as the corresponding first event trigger word, and the first element subset corresponding to the first event type in the preset event element set is used as the corresponding current element subset, and each event element type of the current element subset is used as a corresponding first element type, and the first annotation label in the first annotation label vector that does not correspond to all first element types is reset to the O label, and the element objects corresponding to each first element type are extracted and processed according to the reset first annotation label vector and the second segmentation text sequence to obtain the corresponding first element object, and each first element type and the corresponding first element object form a corresponding first event element, and all the obtained first event elements form a corresponding first event element set, and the obtained first event trigger word, first event type and first event element set form the corresponding first event information text; and the first event information text obtained this time is output.

[0184] Here, the event element set of the embodiment of the present invention is a preset total set of all element types of all event types, consisting of multiple first element subsets, each first element subset corresponds to a class of event types, and each first element subset consists of all event element types corresponding to the current event type.

[0185] The step of extracting and processing the element objects corresponding to each first element type according to the reset first annotation label vector and the second segmented text sequence to obtain the corresponding first element objects specifically includes:

[0186] Step A1, the first event information fusion module records the first second segmented word text in the second segmented word text sequence as the corresponding current segmented word text;

[0187] Step A2, and record the first annotation tag corresponding to the current segmentation text in the first annotation tag vector as the corresponding current annotation tag; and identify the current annotation tag; if the current annotation tag is a B-event element tag, initialize a corresponding empty sequence for the first element type corresponding to the current annotation tag as the corresponding first object segmentation sequence, and add the current segmentation text to the first object segmentation sequence created this time; if the current annotation tag is an I-event element tag, add the current segmentation text to the first object segmentation sequence corresponding to the first element type corresponding to the current annotation tag;

[0188] Wherein, the first object segmentation sequence corresponds one-to-one to the first element type;

[0189] Step A3, identifying whether the current segmented text is the last second segmented text in the second segmented text sequence; if so, going to step A4; if not, taking the next second segmented text in the second segmented text sequence as the new current segmented text and going back to step A2;

[0190] Step A4, sequentially concatenate all the second segmented word texts in each first object segmented word sequence to obtain a corresponding first concatenated text; and use the first concatenated text corresponding to each first element type as the corresponding first element object.

[0191] For example, it is known that text 1 is "Xiao Ming plans to go to the cafeteria to eat at 3 pm", the second word segmentation text sequence is {Xiao Ming, plan, afternoon, 3 o'clock, go, cafeteria, eat, meal}, the first trigger word index is 5, that is, the trigger word is "go", the first event type is a trajectory event, and the event element types of the first element subset corresponding to the trajectory event in the event element set include (person element, time element, place element), and the first annotation label vector is {B-person element label, O label, B-time element label, I-time element label, O label, B place element label, O label, B-food element label};

[0192] Then, all the first element types obtained are (person element, time element, place element), and the first annotation label vector after resetting the first annotation label that does not correspond to all the first element types to the O label is {B-person element label, O label, B-time element label, I-time element label, O label, B place element label, O label, O label}; according to this first annotation label vector and the second word segmentation text sequence, the element objects corresponding to each first element type are extracted and processed to obtain three first element objects, namely "Xiao Ming", "3 o'clock in the afternoon", and "canteen"; the first event element set thus obtained should be the first event element set {first event element 1 (first element type = person element, first element object = "Xiao Ming"), first event element 2 (first element type = time element, first element object = "3 o'clock in the afternoon"), first event element 1 (first element type = place element, first element object = "canteen")}; the first event information text thus obtained should be:

[0193] The first event trigger word: "go",

[0194] First event type: trajectory event,

[0195] The first event element set: {first event element 1 (first element type = person element, first element object = "Xiao Ming"), first event element 2 (first element type = time element, first element object = "three o'clock in the afternoon"), first event element 1 (first element type = place element, first element object = "canteen")}.

[0196] Step 2: based on the text generation task processing capability of the first language model, corresponding model training data sets are created for the text retrieval model and the event extraction model, recorded as the corresponding first data set and second data set; and the text retrieval model is trained based on the first data set; and the event extraction model is trained based on the second data set;

[0197] Specifically, it includes: step 21, based on the text generation task processing capability of the first language model, corresponding model training data sets are created for the text retrieval model and the event extraction model, and recorded as corresponding first data sets and second data sets;

[0198] Wherein, the first data set includes multiple first data records; the first data record includes a first training text, a first comparison text sequence and a first label index; the first comparison text sequence includes multiple first comparison texts; when the first label index is empty, it means that all first comparison texts in the first comparison text sequence are irrelevant to the first training text; when the first label index is not empty, it means that the first comparison text in the first comparison text sequence whose sequence index matches the first label index has the greatest correlation with the first training text;

[0199] The second data set includes a plurality of second data records; the second data record includes a second training text and a first label event information text; the first label event information text consists of a first label event trigger word, a first label event type and a first label event element set; the first label event element set includes a plurality of first label event elements; the first label event element includes a first label element type and a first label element object;

[0200] Specifically, the steps include: Step 211, initializing a first counter to 0; and increasing the counter from 2 to a preset sentence total threshold value n. amax The integer value range between is used as the corresponding value range R; and the first positive and negative sample states are initialized as positive sample states;

[0201] Here, the total number of sentences threshold n amax is a preset integer threshold, n amax >2; the range of R is [2,n amax ]; The first positive and negative sample states include a positive sample state and a negative sample state;

[0202] Step 212, randomly select an integer in the value range R as the corresponding first sentence total number; and bring the first specific knowledge domain, the first sentence total number and the first positive and negative sample state into the preset first record generation instruction template to perform instruction text splicing to obtain the corresponding first instruction text; and input the first instruction text into the first large language model to perform corresponding record text generation processing to obtain the corresponding first record text; and extract the corresponding first training text, the first comparison text sequence and the first label index from the first record text to form a corresponding first data record;

[0203] Here, 2≤the total number of first sentences≤the total number of sentences threshold n amax ;

[0204] The first record generation instruction template of the embodiment of the present invention is a formatted text configuration template; the first record generation instruction template is used to take the first specific knowledge domain, the first total number of sentences and the first positive and negative sample states as the corresponding current knowledge domain, the current total number of comparison texts n c and the current positive and negative sample states; and inform the first language model through a preset narrative text to generate a creative sentence based on the current knowledge field as the corresponding first training text, and also generate the current comparison text total number n based on the current knowledge field c The creative sentences of the first comparison text sequence are composed of the corresponding first comparison text sequence, and when the current positive and negative sample state is the negative sample state, each first comparison text in the first comparison text sequence is required to be irrelevant to the first training text and the corresponding first label index is set to be empty, and when the current positive and negative sample state is the positive sample state, at least one first comparison text in the first comparison text sequence is required to be related to the first training text and the sequence index of the first comparison text with the highest correlation with the first training text in the first comparison text sequence is used as the corresponding first label index, and the corresponding first record text is composed of the obtained first training text, the first comparison text sequence and the first label index and outputted;

[0205] Step 213, identifying whether the first counter exceeds a preset first counting threshold; if the first counter does not exceed the first counting threshold, randomly selecting a first positive and negative sample state from the positive sample state and the negative sample state to reset; if the first counter exceeds the first counting threshold, the positive and negative sample ratios of the generated first data record are counted to obtain the corresponding first positive and negative sample ratios, and identifying whether the first positive and negative sample ratio exceeds the preset first positive and negative sample ratio threshold, if so, resetting the first positive and negative sample state to the negative sample state, if not, resetting the first positive and negative sample state to the positive sample state;

[0206] Here, the first counting threshold and the first positive-negative sample ratio threshold are two preset threshold parameters; the first positive-negative sample ratio is the ratio of the total number of first data records whose first positive-negative sample state is a positive sample state to the total number of first data records whose first positive-negative sample state is a negative sample state;

[0207] Step 214, adding 1 to the first counter; and identifying whether the first counter after adding 1 exceeds the preset first record total threshold; if not, returning to step 212; if so, forming a corresponding first data set from all the obtained first data records and going to step 215;

[0208] Here, the first record total threshold is a preset threshold parameter;

[0209] Step 215, initializing the second counter to 0; and initializing the first event text attribute to descriptive text;

[0210] The first event text attribute includes descriptive text, action text and position text;

[0211] Step 216, bringing the first specific knowledge domain and the first event text attribute into a preset second record generation instruction template to perform instruction text splicing to obtain a corresponding second instruction text; and inputting the second instruction text into the first large language model to perform corresponding record text generation processing to obtain a corresponding second record text; and extracting the corresponding second training text and the first label event information text from the second record text to form a corresponding second data record;

[0212] Here, the second record generation instruction template of the embodiment of the present invention is a formatted text configuration template; the second record generation instruction template is used to use the first specific knowledge domain and the first event text attribute as the corresponding current knowledge domain and current text attribute; and inform the first large language model through a preset narrative text to randomly select a class of event types from all event types in the current knowledge domain as the corresponding current event type, and generate a creative event information text based on the current event type as the corresponding first label event information text, and randomly generate a creative sentence matching the current text attribute based on the first label event information text as the corresponding second training text, and the corresponding second record text is composed of the obtained second training text and the first label event information text and output, and the first label event information text is required to be composed of a first label event trigger word, a first label event type and a first label event element set, and the first label event element set is required to be composed of one or more first label event elements, and the first label event element is required to be composed of a first label element type and a first label element object;

[0213] Step 217, identifying whether the second counter exceeds a preset second counting threshold; if the second counter does not exceed the second counting threshold, randomly selecting one of the descriptive text, the action text, and the positional text to reset the first event text attribute; if the second counter exceeds the second counting threshold, the descriptive text, the action text, and the positional text ratios of the generated first data record are counted to obtain the corresponding first, second, and third ratios, and the first event text attribute is reset based on the descriptive text, the action text, or the positional text corresponding to the minimum ratio among the first, second, and third ratios;

[0214] Here, the second counting threshold is a preset threshold parameter; the first ratio is the ratio of the total number of first data records whose first event text attribute is descriptive text to the total number of all first data records that have been generated; the second ratio is the ratio of the total number of first data records whose first event text attribute is action text to the total number of all first data records that have been generated; the third ratio is the ratio of the total number of first data records whose first event text attribute is positional text to the total number of all first data records that have been generated;

[0215] Step 218, adding 1 to the second counter; and identifying whether the second counter after adding 1 exceeds the preset second record total threshold; if not, returning to step 216; if so, forming a corresponding second data set from all the obtained second data records;

[0216] Here, the second total number of records threshold is a preset threshold parameter;

[0217] Step 22, training the text retrieval model based on the first data set;

[0218] Specifically, it includes: step 221, dividing the first data set into sub-data sets based on a preset first segmentation ratio to obtain a corresponding first training set and a first evaluation set;

[0219] The first segmentation ratio is a preset ratio threshold, such as 8:2; the first training set and the first evaluation set are both composed of a plurality of first data records; the ratio of the total number of records in the first training set to the total number of records in the first evaluation set satisfies the first segmentation ratio;

[0220] Step 222, taking the first first data record of the first training set as the corresponding current training record;

[0221] Step 223, taking the first training text, the first comparison text sequence and the first label index of the current training record as the corresponding current training text, the current comparison text sequence and the current label index;

[0222] Step 224, input the current training text and the current comparison text sequence into the text retrieval model, and the text retrieval model performs associated text retrieval processing on the current comparison text sequence input into the model according to the current training text input into the model, and uses the retrieval text output by the text retrieval model as the corresponding current predicted text;

[0223] Step 225, whether the current predicted text is a first compared text in the current compared text sequence is identified; if so, the sequence index of the current predicted text in the current compared text sequence is extracted as the corresponding current predicted index; if not, the corresponding current predicted index is set to empty; and two all-zero vectors whose lengths are consistent with the total number of compared texts in the current compared text sequence are initialized as the corresponding first predicted vector and first label vector; and when the current predicted index is not empty, the vector data corresponding to the vector sorting index and the current predicted index in the first predicted vector is reset to 1; and when the current label index is not empty, the vector data corresponding to the vector sorting index and the current label index in the first label vector is reset to 1;

[0224] The first prediction vector and the first label vector are both formed by sequentially sorting a plurality of vector data; when the first prediction vector and the first label vector are initialized, all vector data within each of them are 0;

[0225] Step 226: Substitute the first prediction vector and the first label vector into the preset first model loss function L M1 ; and based on the preset first model optimizer, move towards making the first model loss function L M1 Perform a round of optimization on the model parameters of the first MLP module and all the second MLP modules of the text retrieval model in the direction of reaching the minimum value;

[0226] Here, the first model loss function L M1 for:

[0227]

[0228] Among them, v pre is the first prediction vector, v tag is the first label vector;

[0229] The first model optimizer includes at least an SGD optimizer and an ADAM optimizer;

[0230] Step 227, identifying whether the current training record is the last first data record of the first training set; if so, going to step 228; if not, extracting the next first data record of the first training set as the new current training record and returning to step 223;

[0231] Step 228, perform a round of traversal on all the first data records of the first evaluation set; and in this round of traversal, use the currently traversed first data record as the corresponding current evaluation record; and use the first training text, the first comparison text sequence and the first label index of the current evaluation record as the corresponding current training text, the current comparison text sequence and the current label index; and input the current training text and the current comparison text sequence into the text retrieval model, and the text retrieval model performs associated text retrieval processing on the current comparison text sequence input into the model according to the current training text input into the model, and use the retrieval text output by the text retrieval model as the corresponding current predicted text; and identify whether the current predicted text is a first comparison text in the current comparison text sequence, and if so, extract the sequence index of the current predicted text in the current comparison text sequence as the corresponding current prediction index, and if not, set the corresponding current prediction index to empty; and Initialize two all-zero vectors whose lengths are consistent with the total number of compared texts in the current compared text sequence as the corresponding second prediction vector and second label vector; and when the current prediction index is not empty, reset the vector data corresponding to the vector sorting index and the current prediction index in the second prediction vector to 1; and when the current label index is not empty, reset the vector data corresponding to the vector sorting index and the current label index in the second label vector to 1; and form a corresponding first prediction-label pair by the second prediction vector and the second label vector corresponding to the current evaluation record; and at the end of this round of traversal, construct a confusion matrix A based on all the first prediction-label pairs obtained based on the construction principle of the confusion matrix; and perform corresponding accuracy, precision and recall statistics based on the confusion matrix A to obtain the corresponding first accuracy, first precision and first recall; and perform corresponding F1 score calculation based on the first precision and first recall to obtain the corresponding first F1 score;

[0232] Step 229, identifying the first accuracy and the first F1 score obtained this time; if the first accuracy does not meet the preset first accuracy range or the first F1 score does not meet the preset first F1 score range, returning to step 222 to continue training; if the first accuracy meets the first accuracy range and the first F1 score meets the first F1 score range, stopping the training and confirming that the text retrieval model training is completed;

[0233] Here, the first accuracy range and the first F1 score range are two preset value ranges;

[0234] Step 23, training the event extraction model based on the second data set;

[0235] Specifically, it includes: step 231, dividing the second data set into sub-data sets based on a preset second segmentation ratio to obtain corresponding second training sets and second evaluation sets;

[0236] The second segmentation ratio is a preset ratio threshold, such as 8:2; the second training set and the second evaluation set are both composed of a plurality of second data records; the ratio of the total number of records in the second training set to the total number of records in the second evaluation set satisfies the second segmentation ratio;

[0237] Step 232, taking the first second data record of the second training set as the corresponding current training record;

[0238] Step 233, taking the second training text and the first label event information text of the current training record as the corresponding current training text and the current label event information text;

[0239] Step 234, input the current training text into the event extraction model, the event extraction model performs event information extraction processing on the current training text input into the model, and uses the event information text output by the event extraction model as the corresponding current predicted event information text;

[0240] Step 235: bring the current predicted event information text and the current label event information text into the preset second model loss function L M2 ; and based on the preset second model optimizer, move towards making the second model loss function L M2 Perform a round of optimization on the model parameters of the first trigger word prediction module, the first event type prediction module, and the first event element labeling module of the event extraction model in the direction of reaching the minimum value;

[0241] Here, the second model loss function L M2 for:

[0242]

[0243] in,

[0244] is the N-gram encoding vector of the trigger word text of the first event trigger word of the current predicted event information text. If the first event trigger word of the current predicted event information text is empty, the corresponding encoding vector is set to an all-zero vector; is the trigger word text N-gram encoding vector of the first tag event trigger word of the current tag event information text. If the first tag event trigger word of the current tag event information text is empty, the corresponding encoding vector is set to an all-zero vector; the encoding vector The vector length of should be consistent. If the text length of the first event trigger word and the first label event trigger word in the current predicted event information text and the current label event information text are inconsistent, the encoding vector with the shorter length is padded with zeros to make the encoding vector The vector length of is consistent;

[0245] The event type one-hot encoding vector of the first event type of the current predicted event information text; The event type one-hot encoding vector of the first label event type of the current label event information text; the one-hot encoding vector y The vector length of is consistent, and is composed of multiple event type one-hot encodings. Each event type one-hot encoding corresponds to a class of event types. The total number of event type one-hot encodings is consistent with the preset total number of event types. The one-hot encoding vector In the one-hot encoding vector, only the event type corresponding to the first event type of the current predicted event information text is encoded as 1, and all other event types are encoded as 0. Only the event type corresponding to the first label event type of the current label event information text is encoded as 1, and all other event types are encoded as 0;

[0246] M is the total number of types of the statistical type set G, and the total number of types of statistics M is a positive integer; the statistical type set G is the statistical result obtained by performing type statistics on the element types of all event elements in the current predicted event information text and the current label event information text. The statistical type set G consists of M types of statistical types g i Composition, each statistic type g i The element type corresponding to a class of event elements; 1≤type index i≤M;

[0247] The first element type and the i-th statistical type g in the current prediction event information text i The object text N-gram encoding vector of the first element object of the first event element that matches. If the current predicted event information text does not contain a statistical type g of the i-th category i The first element type that matches the corresponding encoding vector is set to an all-zero vector;

[0248] The first tag element type and the i-th statistical type g in the current tag event information text i The object text N-gram encoding vector of the first tag element object of the matched first tag event element. If the current tag event information text does not contain a certain i-th statistical type g i The first tag element type that matches the corresponding encoding vector is set to an all-zero vector;

[0249] Encoded vector The vector length should be consistent. If the current predicted event information text and the current label event information text contain the same statistical type g as the i-th categoryi If the object text lengths of the corresponding first element object and the first tag element object are inconsistent, the encoding vector with the shorter length is padded with zeros to make the encoding vector The vector length of is consistent;

[0250] The second model optimizer includes at least an SGD optimizer and an ADAM optimizer;

[0251] Step 236, identifying whether the current training record is the last second data record of the second training set; if so, going to step 237; if not, extracting the next second data record of the second training set as the new current training record and returning to step 233;

[0252] Step 237, perform a round of traversal on all second data records of the second evaluation set; and in this round of traversal, use the currently traversed second data record as the corresponding current evaluation record; and use the second training text and the first label event information text of the current evaluation record as the corresponding current training text and the current label event information text; and input the current training text into the event extraction model, and the event extraction model performs event information extraction processing on the current training text input into the model, and use the event information text output by the event extraction model as the corresponding current predicted event information text; and form a corresponding second prediction-label pair with the current predicted event information text and the corresponding current label event information text; and at the end of this round of traversal, bring all the obtained second prediction-label pairs into the preset model evaluation function F A Performing an evaluation value calculation to obtain a corresponding first evaluation value;

[0253] Here, the model evaluation function F A for:

[0254]

[0255] n a is the total number of second prediction-label pairs, 1≤indexj≤n a ;

[0256] f er () is MAE error function or MSE error function;

[0257] The trigger word text N-gram encoding vector corresponding to the first event trigger word of the predicted event information text of the j-th second prediction-label pair; is the N-gram encoding vector of the trigger word text of the first label event trigger word of the label event information text of the jth second prediction-label pair; a pair of encoding vectors corresponding to each second prediction-label pair The vector lengths of should be consistent. If a pair of encoding vectors If the lengths of the vectors are inconsistent, the shorter encoding vector is padded with zeros to make the lengths of the two vectors consistent;

[0258] is the event type one-hot encoding vector of the first event type of the predicted event information text of the j-th second prediction-label pair; is the event type one-hot encoding vector of the first label event type of the label event information text of the jth second prediction-label pair; a pair of one-hot encoding vectors corresponding to each second prediction-label pair The vector lengths of are consistent;

[0259] M j is the statistical type set G of the jth second prediction-label pair j The total number of species statistics, the total number of species statistics M j is a positive integer; statistical type set G j is the statistical result of the type statistics of all event elements in the predicted event information text and the label event information text of the jth second prediction-label pair. The statistical type set G j By M j Class statistic type g j,k Composition, each statistic type g j,k The element type corresponding to a class of event elements; in each statistical type set G j , 1≤type index k≤M j ;

[0260] is the first element type in the predicted event information text of the jth second prediction-label pair and the corresponding statistical type set G j The kth statistical type g in j,k The object text N-gram encoding vector of the first element object of the first event element of the match;

[0261] The first label element type and the corresponding statistical type set G in the label event information text of the jth second prediction-label pair j The kth statistical type g j,k The object text N-gram encoding vector of the first tag element object of the matched first tag event element;

[0262] A pair of encoding vectors for each second prediction-label pair The vector lengths of should be consistent. If a pair of encoding vectors If the lengths of the vectors are inconsistent, the shorter encoding vector is padded with zeros to make the lengths of the two vectors consistent;

[0263] Step 238, identifying whether the first evaluation value satisfies the preset first evaluation value range; if not, returning to step 232 to continue training; if satisfied, stopping training and confirming that the event extraction model training is completed.

[0264] Here, the first evaluation value range is a preset evaluation value range.

[0265] Step 3: After the model training is completed, the input text received from the user is recorded as the corresponding user text of the time.

[0266] Here, the embodiment of the present invention has no limitation on the length of the text input by the user, and the text can be an extra-long text.

[0267] Step 4: Segment the current user text to obtain a corresponding sentence text sequence.

[0268] Here, the sentence text sequence is formed by sequentially sorting multiple sentence texts.

[0269] Step 5, taking each sentence text as the corresponding current text; and forming the corresponding other text sequence from all sentence texts in the sentence text sequence except the current text; and inputting the current text and the corresponding other text sequence into the text retrieval model for text retrieval to obtain the corresponding current retrieval text; and performing text splicing on the current text and the corresponding current retrieval text to obtain a corresponding context-enhanced text.

[0270] Step 6, performing deduplication processing on all the obtained context-enhanced texts; and inputting each deduplicated context-enhanced text into the event extraction model to perform event information extraction processing to obtain the corresponding event information text.

[0271] Step 7: Each event information text, the corresponding sentence text and the context-enhanced text form a corresponding event extraction record; and all the obtained event extraction records form a corresponding extraction record sequence to be fed back to the user.

[0272] Figure 5 The module structure diagram of a context-enhanced event extraction device provided in the second embodiment of the present invention is a terminal device or server that implements the aforementioned method embodiment, and can also be a device that enables the aforementioned terminal device or server to implement the aforementioned method embodiment. For example, the device can be a device or chip system of the aforementioned terminal device or server. Figure 5As shown, the device includes: a model building module 201, a model training module 202, a text receiving module 203, a text sentence segmentation module 204, a context enhancement module 205, an event extraction module 206 and an event feedback module 207.

[0273] The model building module 201 is used to select a class of large language models as the corresponding first large language model; and to build a text retrieval model for text retrieval; and to add trigger word prediction, event type prediction, event element annotation and event information fusion components related to event extraction on the basis of the feature extraction component of the first large language model to form an event extraction model for event information extraction.

[0274] The model training module 202 is used to create corresponding model training data sets for the text retrieval model and the event extraction model based on the text generation task processing capability of the first language model, recorded as the corresponding first data set and second data set; and train the text retrieval model based on the first data set; and train the event extraction model based on the second data set.

[0275] The text receiving module 203 is used to receive the user's input text and record it as the corresponding user text of the current time after the model training is completed.

[0276] The text sentence segmentation module 204 is used to perform text sentence segmentation processing on the current user text to obtain a corresponding sentence text sequence; the sentence text sequence is formed by sequentially sorting a plurality of sentence texts.

[0277] The context enhancement module 205 is used to take each sentence text as the corresponding current text; and form a corresponding other text sequence from all sentence texts in the sentence text sequence except the current text; and input the current text and the corresponding other text sequence into the text retrieval model for text retrieval to obtain the corresponding current retrieval text; and perform text splicing on the current text and the corresponding current retrieval text to obtain a corresponding context enhanced text.

[0278] The event extraction module 206 is used to perform deduplication processing on all the obtained context-enhanced texts; and input each deduplication-enhanced context-enhanced text into the event extraction model to perform event information extraction processing to obtain the corresponding event information text.

[0279] The event feedback module 207 is used to form a corresponding event extraction record from each event information text, the corresponding sentence text and the context enhancement text; and to form a corresponding extraction record sequence from all the obtained event extraction records to feedback to the user.

[0280] An event extraction device based on context enhancement provided in an embodiment of the present invention can execute the method steps in the above method embodiment. Its implementation principle and technical effects are similar and will not be repeated here.

[0281] It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software called by processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software called by processing elements, and some modules can be implemented in the form of hardware. For example, the model building module can be a separately established processing element, or it can be integrated in a chip of the above device. In addition, it can also be stored in the memory of the above device in the form of program code, and called and executed by a processing element of the above device. The function of the above-mentioned module is determined. The implementation of other modules is similar. In addition, these modules can be fully or partially integrated together, or they can be implemented independently. The processing element described here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.

[0282] For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASIC), or one or more digital signal processors (DSP), or one or more field programmable gate arrays (FPGA). For another example, when a module above is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).

[0283] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the above method embodiments are generated. The above computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The above-mentioned computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the above-mentioned computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, Bluetooth, microwave, etc.) methods. The above-mentioned computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media integrated. The above-mentioned available medium can be a magnetic medium (such as a floppy disk, a hard disk, a tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)), etc.

[0284] Figure 6 This is a schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present invention. The electronic device may be a terminal device or a server for implementing the method of the aforementioned embodiment, or may be a terminal device or a server for implementing the method of the aforementioned embodiment connected to the aforementioned terminal device or server. Figure 6 As shown, the electronic device may include: a processor 301 (such as a CPU), a memory 302, and a transceiver 303; the transceiver 303 is coupled to the processor 301, and the processor 301 controls the transceiver 303. Various instructions may be stored in the memory 302 to complete various processing functions and implement the processing steps described in the aforementioned embodiment method. Preferably, the electronic device involved in the embodiment of the present invention also includes: a power supply 304, a system bus 305 and a communication port 306. The system bus 305 is used to realize the communication connection between components. The above-mentioned communication port 306 is used for connecting and communicating between the electronic device and other peripherals.

[0285] exist Figure 6The system bus 305 mentioned in the figure can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The system bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface is used to realize the communication between the database access device and other devices (such as clients, read-write libraries, and read-only libraries). The memory may include random access memory (RAM), and may also include non-volatile memory (Non-Volatile Memory), such as at least one disk storage.

[0286] The above-mentioned processor can be a general-purpose processor, including a central processing unit CPU, a network processor (Network Processor, NP), a graphics processing unit (Graphics Processing Unit, GPU), etc.; it can also be a digital signal processor DSP, an application-specific integrated circuit ASIC, a field programmable gate array FPGA or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0287] It should be noted that an embodiment of the present invention further provides a computer-readable storage medium, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the method and processing process provided in the above embodiments.

[0288] The embodiment of the present invention provides an event extraction method, device, electronic device and computer-readable storage medium based on context enhancement. As can be seen from the above content, the embodiment of the present invention selects a class of large language models as the corresponding first large language model, and constructs a text retrieval model for text retrieval, and adds trigger word prediction, event type prediction, event element annotation and event information fusion components related to event extraction on the basis of the feature extraction component of the first large language model to form an event extraction model for event information extraction; and uses the powerful text generation task processing capability of the first large language model to automatically create a large amount of model training data sets for the text retrieval model and the event extraction model, and trains the text retrieval model and the event extraction model separately based on the obtained two data sets; and after the model training is completed, the text retrieval model is used to perform text retrieval on the largest associated sentence in the full text of each sentence in the user input text, and the text splicing of each sentence and its corresponding retrieval text forms a corresponding context enhanced text; and each context enhanced text after deduplication is input into the event extraction model for event information extraction processing to obtain the corresponding event information text, and all the obtained event information texts are fed back to the user. The event extraction model customized by the embodiment of the present invention retains the encoding components of the first large language model and adds exclusive components related to the event extraction task. The customized text retrieval model can provide a context enhancement mechanism for the event extraction model. Using the two customized models provided by the embodiment of the present invention to process the event extraction task of large text can not only improve the extraction accuracy of event information, but also improve the extraction completeness of event information. In addition, the embodiment of the present invention also uses the powerful text generation capability of the first large language model to automatically create corresponding training data sets for the two customized models. This processing method of the embodiment of the present invention not only improves the model training speed, but also improves the generalization of the model.

[0289] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0290] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A context-enhanced event extraction method, characterized in that: The method comprises: Select a class of large language models as the corresponding first large language model; and construct a text retrieval model for text retrieval; and add trigger word prediction, event type prediction, event element annotation and event information fusion components related to event extraction on the basis of the feature extraction component of the first large language model to form an event extraction model for event information extraction; Based on the text generation task processing capability of the first language model, corresponding model training data sets are created for the text retrieval model and the event extraction model, which are recorded as corresponding first data sets and second data sets; and the text retrieval model is trained based on the first data set; and the event extraction model is trained based on the second data set; After the model training is completed, the input text received from the user is recorded as the corresponding user text of the current time; Performing text sentence processing on the current user text to obtain a corresponding sentence text sequence; the sentence text sequence is formed by sequentially sorting a plurality of sentence texts; Each of the sentence texts is used as the corresponding current text; and all the sentence texts other than the current text in the sentence text sequence form a corresponding other text sequence; and the current text and the corresponding other text sequence are input into the text retrieval model to perform text retrieval to obtain the corresponding current retrieval text; and the current text and the corresponding current retrieval text are text spliced ​​to obtain a corresponding context-enhanced text; Deduplication processing is performed on all the obtained context-enhanced texts; and each of the deduplicated context-enhanced texts is input into the event extraction model to perform event information extraction processing to obtain corresponding event information texts; Each event information text, the corresponding sentence text and the context enhanced text form a corresponding event extraction record; and all the obtained event extraction records form a corresponding extraction record sequence to be fed back to the user.

2. The event extraction method based on context enhancement according to claim 1, characterized in that: The first large language model is implemented based on the Transformer model architecture; the large language model implemented based on the Transformer model architecture includes at least a GPT series model and a BERT series model; the first large language model has completed model pre-training based on the full-domain text corpus and has completed model fine-tuning based on the text corpus of the first specific knowledge domain, and can correctly understand and generate natural language text and can correctly handle multiple natural language processing tasks; the multiple natural language processing tasks include at least a text generation task; The full range of fields at least includes the biomedical knowledge field, the battery material knowledge field, the financial knowledge field, the legal knowledge field, the architectural knowledge field and the autonomous driving knowledge field; The first specific knowledge domain is any knowledge domain in the overall domain; The first language model is used to perform corresponding natural language text generation processing based on the natural language understanding of the first input text input to the model and output the corresponding first generated text when processing the text generation task; The text retrieval model is used to perform associated text retrieval processing on a second text sequence input by the model according to a first text input by the model and output a corresponding first retrieval text; the second text sequence is formed by sorting a plurality of second texts; the first and second texts are each a sentence text; the first text is different from all the second texts in the second text sequence; when the first retrieval text is not empty, it matches one of the second texts in the second text sequence; The event extraction model is used to perform event information extraction processing on the third text input by the model and output the corresponding first event information text; the third text is a sentence text; When the first event information text is not empty, it is composed of a first event trigger word, a first event type and a first event element set; the first event element set includes a plurality of first event elements; The first event element includes a first element type and a first element object; The first data set includes a plurality of first data records; the first data record includes a first training text, a first comparison text sequence and a first label index; the first comparison text sequence includes a plurality of first comparison texts; when the first label index is empty, it means that all the first comparison texts in the first comparison text sequence are irrelevant to the first training text; when the first label index is not empty, it means that the first comparison text in the first comparison text sequence whose sequence index matches the first label index has the greatest correlation with the first training text; The second data set includes multiple second data records; the second data records include a second training text and a first label event information text; the first label event information text consists of a first label event trigger word, a first label event type and a first label event element set; the first label event element set includes multiple first label event elements; the first label event element includes a first label element type and a first label element object.

3. The event extraction method based on context enhancement according to claim 2 is characterized in that: The large language model input end of the first large language model is used to receive the corresponding first input text, and the large language model output end is used to output the corresponding first generated text; The internal model component of the first large language model at least includes a first word embedding encoding module, a first feature extraction module and a first text generation module; the input end of the first word embedding encoding module is connected to the input end of the large language model, and the output end is connected to the input end of the first feature extraction module; the output end of the first feature extraction module is connected to the input end of the first text generation module; the output end of the first text generation module is connected to the output end of the large language model; The first word embedding encoding module is used to perform word segmentation processing on the first input text to obtain a corresponding first word segmentation text sequence; and based on a preset word embedding encoding model, each first word segmentation text of the first word segmentation text sequence is subjected to word embedding encoding processing to obtain a corresponding first word segmentation encoding vector and send it to the first feature extraction module; the first word segmentation text sequence is formed by sequentially sorting a plurality of the first word segmentation texts; the word embedding encoding model at least includes an N-gram encoding model and a Word2Vec encoding model; the first word segmentation encoding vector is formed by sequentially sorting a plurality of first word segmentation encodings, and the first word segmentation encoding corresponds to the first word segmentation text in one-to-one correspondence; The first feature extraction module is implemented based on the Encoder or Decoder module of the Transformer model; the first feature extraction module is used to perform deep learning encoding on the associated features of each word segmentation code and other word segmentation codes in the first word segmentation code vector to obtain a corresponding first text feature vector and send it to the first text generation module; the first text feature vector is composed of multiple first text features, and the first text features correspond to the first word segmentation text one by one; The first text generation module is implemented based on a type of text generator model; it is used to perform feature decoding and text generation processing according to the first text feature vector to obtain the corresponding first generated text and output it.

4. The event extraction method based on context enhancement according to claim 2 is characterized in that: The first retrieval model input end of the text retrieval model is used to receive the corresponding first text, the second retrieval model input end is used to receive the corresponding second text sequence, and the retrieval model output end is used to output the corresponding first retrieval text; The internal model components of the text retrieval model at least include a first MLP module, a second MLP stacking module, a similarity comparison module and a text screening module; the input end of the first MLP module is connected to the input end of the first retrieval model, and the output end is connected to the first input end of the similarity comparison module; the input end of the second MLP stacking module is connected to the input end of the second retrieval model, and the output end is connected to the second input end of the similarity comparison module; the output end of the similarity comparison module is connected to the first input end of the text screening module; the second input end of the text screening module is connected to the input end of the second retrieval model, and the output end is connected to the output end of the retrieval model; The first MLP module is implemented based on the MLP model structure; the first MLP module is used to extract text features from the first text to obtain a corresponding first text feature vector and send it to the similarity comparison module; The second MLP stacking module is composed of a plurality of parallel second MLP modules, and the second MLP modules correspond to the second texts one by one; each second MLP module is implemented based on the MLP model structure; the second MLP stacking module is used to count the total number of texts in the second text sequence to obtain the corresponding total number of texts N; Dynamically stack N parallel second MLP modules, and create a one-to-one correspondence between the second MLP modules and the second texts of the second text sequence; each second MLP module extracts text features from the corresponding second text to obtain a corresponding second text feature vector; and sorts all the obtained second text feature vectors according to the text sorting order of the second text sequence to form a corresponding second text feature vector sequence and sends it to the similarity comparison module; The similarity comparison module is used to calculate the vector similarity between the first text feature vector and each of the second text feature vectors in the second text feature vector sequence according to the cosine vector similarity algorithm to obtain the corresponding first similarity; and use the first similarity with the highest similarity as the corresponding maximum similarity; and identify whether the maximum similarity exceeds a preset similarity threshold; if the maximum similarity exceeds the similarity threshold, extract the sorting index of the second text feature vector corresponding to the maximum similarity in the second text feature vector sequence as the corresponding first sorting index; if the maximum similarity does not exceed the similarity threshold, set the corresponding first sorting index to empty; and send the obtained first sorting index to the text screening module; The text screening module is used to identify whether the first sorting index is empty; if the first sorting index is not empty, extract the second text corresponding to the first sorting index in the second text sequence as the corresponding first search text; If the first sorting index is empty, the corresponding first search text is set to be empty; and the obtained first search text is output.

5. The event extraction method based on context enhancement according to claim 3 is characterized in that: The extraction model input end of the event extraction model is used to receive the corresponding third text, and the extraction model output end is used to output the corresponding first event information text; The internal model components of the event extraction model at least include the first word embedding encoding module, the first feature extraction module, the first trigger word prediction module, the first event type prediction module, the first event element labeling module and the first event information fusion module; The input end of the first word embedding encoding module is connected to the input end of the extraction model, and the first and second output ends are respectively connected to the input end of the first feature extraction module and the third input end of the first event information fusion module; the first, second and third output ends of the first feature extraction module are respectively connected to the input end of the first trigger word prediction module, the second input end of the first event type prediction module and the input end of the first event element labeling module; the output end of the first trigger word prediction module is connected to the first input end of the first event type prediction module; the output end of the first event type prediction module is connected to the first input end of the first event information fusion module; the output end of the first event element labeling module is connected to the second input end of the first event information fusion module; the output end of the first event information fusion module is connected to the output end of the extraction model; The first word embedding encoding module is used to perform word segmentation processing on the third text to obtain a corresponding second word segmentation text sequence and send it to the first event information fusion module; and based on the word embedding encoding model, each second word segmentation text of the second word segmentation text sequence is subjected to word embedding encoding processing to obtain a corresponding second word segmentation encoding vector and send it to the first feature extraction module; the second word segmentation text sequence is formed by sequentially sorting a plurality of second word segmentation texts; the second word segmentation encoding vector is formed by sequentially sorting a plurality of second word segmentation encodings, and the second word segmentation encoding corresponds to the second word segmentation text in one-to-one correspondence; The first feature extraction module is used to perform deep learning encoding on the associated features of each word segmentation code and other word segmentation codes in the second word segmentation code vector to obtain a corresponding second text feature vector and send it to the first trigger word prediction module, the first event type prediction module and the first event element labeling module respectively; the second text feature vector is composed of multiple second text features, and the second text features correspond to the second word segmentation text one by one; The first trigger word prediction module is implemented based on a type of neural network classifier; the first trigger word prediction module is used to perform corresponding event trigger word probability prediction processing according to the second text feature vector to obtain a corresponding first trigger word prediction vector and send it to the first event type prediction module; the neural network classifier at least includes a classifier model implemented based on an MLP model, a classifier model implemented based on a CNN model, and a classifier model implemented based on an RNN model; the first trigger word prediction vector is composed of multiple first trigger word prediction probabilities; the first trigger word prediction probability corresponds to the second word segmentation text one by one; the first trigger word prediction probability is the prediction probability that the corresponding second word segmentation text is identified as an event trigger word; The first event type prediction module is used to perform feature fusion processing on the first trigger word prediction vector and the second text feature vector to obtain a corresponding first text fusion feature vector; and based on another type of the neural network classifier, perform corresponding event type classification prediction processing on the first word segmentation fusion feature vector to obtain a corresponding first event type prediction vector; and record the first trigger word prediction probability with the largest probability value in the first trigger word prediction vector as the corresponding maximum trigger word prediction probability; and identify whether the maximum trigger word prediction probability exceeds a preset trigger word prediction probability threshold; if the maximum trigger word prediction probability exceeds the trigger word prediction probability threshold, the sorted index in the first trigger word prediction vector is extracted as the corresponding first trigger word index; if the maximum trigger word prediction probability does not exceed the trigger word prediction probability threshold, the corresponding first trigger word index is set to empty; and taking the first event type prediction probability with the largest probability in the first event type prediction vector as the corresponding maximum event type prediction probability; and identifying whether the maximum event type prediction probability exceeds a preset event type prediction probability threshold; if the maximum event type prediction probability exceeds the event type prediction probability threshold, taking the event type corresponding to the maximum event type prediction probability as the corresponding first event type; if the maximum event type prediction probability does not exceed the event type prediction probability threshold, setting the corresponding first event type to empty; The obtained first trigger word index and the first event type are sent to the first event information fusion module; the first text fusion feature vector is formed by sequentially sorting a plurality of first text fusion features, the first text fusion features correspond to the second word segmentation texts one by one, and each of the first text fusion features is formed by splicing the corresponding first trigger word prediction probability and the second text feature in a data vector splicing manner; the first event type prediction vector is composed of a plurality of the first event type prediction probabilities; each of the first event type prediction probabilities corresponds to a class of the event type; The first event element labeling module is implemented based on a conditional random field model; the first event element labeling module is used to perform corresponding event element labeling processing according to the second text feature vector to obtain a corresponding first labeling label vector and send it to the first event information fusion module; the first labeling label vector is formed by sequentially sorting a plurality of first labeling labels, and the first labeling label corresponds to the second word segmentation text one by one; the first labeling label is the event element label of the corresponding second word segmentation text; the label type of the first labeling label includes multiple categories of B-event element labels, multiple categories of I-event element labels and O labels; each category of the B-event element label or the I-event element label corresponds to a specified event element type; the second word segmentation text corresponding to each of the B-event element labels is the starting word segmentation of the element object text corresponding to a category of the event element type, and the second word segmentation text corresponding to each of the I-event element labels is the middle word segmentation of the element object text corresponding to a category of event element type event element type; the second word segmentation text corresponding to each of the O labels is a word segmentation that cannot correspond to any of the event element types; The first event information fusion module is used to identify the first trigger word index and the first event type; if the first trigger word index is empty or the first event type is empty, the corresponding first event information text is set to be empty; if both the first trigger word index and the first event type are not empty, the second segmented word text corresponding to the first trigger word index in the second segmented word text sequence is used as the corresponding first event trigger word, and the first element subset corresponding to the first event type in the preset event element set is used as the corresponding current element subset, and each of the event element types in the current element subset is used as a corresponding first element type, and the first annotation label in the first annotation label vector that does not correspond to all the first element types is reset to the O label, and the element objects corresponding to each of the first element types are extracted and processed according to the reset first annotation label vector and the second segmented word text sequence to obtain the corresponding first element object, and each of the first element types and the corresponding first element object is composed of a corresponding first event element, and all the obtained first event elements are composed of a corresponding first event element set, and the obtained first event trigger word, the first event type and the first event element set are composed of the corresponding first event information text; And output the first event information text obtained this time; wherein, the event element set includes multiple first element subsets, each of the first element subsets corresponds to a class of the event type; the first element subset consists of one or more event element types.

6. The event extraction method based on context enhancement according to claim 5 is characterized in that: The extracting and processing the element objects corresponding to each of the first element types according to the reset first annotation label vector and the second segmented text sequence to obtain the corresponding first element objects specifically includes: Step 61, the first event information fusion module records the first second segmented word text of the second segmented word text sequence as the corresponding current segmented word text; Step 62, and record the first annotation label corresponding to the current segmentation text in the first annotation label vector as the corresponding current annotation label; and identify the current annotation label; if the current annotation label is the B-event element label, initialize a corresponding empty sequence for the first element type corresponding to the current annotation label as the corresponding first object segmentation sequence, and add the current segmentation text to the first object segmentation sequence created this time; if the current annotation label is the I-event element label, add the current segmentation text to the first object segmentation sequence corresponding to the first element type corresponding to the current annotation label; Wherein, the first object segmentation sequence corresponds one-to-one to the first element type; Step 63, identifying whether the current segmented text is the last second segmented text in the second segmented text sequence; if so, going to step 64; if not, taking the next second segmented text in the second segmented text sequence as the new current segmented text and going back to step 62; Step 64, sequentially concatenate all the second segmented word texts in each of the first object segmented word sequences to obtain a corresponding first concatenated text; and use the first concatenated text corresponding to each of the first element types as the corresponding first element object.

7. The event extraction method based on context enhancement according to claim 2 is characterized in that: The text generation task processing capability based on the first language model creates corresponding model training data sets for the text retrieval model and the event extraction model, which are recorded as corresponding first data sets and second data sets, and specifically include: Step 71, initialize the first counter to 0; and increment the counter from 2 to the preset sentence total threshold n. amax The integer value range between is used as the corresponding value range R; and the first positive and negative sample states are initialized as positive sample states; Wherein, the value range R is [2,n amax ], the total number of sentences threshold n amax is an integer greater than 2; the first positive and negative sample states include a positive sample state and a negative sample state; Step 72, randomly selecting an integer in the value range R as the corresponding first sentence total number; bringing the first specific knowledge domain, the first sentence total number and the first positive and negative sample states into a preset first record generation instruction template to perform instruction text splicing to obtain a corresponding first instruction text; inputting the first instruction text into the first large language model to perform corresponding record text generation processing to obtain a corresponding first record text; and extracting the corresponding first training text, the first comparison text sequence and the first label index from the first record text to form a corresponding first data record; Where 2≤the total number of the first sentence≤the total number of sentences threshold n amax ; The first record generation instruction template is a formatted text configuration template; the first record generation instruction template is used to take the first specific knowledge domain, the first total number of sentences and the first positive and negative sample states as the corresponding current knowledge domain, the current total number of comparison texts n c and the current positive and negative sample states; and inform the first language model through a preset narrative text to generate a creative sentence based on the current knowledge field as the corresponding first training text, and to generate the total number of current comparison texts n based on the current knowledge field c The creative sentences of the first comparison text sequence are composed of the first comparison text sequence, and when the current positive and negative sample state is a negative sample state, each of the first comparison texts in the first comparison text sequence is required to be irrelevant to the first training text and the corresponding first label index is set to be empty, and when the current positive and negative sample state is a positive sample state, at least one of the first comparison texts in the first comparison text sequence is required to be relevant to the first training text and the sequence index of the first comparison text with the highest correlation with the first training text in the first comparison text sequence is used as the corresponding first label index, and the first training text, the first comparison text sequence and the first label index are obtained to form the corresponding first record text and output it; Step 73, identifying whether the first counter exceeds a preset first counting threshold; if the first counter does not exceed the first counting threshold, randomly selecting one of the positive sample state and the negative sample state to reset the first positive and negative sample state; if the first counter exceeds the first counting threshold, statistically analyzing the positive and negative sample ratios of the first data record that has been generated to obtain the corresponding first positive and negative sample ratios, and identifying whether the first positive and negative sample ratio exceeds a preset first positive and negative sample ratio threshold, if so, resetting the first positive and negative sample state to a negative sample state, if not, resetting the first positive and negative sample state to a positive sample state; The first positive-negative sample ratio is a ratio of the total number of the first data records in which the first positive-negative sample state is a positive sample state to the total number of the first data records in which the first positive-negative sample state is a negative sample state; Step 74, adding 1 to the first counter; and identifying whether the first counter after adding 1 exceeds a preset first record total threshold; if not, returning to step 72; if so, forming the corresponding first data set from all the first data records obtained and going to step 75; Step 75, initializing the second counter to 0; and initializing the first event text attribute to descriptive text; Wherein, the first event text attributes include descriptive text, action text and position text; Step 76, bringing the first specific knowledge domain and the first event text attribute into a preset second record generation instruction template to perform instruction text splicing to obtain a corresponding second instruction text; and inputting the second instruction text into the first large language model to perform corresponding record text generation processing to obtain a corresponding second record text; and extracting the corresponding second training text and the first label event information text from the second record text to form a corresponding second data record; Wherein, the second record generation instruction template is a formatted text configuration template; the second record generation instruction template is used to take the first specific knowledge domain and the first event text attribute as the corresponding current knowledge domain and current text attribute; and inform the first large language model through a preset narrative text to randomly select a type of event type from all event types in the current knowledge domain as the corresponding current event type, and generate a creative event information text based on the current event type as the corresponding first label event information text, and randomly generate a creative sentence matching the current text attribute based on the first label event information text as the corresponding second training text, and the corresponding second record text is composed of the obtained second training text and the first label event information text and output, and the first label event information text is required to be composed of the first label event trigger word, the first label event type and the first label event element set, and the first label event element set is required to be composed of one or more of the first label event elements, and the first label event element is required to be composed of the first label element type and the first label element object; Step 77, identifying whether the second counter exceeds a preset second counting threshold; if the second counter does not exceed the second counting threshold, randomly selecting one of the descriptive text, the action text and the positional text to reset the first event text attribute; if the second counter exceeds the second counting threshold, the descriptive text, the action text and the positional text ratios of the first data record that have been generated are counted to obtain the corresponding first, second and third ratios, and the first event text attribute is reset based on the descriptive text, the action text or the positional text corresponding to the minimum ratio among the first, second and third ratios; The first ratio is the ratio of the total number of the first data records whose first event text attribute is descriptive text to the total number of all the first data records that have been generated; the second ratio is the ratio of the total number of the first data records whose first event text attribute is action text to the total number of all the first data records that have been generated; the third ratio is the ratio of the total number of the first data records whose first event text attribute is positional text to the total number of all the first data records that have been generated; Step 78, adding 1 to the second counter; and identifying whether the second counter after adding 1 exceeds the preset second record total threshold; if not, returning to step 76; if so, all the obtained second data records form the corresponding second data set.

8. The event extraction method based on context enhancement according to claim 2, characterized in that: The training of the text retrieval model based on the first data set specifically includes: Step 81, dividing the first data set into sub-datasets based on a preset first segmentation ratio to obtain a corresponding first training set and a first evaluation set; Wherein, both the first training set and the first evaluation set are composed of a plurality of the first data records; the ratio of the total number of records in the first training set to the total number of records in the first evaluation set satisfies the first segmentation ratio; Step 82, taking the first first data record of the first training set as the corresponding current training record; Step 83, taking the first training text, the first comparison text sequence and the first label index of the current training record as the corresponding current training text, the current comparison text sequence and the current label index; Step 84, inputting the current training text and the current comparison text sequence into the text retrieval model, and having the text retrieval model perform associated text retrieval processing on the current comparison text sequence input into the model according to the current training text input into the model, and using the retrieval text output by the text retrieval model as the corresponding current predicted text; Step 85, whether the current predicted text is one of the first compared texts in the current compared text sequence is identified; if so, the sequence index of the current predicted text in the current compared text sequence is extracted as the corresponding current predicted index; if not, the corresponding current predicted index is set to empty; and two all-zero vectors whose lengths are consistent with the total number of compared texts in the current compared text sequence are initialized as the corresponding first predicted vector and first label vector; and when the current predicted index is not empty, the vector data corresponding to the vector sorting index and the current predicted index in the first predicted vector is reset to 1; and when the current label index is not empty, the vector data corresponding to the vector sorting index and the current label index in the first label vector is reset to 1; The first prediction vector and the first label vector are both formed by sequentially sorting a plurality of vector data; when the first prediction vector and the first label vector are initialized, all vector data inside each of them is 0; Step 86: Substitute the first prediction vector and the first label vector into a preset first model loss function L M1 ; and based on the preset first model optimizer, move towards making the first model loss function L M1 Performing a round of optimization on the model parameters of the first MLP module and all the second MLP modules of the text retrieval model in the direction of reaching the minimum value; Among them, the first model loss function L M1 for: v pre is the first prediction vector, v tag is the first label vector; The first model optimizer includes at least an SGD optimizer and an ADAM optimizer; Step 87, identifying whether the current training record is the last first data record of the first training set; if so, going to step 88; if not, extracting the next first data record of the first training set as the new current training record and returning to step 83; Step 88, perform a round of traversal on all the first data records of the first evaluation set; and in this round of traversal, use the first data record currently traversed as the corresponding current evaluation record; and use the first training text, the first comparison text sequence and the first label index of the current evaluation record as the corresponding current training text, the current comparison text sequence and the current label index; and input the current training text and the current comparison text sequence into the text retrieval model, and the text retrieval model performs associated text retrieval processing on the current comparison text sequence input into the model according to the current training text input into the model, and use the retrieval text output by the text retrieval model as the corresponding current predicted text; and identify whether the current predicted text is one of the first comparison texts in the current comparison text sequence, and if so, extract the sequence index of the current predicted text in the current comparison text sequence as the corresponding current prediction index, and if not, set the corresponding current prediction The index is empty; and two all-zero vectors whose lengths are consistent with the total number of comparison texts of the current comparison text sequence are initialized as the corresponding second prediction vector and second label vector; and when the current prediction index is not empty, the vector data corresponding to the vector sorting index and the current prediction index in the second prediction vector is reset to 1; and when the current label index is not empty, the vector data corresponding to the vector sorting index and the current label index in the second label vector is reset to 1; and the second prediction vector and the second label vector corresponding to the current evaluation record form a corresponding first prediction-label pair; and at the end of this round of traversal, a confusion matrix A is constructed based on the construction principle of the confusion matrix according to all the first prediction-label pairs obtained; and based on the confusion matrix A, the corresponding accuracy, precision and recall statistics are performed to obtain the corresponding first accuracy, first precision and first recall; and based on the first precision and the first recall, the corresponding F1 score is calculated to obtain the corresponding first F1 score; Step 89, identifying the first accuracy rate and the first F1 score obtained this time; if the first accuracy rate does not meet the preset first accuracy rate range or the first F1 score does not meet the preset first F1 score range, returning to step 82 to continue training; if the first accuracy rate meets the first accuracy rate range and the first F1 score meets the first F1 score range, stopping training and confirming the completion of text retrieval model training.

9. The event extraction method based on context enhancement according to claim 2, characterized in that: The training of the event extraction model based on the second data set specifically includes: Step 91, dividing the second data set into sub-data sets based on a preset second segmentation ratio to obtain corresponding second training sets and second evaluation sets; Wherein, both the second training set and the second evaluation set are composed of a plurality of the second data records; the ratio of the total number of records in the second training set to the total number of records in the second evaluation set satisfies the second segmentation ratio; Step 92, taking the first second data record of the second training set as the corresponding current training record; Step 93, taking the second training text and the first label event information text of the current training record as the corresponding current training text and current label event information text; Step 94, inputting the current training text into the event extraction model, allowing the event extraction model to extract event information from the current training text input into the model, and using the event information text output by the event extraction model as the corresponding current predicted event information text; Step 95: Substitute the current predicted event information text and the current label event information text into the preset second model loss function L M2 ; and based on the preset second model optimizer, move towards making the second model loss function L M2 Performing a round of optimization on the model parameters of the first trigger word prediction module, the first event type prediction module, and the first event element labeling module of the event extraction model in the direction of reaching the minimum value; Among them, the second model loss function L M2 for: is the trigger word text N-gram encoding vector of the first event trigger word of the current predicted event information text. If the first event trigger word of the current predicted event information text is empty, the corresponding encoding vector is set to an all-zero vector; is the trigger word text N-gram encoding vector of the first tag event trigger word of the current tag event information text. If the first tag event trigger word of the current tag event information text is empty, the corresponding encoding vector is set to an all-zero vector; The encoding vector The vector lengths of the first event trigger word and the first label event trigger word in the current predicted event information text and the current label event information text are inconsistent, the encoding vector is padded with zeros to make the encoding vector shorter. The vector length of is consistent; An event type one-hot encoding vector of the first event type of the current predicted event information text; The event type one-hot encoding vector of the first label event type of the current label event information text; the one-hot encoding vector The vector lengths of are consistent, and are composed of multiple event type one-hot encodings, each of which corresponds to a class of event types, and the total number of event type one-hot encodings is consistent with the preset total number of event types; the one-hot encoding vector In the one-hot encoding vector, only the event type corresponding to the first event type of the current predicted event information text is one-hot encoded as 1, and all other event types are one-hot encoded as 0; Only the event type corresponding to the first label event type of the current label event information text is one-hot encoded as 1, and all other event types are one-hot encoded as 0; M is the total number of types of the statistical type set G, and the total number of types of statistics M is a positive integer; the statistical type set G is the statistical result obtained by performing type statistics on the element types of all event elements in the current predicted event information text and the current label event information text, and the statistical type set G consists of M types of statistical types g i Composition, each of the statistical types g i The element type corresponding to a class of event elements; 1≤type index i≤M; The first element type and the statistic type g of the i-th category in the current prediction event information text i The object text N-gram encoding vector of the first element object of the first event element that matches, if the current predicted event information text does not contain a statistical type g of the i-th category i The first element type that matches the corresponding encoding vector is set to an all-zero vector; The first tag element type and the statistic type g of the i-th category in the current tag event information text i The object text N-gram encoding vector of the first tag element object of the first tag event element that matches, if the current tag event information text does not contain a statistical type g of the i-th category i The encoding vector corresponding to the first tag element type that matches is set to an all-zero vector; The encoding vector The vector length should be consistent. If the current predicted event information text and the current label event information text have the same statistical type g as the i-th category i If the object text lengths of the first element object and the first tag element object are inconsistent, the encoding vector with the shorter length is padded with zeros to make the encoding vector The vector length of is consistent; The second model optimizer includes at least an SGD optimizer and an ADAM optimizer; Step 96, identifying whether the current training record is the last second data record of the second training set; if so, going to step 97; if not, extracting the next second data record of the second training set as the new current training record and returning to step 93; Step 97, perform a round of traversal on all the second data records of the second evaluation set; and in this round of traversal, use the second data record currently traversed as the corresponding current evaluation record; and use the second training text and the first label event information text of the current evaluation record as the corresponding current training text and current label event information text; and input the current training text into the event extraction model, and the event extraction model performs event information extraction processing on the current training text input into the model, and use the event information text output by the event extraction model as the corresponding current predicted event information text; and form a corresponding second prediction-label pair with the current predicted event information text and the corresponding current label event information text; and at the end of this round of traversal, bring all the obtained second prediction-label pairs into the preset model evaluation function F A Performing an evaluation value calculation to obtain a corresponding first evaluation value; The model evaluation function F A for: n a is the total number of the second prediction-label pairs, 1≤indexj≤n a ; f er () is MAE error function or MSE error function; The trigger word text N-gram encoding vector corresponding to the first event trigger word of the predicted event information text of the jth second prediction-label pair; is the N-gram encoding vector of the trigger word text of the first label event trigger word of the label event information text of the jth second prediction-label pair; a pair of encoding vectors corresponding to each second prediction-label pair The vector lengths of should be consistent. If a pair of encoding vectors If the lengths of the vectors are inconsistent, the shorter encoding vector is padded with zeros to make the lengths of the two vectors consistent; is the event type one-hot encoding vector of the first event type of the predicted event information text of the j-th second prediction-label pair; is the event type one-hot encoding vector of the first label event type of the label event information text of the jth second prediction-label pair; a pair of one-hot encoding vectors corresponding to each second prediction-label pair The vector lengths of are consistent; M j is the statistical type set G of the jth second prediction-label pair j The total number of species statistics, the total number of species statistics M j is a positive integer; the statistical type set G j is a statistical result obtained by performing type statistics on the element types of all event elements in the predicted event information text and the label event information text of the jth second prediction-label pair, wherein the statistical type set G j By M j Class statistic type g j,k Composition, each of the statistical types g j,k The element type corresponding to a class of event elements; in each of the statistical type sets G j , 1≤type index k≤M j ; The first element type and the corresponding statistical type set G in the predicted event information text of the jth second prediction-label pair j The statistical type g in the kth category j,k an object text N-gram encoding vector of the first element object of the matched first event element; The first label element type and the corresponding statistical type set G in the label event information text of the jth second prediction-label pair j The statistical type g described in the kth category j,k the object text N-gram encoding vector of the first tag element object of the matched first tag event element; Each of the second prediction-label pairs corresponds to a pair of encoding vectors The vector length should be consistent. If a pair of the encoding vector If the lengths of the vectors are inconsistent, the shorter encoding vector is padded with zeros to make the lengths of the two vectors consistent; Step 98, identifying whether the first evaluation value satisfies a preset first evaluation value range; if not, returning to step 92 to continue training; if satisfied, stopping training and confirming that the event extraction model training is completed.

10. A device for executing the context-enhanced event extraction method according to any one of claims 1 to 9, characterized in that: The device comprises: a model building module, a model training module, a text receiving module, a text sentence segmentation module, a context enhancement module, an event extraction module and an event feedback module; The model building module is used to select a class of large language models as the corresponding first large language model; and to build a text retrieval model for text retrieval; and to add trigger word prediction, event type prediction, event element annotation and event information fusion components related to event extraction on the basis of the feature extraction component of the first large language model to form an event extraction model for event information extraction; The model training module is used to create corresponding model training data sets for the text retrieval model and the event extraction model based on the text generation task processing capability of the first large language model, recorded as corresponding first data sets and second data sets; and train the text retrieval model based on the first data set; and train the event extraction model based on the second data set; The text receiving module is used to receive the user's input text as the corresponding current user text after the model training is completed; The text sentence segmentation module is used to perform text sentence segmentation processing on the current user text to obtain a corresponding sentence text sequence; the sentence text sequence is formed by sequentially sorting a plurality of sentence texts; The context enhancement module is used to take each of the sentence texts as the corresponding current text; and to form a corresponding other text sequence from all the sentence texts in the sentence text sequence except the current text; and to input the current text and the corresponding other text sequence into the text retrieval model to perform text retrieval to obtain the corresponding current retrieval text; and to perform text splicing on the current text and the corresponding current retrieval text to obtain a corresponding context enhanced text; The event extraction module is used to perform deduplication processing on all the context-enhanced texts obtained; and input each of the deduplicated context-enhanced texts into the event extraction model to perform event information extraction processing to obtain corresponding event information texts; The event feedback module is used to form a corresponding event extraction record from each event information text, the corresponding sentence text and the context enhanced text; and to form a corresponding extraction record sequence from all the obtained event extraction records to provide feedback to the user.

11. An electronic device, characterized in that: include: memory, processors, and transceivers; The processor is used to couple with the memory, read and execute instructions in the memory, so as to implement the method according to any one of claims 1 to 9; The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a computer, the computer is enabled to execute the method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Event extraction method and device based on vocabulary enhancement and storage medium

    CN114330354A

  • Knowledge acquisition method based on neural symbol mixed retrieval enhancement

    CN115757820A

  • Video text retrieval method, electronic equipment and medium

    CN116737995A

  • Domain knowledge graph automatic construction method based on large language model and prompt project

    CN117035076A

  • Event extraction method, device and system based on multi-source annotation

    CN117874232A

Cited By

  • ETL configuration method and system based on natural language processing

    CN120561176A