Joint extraction model training method and device
Through the joint extraction model training method, the text information extraction process is simplified, the problems of complex extraction process and high resource consumption in the existing technology are solved, and efficient information and event extraction is achieved.
Patent Information
- Application Number
- CN202011173230.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-28
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2040-10-28
AI Technical Summary
In the prior art, deep learning models are used for text information extraction process complex, time-consuming, and require a large amount of computing resources and occupy a lot of memory, lacking simple, convenient and efficient methods.
A joint extraction model training method is proposed. By obtaining the sample text and tag group, inputting the coding layer and prediction layer of the joint extraction model, performing feature representation and determination of prediction head entities, compute the loss value in combination with the prediction group and tag group, and performing model training based on the loss value.
The simplified text information extraction process is realized, which reduces computing resource consumption and memory usage, improves the extraction efficiency, and can realize both information extraction and event extraction.
Smart Images

Figure CN114416932B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of natural language processing technology, and in particular to a joint extraction model training method and device. Background Art
[0002] With the popularization and development of the Internet, the scale of data in the network has grown explosively. Most of this data is in unstructured form, and manual management and effective utilization are very time-consuming and labor-intensive. Therefore, how to accurately find the required information from massive data has become a problem that needs to be solved urgently.
[0003] In the prior art, the required information in the text can be extracted through a deep learning model. Specifically, the entities of the argument roles in the text and the relationships between entities in the text can be extracted through multiple deep learning models, thereby obtaining the required information in the text.
[0004] However, the above method is complicated and time-consuming; in addition, deep learning models generally require a lot of computing resources and occupy a lot of memory, so a simpler, more convenient and efficient method is needed to extract the required information from the text. Summary of the invention
[0005] In view of this, the embodiment of this specification provides a joint extraction model training method. This specification also relates to a joint extraction model training device, a computing device, and a computer-readable storage medium to solve the technical defects existing in the prior art.
[0006] According to a first aspect of an embodiment of this specification, a joint extraction model training method is provided, including:
[0007] Acquire a sample text and a tag group, wherein the tag group is used to characterize the relationship between entities in the sample text, the entities include named entities and trigger words in the sample text, and the trigger words are used to characterize the behavior in the sample text;
[0008] Input the sample text into the encoding layer of the joint extraction model to obtain a feature representation vector group of the sample text, and input the feature representation vector group of the sample text into the first prediction layer of the joint extraction model to obtain a predicted header entity;
[0009] Acquire a feature representation vector group of the predicted header entity, and simultaneously input the feature representation vector group of the predicted header entity and the feature representation vector group of the sample text into the second prediction layer of the joint extraction model to obtain a prediction group;
[0010] Determining a loss value based on the prediction group and the label group;
[0011] The joint extraction model is trained based on the loss value until a training stop condition is reached.
[0012] Optionally, obtaining the sample text and the tag group includes:
[0013] Acquire multiple sample texts and labels of each sample text from a corpus, wherein the corpus includes an event extraction corpus and an information extraction corpus;
[0014] A label group for each sample text is determined based on the label for each sample text.
[0015] Optionally, if the sample text is obtained from a corpus extracted from the event, the label of the sample text includes a trigger word, an argument role, and an entity corresponding to the argument role, and determining the label group of each sample text based on the label of each sample text includes:
[0016] The trigger words, argument roles, and entities corresponding to the argument roles in the labels of the sample text are determined as a label group.
[0017] Optionally, if the sample text is obtained from the corpus of the information extraction, the label of the sample text includes a triple, and the triple is used to characterize the relationship between entities in the sample text, and determining the label group of each sample text based on the label of each sample text includes:
[0018] The label of the sample text is determined as a label group of the sample text.
[0019] Optionally, the feature representation vector group of the sample text includes a feature vector of each word unit in the sample text, and the step of inputting the feature representation vector group of the sample text into the first prediction layer of the joint extraction model to obtain a predicted header entity includes:
[0020] Based on the feature representation vector group of the sample text, determine the probability that the word unit corresponding to each feature vector in the feature representation vector group is the starting position of the predicted head entity and the probability that the word unit corresponding to each feature vector is the ending position of the predicted head entity;
[0021] The predicted head entity is determined based on the probability that the word unit corresponding to each feature vector is the starting position of the predicted head entity and the probability that the word unit corresponding to each feature vector is the ending position of the predicted head entity, wherein the predicted head entity is obtained from the entity in the sample text.
[0022] Optionally, the step of simultaneously inputting the feature representation vector group of the predicted header entity and the feature representation vector group of the sample text into the second prediction layer of the joint extraction model to obtain the prediction group includes:
[0023] Concatenating the feature representation vector group of the predicted header entity with the feature representation vector group of the sample text to obtain a concatenated feature representation vector group;
[0024] Based on the concatenated feature representation vector group, the prediction tail entity associated with the prediction head entity and the relationship between the prediction head entity and the prediction tail entity are determined to obtain the prediction group, wherein the prediction group includes the prediction head entity, the prediction tail entity associated with the prediction head entity, and the relationship between the prediction head entity and the prediction tail entity.
[0025] Optionally, the feature representation vector group of the predicted head entity includes a feature vector of each word unit in the predicted head entity, and determining the predicted tail entity associated with the predicted head entity based on the concatenated feature representation vector group includes:
[0026] Based on the concatenated feature representation vector group, determining the probability that the word unit corresponding to each feature vector is the starting position of the predicted tail entity corresponding to the predicted head entity and the probability that the word unit corresponding to each feature vector is the ending position of the predicted tail entity corresponding to the predicted head entity;
[0027] The predicted tail entity is determined based on the probability that the word unit corresponding to each feature vector is the starting position of the predicted tail entity corresponding to the predicted head entity and the probability that the word unit corresponding to each feature vector is the ending position of the predicted tail entity corresponding to the predicted head entity.
[0028] Optionally, the training the joint extraction model based on the loss value until a training stop condition is reached includes:
[0029] If the loss value is greater than or equal to a preset threshold, continue training the joint extraction model;
[0030] If the loss value is less than the preset threshold, the training is stopped.
[0031] According to a second aspect of an embodiment of this specification, a joint extraction method is provided, the method comprising:
[0032] Get the text to be extracted;
[0033] Input the text to be extracted into the encoding layer of the joint extraction model to obtain a feature representation vector group of the text to be extracted, and input the feature representation vector group of the text to be extracted into the first prediction layer of the joint extraction model to determine the head entity in the text to be extracted, wherein the joint extraction model is trained by the joint extraction model training method described in the first aspect above;
[0034] The feature representation vector group of the head entity is obtained, and the feature representation vector group of the head entity and the feature representation vector group of the text to be extracted are simultaneously input into the second prediction layer of the joint extraction model to obtain the extraction result of the text to be extracted.
[0035] According to a third aspect of an embodiment of this specification, a joint extraction model training device is provided, including:
[0036] A first acquisition module is used to acquire sample text and a tag group, wherein the tag group is used to characterize the relationship between entities in the sample text, the entities include named entities and trigger words in the sample text, and the trigger words are used to characterize the behavior in the sample text;
[0037] A first prediction module, configured to input the sample text into the encoding layer of the joint extraction model to obtain a feature representation vector group of the sample text, and input the feature representation vector group of the sample text into the first prediction layer of the joint extraction model to obtain a predicted header entity;
[0038] A second prediction module is used to obtain a feature representation vector group of the predicted header entity, and input the feature representation vector group of the predicted header entity and the feature representation vector group of the sample text into the second prediction layer of the joint extraction model at the same time to obtain a prediction group;
[0039] A determination module, configured to determine a loss value based on the prediction group and the label group;
[0040] A training module is used to train the joint extraction model based on the loss value until a training stop condition is reached.
[0041] Optionally, the first acquisition module is used to:
[0042] Acquire multiple sample texts and labels of each sample text from a corpus, wherein the corpus includes an event extraction corpus and an information extraction corpus;
[0043] A label group for each sample text is determined based on the label for each sample text.
[0044] Optionally, the first acquisition module is used to:
[0045] If the sample text is obtained from a corpus extracted from the event, the label of the sample text includes a trigger word, an argument role, and an entity corresponding to the argument role, and the trigger word, the argument role, and the entity corresponding to the argument role in the label of the sample text are determined as a label group.
[0046] Optionally, the first acquisition module is used to:
[0047] If the sample text is obtained from the information extraction corpus, the label of the sample text includes a triple, and the triple is used to characterize the relationship between entities in the sample text, the label of the sample text is determined as the label group of the sample text.
[0048] Optionally, the first prediction module is used to:
[0049] The feature representation vector group of the sample text includes a feature vector of each word unit in the sample text, and based on the feature representation vector group of the sample text, determining the probability that the word unit corresponding to each feature vector in the feature representation vector group is the starting position of the predicted head entity and the probability that the word unit is the ending position of the predicted head entity;
[0050] The predicted head entity is determined based on the probability that the word unit corresponding to each feature vector is the starting position of the predicted head entity and the probability that the word unit is the ending position of the predicted head entity, wherein the predicted head entity is obtained from the entity in the sample text.
[0051] Optionally, the second prediction module is used to:
[0052] Concatenating the feature representation vector group of the predicted header entity with the feature representation vector group of the sample text to obtain a concatenated feature representation vector group;
[0053] Based on the concatenated feature representation vector group, the prediction tail entity associated with the prediction head entity and the relationship between the prediction head entity and the prediction tail entity are determined to obtain the prediction group, wherein the prediction group includes the prediction head entity, the prediction tail entity associated with the prediction head entity, and the relationship between the prediction head entity and the prediction tail entity.
[0054] Optionally, the second prediction module is used to:
[0055] The feature representation vector group of the prediction head entity includes a feature vector of each word unit in the prediction head entity, and based on the concatenated feature representation vector group, determining the probability of the word unit corresponding to each feature vector being the starting position of the prediction tail entity corresponding to the prediction head entity and the probability of the word unit being the ending position of the prediction tail entity corresponding to the prediction head entity;
[0056] The predicted tail entity is determined based on the probability that the word unit corresponding to each feature vector is the starting position of the predicted tail entity corresponding to the predicted head entity and the probability that the word unit is the ending position of the predicted tail entity corresponding to the predicted head entity.
[0057] Optionally, the training module is used to:
[0058] If the loss value is greater than or equal to a preset threshold, continue training the joint extraction model;
[0059] If the loss value is less than the preset threshold, the training is stopped.
[0060] According to a fourth aspect of the embodiments of this specification, a joint extraction device is provided, the device comprising:
[0061] The second acquisition module is used to acquire the text to be extracted;
[0062] A first determination module is used to input the text to be extracted into the encoding layer of the joint extraction model to obtain a feature representation vector group of the text to be extracted, and input the feature representation vector group of the text to be extracted into the first prediction layer of the joint extraction model to determine the head entity in the text to be extracted, wherein the joint extraction model is trained by the joint extraction model training method described in the first aspect above;
[0063] The second determination module is used to obtain the feature representation vector group of the head entity, and input the feature representation vector group of the head entity and the feature representation vector group of the text to be extracted into the second prediction layer of the joint extraction model at the same time to determine the extraction result of the text to be extracted.
[0064] According to a fifth aspect of an embodiment of this specification, a computing device is provided, including:
[0065] Memory and processor;
[0066] The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the steps of the joint extraction model training method described in the first aspect above, or to implement the steps of the joint extraction method described in the second aspect above.
[0067] According to the seventh aspect of the embodiments of this specification, a computer-readable storage medium is provided, which stores computer-executable instructions. When the instructions are executed by a processor, the steps of the joint extraction model training method described in the first aspect above are implemented, or the steps of the joint extraction method described in the second aspect above are implemented.
[0068] The joint extraction model training method provided in the present specification obtains sample text and a label group, wherein the label group is used to characterize the relationship between entities in the sample text, the entities include named entities and trigger words in the sample text, and the trigger words are used to characterize the behavior in the sample text; the sample text is input into the encoding layer of the joint extraction model to obtain a feature representation vector group of the sample text, and the feature representation vector group of the sample text is input into the first prediction layer of the joint extraction model to obtain a predicted head entity; the feature representation vector group of the predicted head entity is obtained, and the feature representation vector group of the predicted head entity and the feature representation vector group of the sample text are simultaneously input into the second prediction layer of the joint extraction model to obtain a prediction group; a loss value is determined based on the prediction group and the label group; and the joint extraction model is trained based on the loss value until a training stop condition is reached. When training the joint extraction model, the present specification sets the labels for event extraction and information extraction of the sample text in the label group, and trains the joint extraction model through the encoding layer, the first prediction layer and the second prediction layer, so as to obtain a joint extraction model capable of jointly extracting event extraction and information extraction. Only through the joint extraction model, information extraction and event extraction can be realized simultaneously to obtain the required information in the text. Compared with the prior art of extracting information and extracting events separately through multiple models, the consumption of computing resources and the occupation of memory resources are greatly reduced, and the extraction efficiency of the joint extraction model is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] Figure 1 is a flow chart of a joint extraction model training method provided in an embodiment of this specification;
[0070] Figure 2 It is a processing flow chart of a joint extraction model training method for joint extraction of information and events provided in an embodiment of this specification;
[0071] Figure 3 is a flow chart of a joint extraction method provided in an embodiment of this specification;
[0072] Figure 4 is a flow chart of another joint extraction method provided in an embodiment of this specification;
[0073] Figure 5 It is a structural diagram of a joint extraction model training device provided in an embodiment of this specification;
[0074] Figure 6 It is a structural schematic diagram of a combined extraction device provided in an embodiment of this specification;
[0075] Figure 7It is a structural block diagram of a computing device provided in an embodiment of this specification. DETAILED DESCRIPTION
[0076] Many specific details are described in the following description to facilitate a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of this specification, so this specification is not limited to the specific implementation disclosed below.
[0077] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0078] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "in response to determining".
[0079] First, the terms involved in one or more embodiments of this specification are explained.
[0080] Joint extraction model: a model that can realize both event extraction and information extraction.
[0081] Trigger words: words that can trigger an event to happen. They are the most important feature words in an event and can be used to represent actions in an event. They are usually verbs or nouns. For example, if the text is "A went to city B to attend a wedding today", the trigger word can be "attend".
[0082] Argument role: The role that an entity in a text plays in the event contained in the text. For example, in a meeting event, the argument role can be the meeting time, the participants, the meeting location, etc.
[0083] Event extraction: Identify trigger words in the text and determine the event type of the event contained in the text, and extract entities corresponding to the argument roles in the text based on the event type.
[0084] Event extraction includes two processes: event detection and argument role recognition. Event detection: identifying trigger words in the text, and then determining the event type of the event contained in the text; argument role recognition: extracting entities corresponding to argument roles in the text based on the argument role set.
[0085] Information extraction: extracting triplets from natural language text<e1,r,e2> , where e1 and e2 are entities identified from the text, and r represents the relationship between the two entities e1 and e2.
[0086] Information extraction includes two processes: entity recognition and relationship extraction. Entity recognition: find all named entities from the text, such as names of people, places, time, proper nouns, etc. Relationship extraction: refers to extracting pre-defined entity relationships from unstructured text based on entity recognition, that is, determining the relationship between entities.
[0087] Token: Before any actual processing is done on the input text, it needs to be segmented into language units such as characters, punctuation marks, numbers or letters. These units are called tokens. For English text, a token can be a word, a punctuation mark, a number, etc. For Chinese text, the smallest token can be a character, a punctuation mark, a number, etc.
[0088] BERT (Bidirectional Encoder Representations from Transformers) model: a bidirectional attention neural network model. The BERT model can predict the current word through the left and right contexts and predict the next sentence through the current sentence. The goal of the BERT model is to use large-scale unlabeled corpus training to obtain the semantic representation of text containing rich semantic information, and then fine-tune the semantic representation of the text in a specific NLP (Natural Language Processing) task, and finally apply it to the NLP task.
[0089] Long Short-Term Memory (LSTM) model: a time recurrent neural network suitable for processing and predicting important events with relatively long intervals and delays in time series. The LSTM model can be used to connect previous information to the current task, such as using past sentences to infer the understanding of the current sentence.
[0090] Non-linear transformation: It is to perform a non-linear transformation on the original feature to obtain a new feature. Using this new feature to perform linear classification corresponds to the original feature space, which is equivalent to performing a non-linear classification.
[0091] Accuracy P (Precision): The proportion of correctly predicted positive data to the predicted positive data.
[0092] Recall rate R (Recall): The ratio of data predicted as positive examples to actual positive examples.
[0093] F1 value: Take words as units, count the accuracy and recall between the predicted answer and the standard answer, and then calculate the F1 value using the following formula.
[0094] In this specification, a joint extraction model training method and a joint extraction method are provided. This specification also involves a joint extraction model training device, a joint extraction device, a computing device, and a computer-readable storage medium, which are described in detail one by one in the following embodiments.
[0095] Figure 1 A flowchart of a joint extraction model training method provided according to an embodiment of this specification is shown, which specifically includes the following steps:
[0096] Step S102: Obtain sample text and a tag group, wherein the tag group is used to characterize the relationship between entities in the sample text, and the entities include named entities and trigger words in the sample text, and the trigger words are used to characterize the behavior in the sample text.
[0097] The sample text is a written text containing certain information content, which can be a sentence, a paragraph, etc., and can be a text in various languages such as Chinese text, English text, French text, etc., which is not limited in the embodiment of the present application. In addition, there can be multiple sample texts.
[0098] Among them, named entities are names of people, organization names, place names, and all other entities identified by names.
[0099] The tag group may include three elements, which are two entities and the relationship between the two entities, and the number of tag groups may be multiple.
[0100] As an example, if the tag group is related to information extraction, the tag group can be a triple. For example, the tag group can be (Zhang San, position, teacher), indicating that the relationship between "Zhang San" and "teacher" is that Zhang San's position is teacher.
[0101] As another example, if the tag group is related to event extraction, the tag group is different from the triples understood by those skilled in the art. For example, the tag group can be (attendance, attendee, Zhang San), which means that in the event triggered by "attendance", the "attendee" is "Zhang San". Among them, "attendance" is the trigger word, "attendee" is the argument role, and "Zhang San" is the entity corresponding to the argument role in the text.
[0102] That is to say, for event extraction, the trigger words in the event extraction can be marked as entities, the argument roles can be marked as the relationship between entities, and the entity corresponding to the argument role in the text can be marked as another entity.
[0103] In implementation, the specific implementation of obtaining sample texts and label groups may include: obtaining multiple sample texts and labels of each sample text from a corpus, the corpus including an event extraction corpus and an information extraction corpus, and determining a label group of each sample text based on the label of each sample text.
[0104] That is to say, multiple sample texts and the label of each sample text can be obtained from the corpus corresponding to event extraction and the corpus corresponding to information extraction. Since the labels of the sample texts corresponding to event extraction and information extraction are different, it is also necessary to determine the label group of each sample text based on the label of each sample text.
[0105] In some embodiments, if the sample text is obtained from a corpus extracted from an event, the label of the sample text includes a trigger word, an argument role, and an entity corresponding to the argument role. In this case, the specific implementation of determining the label group of each sample text based on the label of each sample text may include: determining the trigger word, the argument role, and the entity corresponding to the argument role in the label of the sample text as a label group.
[0106] In order to facilitate model training, the labels of the sample texts can be converted into a form similar to triples. Therefore, for the labels of the sample texts obtained from the corpus corresponding to the event extraction, the trigger words can be marked as entities, the argument roles can be marked as relations, and the trigger words, argument roles and the entities corresponding to the argument roles can be regarded as a label group.
[0107] For example, if the sample text is "Zhang San and Li Si both participated in the sports meeting." The labels of the sample text in the corpus corresponding to the event extraction are the trigger word "participate", the participating person "Zhang San", the participating person "Li Si" and the meeting name "sports meeting". If label conversion is required, "participate" can be marked as an entity, "participating person" can be marked as a relationship, and "meeting name" can be marked as a relationship. Three labels can be obtained: (participate, participating person, Zhang San), (participate, participating person, Li Si) and (participate, meeting name, sports meeting).
[0108] In some other embodiments, if the sample text is obtained from a corpus of information extraction, the label of the sample text includes a triple, and the triple is used to characterize the relationship between entities in the sample text. In this case, determining the label group of each sample text based on the label of each sample text may include: determining the label of the sample text as the label group of the sample text.
[0109] That is to say, in the corpus corresponding to the information extraction, the label of the sample text includes multiple triplets, each triplet includes two entities and the relationship between the two entities. The label of the sample text can be directly determined as the label group of the sample text for training the joint extraction model.
[0110] Furthermore, for the sample text obtained from the corpus corresponding to the event extraction, the relationships between entities in the sample text can be manually annotated to obtain the triples of the sample text, and the labels obtained by converting the triples and the original labels of the sample text can be used as the labels of the sample text to obtain the label group of the sample text.
[0111] Similarly, for the sample text obtained from the corpus corresponding to the information extraction, the relationship between the trigger words, entities, and argument roles in the sample text can also be manually determined, and labels can be set. The label and the original label of the sample text, that is, the triplet, are used as the label of the sample text to obtain the label group of the sample text.
[0112] Step S104: input the sample text into the encoding layer of the joint extraction model to obtain a feature representation vector group of the sample text, and input the feature representation vector group of the sample text into the first prediction layer of the joint extraction model to obtain a predicted header entity.
[0113] As an example, the encoding layer of the joint model is used to encode the sample text to obtain a feature representation vector group of the sample text. The feature representation vector group of the sample text includes a feature vector of each word unit in the sample text.
[0114] As an example, the encoding layer may include a BERT model and an LSTM model. Exemplarily, the LSTM model may be a BiLSTM model.
[0115] In implementation, after the sample text is input into the encoding layer, the feature vector of each word unit in the sample text can be obtained through the BERT model, and then the feature vector of each word unit is input into the LSTM model to obtain the feature representation vector group of the sample text.
[0116] The feature vector of each word unit is a vector representation of each word unit after integrating the semantic information of the whole text.
[0117] Furthermore, before the sample text is input into the encoding layer, the sample text can be pre-embedded to obtain the word vector, text vector and position vector of each word unit in the sample text. The word vector, text vector and position vector of each word unit are input into the encoding layer for processing to obtain a feature representation vector group of the sample text.
[0118] Specifically, pre-embedding processing refers to inputting the sample text into the embedding layer for pre-embedding processing, and obtaining the word vector, text vector and position vector of each word unit in the sample text. The word vector is the vector corresponding to each word unit, the text vector is the vector of the text to which each word unit belongs, and the position vector is the vector generated by the position corresponding to each word unit.
[0119] In implementation, after the pre-embedding process obtains the word vector, text vector and position vector of each word unit, the word vector, text vector and position vector of each word unit can be input into the BERT model to obtain the feature vector of each word unit.
[0120] As an example, the BERT model may include n stack layers, which are connected in sequence. Each stack layer also includes: a self-attention layer, a first normalization layer, a feedforward layer, and a second normalization layer. The word vector, text vector, and position vector are input into the first stack layer to obtain the output vector of the first stack layer, and the output vector of the first stack layer is input into the second stack layer... and so on, and finally the output vector of the last stack layer is obtained, and the output vector of the last stack layer is used as the feature vector of each word unit.
[0121] In some embodiments, the feature vector of each word unit is input into the LSTM network model to obtain a vector representation of each word unit after further comprehensive integration of context information, thereby obtaining a feature representation vector group of the sample text.
[0122] In implementation, the feature representation vector group of the sample text is input into the first prediction layer of the joint extraction model, and the specific implementation of obtaining the predicted head entity may include: based on the feature representation vector group of the sample text, determining the probability that the word unit corresponding to each feature vector in the feature representation vector group is the starting position of the predicted head entity and the probability that the word unit corresponding to each feature vector is the end position of the predicted head entity; based on the probability that the word unit corresponding to each feature vector is the starting position of the predicted head entity and the probability that the word unit corresponding to each feature vector is the end position of the predicted head entity, determine the predicted head entity.
[0123] The predicted header entity is obtained from the entity in the sample text.
[0124] As an example, since there is a label group in the joint extraction model along with the sample text input, in the label group, the two entities and the relationship between the entities are arranged in order, the joint extraction model can identify the head entity in the label group and determine the type of the head entity. When predicting the head entity, it tends to determine the entity corresponding to the learned head entity type as the predicted head entity.
[0125] As an example, the first prediction layer may include a fully connected layer and an activation function layer. The activation function may be a Sigmoid activation function.
[0126] It should be noted that the fully connected layer can be understood as a classifier. In the embodiment of the present application, the probability of the word unit corresponding to the feature vector being each category can be determined through the fully connected layer. For example, in the embodiment of this step, the word unit can include two categories, the first is the start position of the predicted head entity, and the second is the end position of the predicted head entity.
[0127] In some embodiments, after obtaining the feature representation vector group of the sample text, the feature representation vector group of the sample text can be input into the first prediction layer. In the first prediction layer, the feature representation vector group of the sample is first linearly mapped and nonlinearly transformed through the fully connected layer to obtain the probability that the word unit corresponding to each feature vector is the starting position of the predicted head entity and the probability that the word unit corresponding to each feature vector is the end position of the predicted head entity. The obtained probabilities are then input into the activation function layer. The activation function layer can normalize the obtained probabilities, and then determine the predicted head entity based on the two probabilities corresponding to each word unit after normalization.
[0128] Among them, linear mapping is the mapping from one vector space V to another vector space W. Through linear mapping, the dimension of word vector can be converted to the dimension of sentence vector. Non-linear transformation is to transform the original feature vector nonlinearly to obtain a new feature vector. Using this new feature vector to perform linear classification corresponds to the original feature space, which is equivalent to performing nonlinear classification.
[0129] As an example, the probability that a certain word unit is the starting position of the predicted head entity or the probability that the word unit is the end position of the predicted head entity can be called the reference probability, where the reference probability is output by the fully connected layer and the value range of the reference probability is from negative infinity to positive infinity. The probability that the word unit corresponding to each feature vector output after the activation function layer is the starting position of the predicted head entity and the probability that the word unit is the end position of the predicted head entity are both in the range of 0 to 1.
[0130] In some embodiments, the starting position of the predicted head entity in the sample text can be determined by comparing the probability of each word unit as the starting position of the predicted head entity. Similarly, the ending position of the predicted head entity in the sample text can be determined by comparing the probability of each word unit as the ending position of the predicted head entity.
[0131] As an example, if the sample text is Chinese text, the word unit with the highest probability of being the start position of the predicted head entity and the word unit with the highest probability of being the end position of the predicted head entity can be combined as the predicted head entity.
[0132] Exemplarily, assuming that the sample text includes "Leader Zhang San attended meeting A", the probability of the word unit "Zhang" as the starting position of the predicted head entity is m1, and the probability of being the ending position of the predicted head entity is n1, the probability of the word unit "San" as the starting position of the predicted head entity is m2, and the probability of being the ending position of the predicted head entity is n2, the probability of the word unit "out" as the starting position of the predicted head entity is m3, and the probability of being the ending position of the predicted head entity is n3, the probability of the word unit "Xi" as the starting position of the predicted head entity is m4, and the probability of being the ending position of the predicted head entity is n4, among which, m1>m3>m2>m4, n2>n4>n1>n3, it can be seen that the probability of the word unit "Zhang" as the starting position of the predicted head entity is the largest, and the probability of the word unit "San" as the ending position of the predicted head entity is the largest, then the predicted head entity of the sample text is "Zhang San".
[0133] As an example, if the sample text is a foreign language text, the word unit with the highest probability of being the start position of the predicted head entity and the highest probability of being the end position of the predicted head entity can be determined as the predicted head entity.
[0134] Exemplarily, assuming that the sample text includes "Tom attended the meeting", the probability of the word unit "Tom" as the starting position of the predicted head entity is x1, and the probability of being the ending position of the predicted head entity is y1, the probability of the word unit "attended" as the starting position of the predicted head entity is x2, and the probability of being the ending position of the predicted head entity is y2, the probability of the word unit "meeting" as the starting position of the predicted head entity is x3, and the probability of being the ending position of the predicted head entity is y3, among which, x2>x1>x3, y2>y1>y3, it can be seen that the probability of the word unit "attended" as the starting position of the predicted head entity and the probability of being the ending position of the predicted head entity are both the largest, then the predicted head entity of the sample text is "attended".
[0135] As another example, the word units can be sorted in descending order of the probability of being the start position of the predicted head entity. First, determine the word units with a probability greater than the probability threshold. Among the word units with a probability greater than the probability threshold, the word unit with the highest probability of being the start position of the predicted head entity and the word unit with the highest probability of being the end position of the predicted head entity can be combined as the predicted head entity.
[0136] It should be noted that the probability threshold can be set by the user according to actual needs or can be set by default by the computing device. The embodiments of the present application do not limit this.
[0137] Exemplarily, assume that the sample text includes "Zhang San attended Meeting A". The probability that the word unit "出" is the start position of the predicted head entity is m1, and the probability that it is the end position of the predicted head entity is n1. The probability that the word unit "席" is the start position of the predicted head entity is m2, and the probability that it is the end position of the predicted head entity is n2. The probability that the word unit "张" is the start position of the predicted head entity is m3, and the probability that it is the end position of the predicted head entity is n3. The probability that the word unit "三" is the start position of the predicted head entity is m4, and the probability that it is the end position of the predicted head entity is n4, where m1 > m3 > m2 > m4 and n2 > n4 > n1 > n3. Assume that m1, m3, n2, and n4 are all greater than the probability threshold. Thus, it can be seen that the word unit "出" has the highest probability of being the start position of the predicted head entity, the word unit "席" has the highest probability of being the end position of the predicted head entity, and the word units "出" and "席" are adjacent in the sample text. Then, it can be determined that the predicted head entity of the sample text includes "出席". The probability that the word unit "张" is the start position of the predicted head entity is greater than the probability threshold, the probability that the word unit "三" is the end position of the predicted head entity is greater than the probability threshold, and the word units "张" and "三" are adjacent in the sample text. Then, it can be determined that the predicted head entity of the sample text also includes "张三". That is, it can be determined that the predicted head entities of the sample text include "出席" and "张三".
[0138] Step S106: Obtain the feature representation vector group of the predicted head entity, and input the feature representation vector group of the predicted head entity and the feature representation vector group of the sample text into the second prediction layer of the joint extraction model simultaneously to obtain a prediction group.
[0139] The prediction group includes the predicted head entity, the predicted tail entity associated with the predicted head entity, and the relationship between the predicted head entity and the predicted tail entity.
[0140] That is to say, after obtaining the predicted head entity through the joint extraction model, the predicted tail entity associated with the predicted head entity and the relationship between the predicted head entity and the predicted tail entity can be predicted based on the feature representation vector group of the predicted head entity and the feature representation vector group of the sample text, and output in the form of a prediction group.
[0141] In implementation, since the feature vector of each word unit in the sample text has been determined at the encoding layer, the feature vector of each word unit corresponding to the predicted head entity can be directly obtained to obtain the feature representation vector group of the predicted head entity.
[0142] In implementation, the feature representation vector group of the prediction head entity and the feature representation vector group of the sample text are simultaneously input into the second prediction layer of the joint extraction model, and the specific implementation of obtaining the prediction group may include: splicing the feature representation vector group of the prediction head entity and the feature representation vector group of the sample text to obtain a spliced feature representation vector group; based on the spliced feature representation vector group, determining the predicted tail entity associated with the predicted head entity, and the relationship between the predicted head entity and the predicted tail entity to obtain the prediction group.
[0143] In some embodiments, in order to facilitate the joint extraction model to determine the predicted tail entity associated with the predicted head entity, the feature representation vector group of the predicted head entity and the feature representation vector group of the sample text can be spliced to obtain a spliced feature representation vector group. For example, the feature representation vector group of the sample text is (E1~E 512 ) is 512 bits, and the feature representation vector group of the prediction header entity is (E 513 ~F 768 )256 bits, then the concatenated feature representation vector group is (E1~E 768 )768 bits.
[0144] In some embodiments, the feature representation vector group of the prediction head entity includes a feature vector of each word unit in the prediction head entity, and the concatenated feature representation vector group includes multiple feature vectors. Based on the concatenated feature representation vector group, the specific implementation of determining the predicted tail entity associated with the prediction head entity may include: based on the concatenated feature representation vector group, determining the probability that the word unit corresponding to each feature vector is the starting position of the predicted tail entity corresponding to the prediction head entity and the probability that the word unit corresponding to each feature vector is the ending position of the predicted tail entity corresponding to the prediction head entity; based on the probability that the word unit corresponding to each feature vector is the starting position of the predicted tail entity corresponding to the prediction head entity and the probability that the word unit corresponding to each feature vector is the ending position of the predicted tail entity corresponding to the prediction head entity, determine the predicted tail entity.
[0145] As an example, the second prediction layer has a similar structure to the first prediction layer, and the second prediction layer may also include a fully connected layer and an activation function layer. The activation function layer may be a Sigmoid function layer.
[0146] It should be noted that the fully connected layer can be understood as a classifier. In the embodiment of the present application, the probability that the word unit corresponding to the feature vector belongs to each category can be determined through the fully connected layer.
[0147] For example, assuming that the number of prediction head entities is two, the word unit may include four categories, the first is the starting position of the predicted tail entity corresponding to the first prediction head entity, the second is the ending position of the predicted tail entity corresponding to the first prediction head entity, the third is the starting position of the predicted tail entity corresponding to the second prediction head entity, and the fourth is the ending position of the predicted tail entity corresponding to the second prediction head entity.
[0148] In some embodiments, the concatenated feature representation vector group can be input into the second prediction layer, and the concatenated feature representation vector group is first linearly mapped and nonlinearly transformed through the fully connected layer to obtain the probability that the word unit corresponding to each feature vector is the starting position of the predicted tail entity, and the probability that the word unit corresponding to each feature vector is the ending position of the predicted tail entity, and then the obtained probability is input into the activation function layer, and the activation function layer can normalize the obtained probability, and then determine the predicted tail entity corresponding to each predicted head entity based on the two probabilities corresponding to each word unit after normalization. In addition, based on the determined predicted head entity and the determined predicted tail entity, the relationship between each group of predicted head entities and predicted tail entities can be determined.
[0149] As an example, the probability that a word unit is the starting position of a predicted tail entity or the probability that the word unit is the ending position of a predicted tail entity can be referred to as a reference probability, where the reference probability is output by the fully connected layer and the value range of the reference probability is from negative infinity to positive infinity. The probability that the word unit corresponding to each feature vector output after the activation function layer is the starting position of the predicted tail entity corresponding to each predicted head entity and the probability of the ending position are both in the range of 0 to 1.
[0150] As an example, the starting position of the predicted tail entity corresponding to the predicted head entity in the sample text can be determined by comparing the probability of each word unit as the starting position of the predicted tail entity corresponding to the predicted head entity. Similarly, the ending position of the predicted tail entity corresponding to the predicted head entity in the sample text can be determined by comparing the probability of each word unit as the ending position of the predicted tail entity corresponding to the predicted head entity. Further, based on the determined starting position of the predicted tail entity corresponding to the predicted head entity and the ending position of the predicted tail entity corresponding to the predicted head entity, the predicted tail entity corresponding to the predicted head entity can be determined.
[0151] For example, if the sample text is "The first leader Zhang San and the second leader Li Si attended meeting A." After the above processing through the second prediction layer, the output can be (attendance, attendee, Zhang San), (attendance, attendee, Li Si), (Zhang San, position, first leader) and (Li Si, position, second leader).
[0152] In the embodiments of the present specification, the predicted tail entity and the relationship between each group of predicted head entities and predicted tail entities are determined through the fully connected layer and the activation function layer. Multiple groups of entity pairs and relationship types can be identified. It is possible to identify situations where an entity has multiple pairs of different relationships, and the identification of the relationship between entities is more comprehensive and accurate.
[0153] Step S108: Determine a loss value based on the prediction group and the label group.
[0154] In implementation, the feature vector group of each entity in the prediction group and the feature vector group of each entity in the label group can be compared, and the loss value can be calculated through the loss function.
[0155] As an example, the loss function may be a classification cross entropy function, a maximum entropy function, etc., which is not limited in the embodiments of the present application.
[0156] Further, after determining the prediction groups, the accuracy can be determined based on the ratio of the number of correctly predicted prediction groups to the number of obtained prediction groups, and the recall can be determined based on the ratio of the number of obtained prediction groups to the number of label groups. The F1 value can also be determined based on the accuracy and recall so that the performance of the joint extraction model can be determined.
[0157] The joint extraction model training method described in the embodiments of this specification can intuitively show the difference between the model's predicted results and the actual results by calculating the loss value, and then conduct targeted training on the joint extraction model, which can effectively improve the model training rate and model training effect.
[0158] Step S110: Train the joint extraction model based on the loss value until the training stop condition is reached.
[0159] In implementation, the specific implementation of this step may include: if the loss value is greater than or equal to a preset threshold, continue training the joint extraction model; if the loss value is less than the preset threshold, stop training.
[0160] That is to say, it can be determined whether the loss value is less than the preset threshold. When the loss value is greater than or equal to the preset threshold, the joint extraction model can continue to be trained; when the loss value is less than the preset threshold, the training can be stopped.
[0161] Among them, the preset threshold is the critical value of the loss value. When the loss value is greater than or equal to the preset threshold, it means that there is still a certain deviation between the predicted result of the joint extraction model and the actual result, and it is still necessary to adjust the parameters of the joint extraction model and obtain sample text to continue training the model; when the loss value is less than the preset threshold, it means that the predicted result of the joint extraction model is close enough to the actual result, and training can be stopped.
[0162] It should be noted that the value of the preset threshold can be determined by the user according to actual conditions, or can be set by default by the computing device, and the embodiments of the present application do not limit this.
[0163] The training method of the joint extraction model described in the embodiments of this specification determines the specific training situation of the joint extraction model according to the loss value, and reversely adjusts the parameters of the joint extraction model according to the loss value to improve the analysis ability of the model when the training fails. The training rate is high and the training effect is good.
[0164] The joint extraction model training method provided in the present specification obtains sample text and a label group, wherein the label group is used to characterize the relationship between entities in the sample text, the entities include named entities and trigger words in the sample text, and the trigger words are used to characterize the behavior in the sample text; the sample text is input into the encoding layer of the joint extraction model to obtain a feature representation vector group of the sample text, and the feature representation vector group of the sample text is input into the first prediction layer of the joint extraction model to obtain a predicted head entity; the feature representation vector group of the predicted head entity is obtained, and the feature representation vector group of the predicted head entity and the feature representation vector group of the sample text are simultaneously input into the second prediction layer of the joint extraction model to obtain a prediction group; a loss value is determined based on the prediction group and the label group; and the joint extraction model is trained based on the loss value until a training stop condition is reached. When training the joint extraction model, the present specification sets the labels for event extraction and information extraction of the sample text in the label group, and trains the joint extraction model through the encoding layer, the first prediction layer and the second prediction layer, so as to obtain a joint extraction model capable of jointly extracting event extraction and information extraction. Only through the joint extraction model, information extraction and event extraction can be realized simultaneously to obtain the required information in the text. Compared with the prior art of extracting information and extracting events separately through multiple models, the consumption of computing resources and the occupation of memory resources are greatly reduced, and the extraction efficiency of the joint extraction model is improved.
[0165] The following combination Figure 2 Taking the application of the joint extraction model training method provided in this specification in the joint extraction of information and events as an example, the joint extraction model training method is further described. Figure 2 A processing flow chart of a joint extraction model training method for joint extraction of information and events provided in an embodiment of this specification is shown, which specifically includes the following steps:
[0166] Step S202: obtaining a plurality of sample texts and a label of each sample text from a corpus, wherein the corpus includes a corpus for event extraction and a corpus for information extraction.
[0167] Step S204: determining a label group for each sample text based on the label of each sample text, wherein the label group is used to characterize the relationship between entities in the sample text, and the entities include named entities and trigger words in the sample text, and the trigger words are used to characterize the behavior in the sample text.
[0168] Since the labels of the sample texts corresponding to event extraction and information extraction are different, it is also necessary to determine the label group of each sample text based on the label of each sample text.
[0169] Take the sample text "Leader Zhang San attended meeting A and meeting B" as an example. If the sample text is obtained from a corpus extracted from events, the label of the sample text includes the trigger word "attendance", the participant "Zhang San", the meeting name "A meeting" and the meeting name "B meeting". The trigger word "attendance" can be marked as an entity, and the meeting name and the participants can be marked as relationships, and the label groups of the sample text can be obtained (attendance, participant, Zhang San), (attendance, meeting name, A meeting) and (attendance, meeting name, B meeting). Furthermore, the relationship between entities in the sample text can also be manually annotated to obtain the triple of the sample text (Zhang San, position, leader). In summary, (attendance, participant, Zhang San), (attendance, meeting name, A meeting), (attendance, meeting name, B meeting) and (Zhang San, position, leader) can all be determined as the label group of the sample text.
[0170] Take the sample text "Leader Zhang San attended meeting A and meeting B" as an example. If the sample text is obtained from the information extraction corpus, the label of the sample text can include a triple, which can be (Zhang San, position, leader), and the triple can be determined as the label group of the sample text. Furthermore, the relationship between the trigger words, entities, and argument roles in the sample text can also be determined artificially, and three labels (attendance, participant, Zhang San), (attendance, meeting name, meeting A) and (attendance, meeting name, meeting B) can be obtained. In summary, (Zhang San, position, leader), (attendance, participant, Zhang San), (attendance, meeting name, meeting A) and (attendance, meeting name, meeting B) can all be determined as the label group of the sample text.
[0171] Step S206: input the sample text into the encoding layer of the joint extraction model to obtain a feature representation vector group of the sample text, wherein the feature representation vector group of the sample text includes a feature vector of each word unit in the sample text.
[0172] Taking the sample text "Leader Zhang San attended meeting A and meeting B" as an example, the sample text is input into the encoding layer of the joint extraction model to obtain the feature vector of each word unit. The feature vector of each word unit constitutes the feature representation vector group of the sample text.
[0173] Step S208: Input the feature representation vector group of the sample text into the first prediction layer of the joint extraction model to obtain a predicted head entity.
[0174] In implementation, the specific realization of this step may include: based on the feature representation vector group of the sample text, the word unit corresponding to each feature vector can be determined as the probability of the start position of the predicted head entity and the probability of the word unit corresponding to each feature vector as the end position of the predicted head entity; then, based on the probability of the word unit corresponding to each feature vector as the start position of the predicted head entity and the probability of the word unit corresponding to each feature vector as the end position of the predicted head entity, the predicted head entity is determined.
[0175] Among them, the predicted head entity is obtained from the entities in the sample text.
[0176] Taking the sample text "Leader Zhang San attended Meeting A and Meeting B" as an example, input the feature representation vector of this sample text into the first prediction layer for processing. After linear mapping and non-linear transformation, the probability of each character as the start position of the predicted head entity and the probability of each character as the end position of the predicted head entity can be obtained. Suppose the probabilities of each character as the start position of the predicted head entity are [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14] respectively; the probabilities of each character as the end position of the predicted head entity are [b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14] respectively. Suppose a3 and a5 are the two larger probabilities among the probabilities of the start position of the predicted head entity, and b4 and b6 are the two larger probabilities among the probabilities of the end position of the predicted head entity, and the word corresponding to a3 and the word corresponding to b4 are adjacent, and the word corresponding to a5 and the word corresponding to b6 are adjacent. Then the word "Zhang" corresponding to a3 and the word "San" corresponding to b4 can be combined as a predicted head entity, and the word "chu" corresponding to a5 and the word "xi" corresponding to b6 can be combined as a predicted head entity. That is, the predicted head entities of this sample text are "Zhang San" and "attended".
[0177] Step S210: Input the feature representation vector group of the predicted head entity and the feature representation vector group of the sample text into the second prediction layer of the joint extraction model simultaneously to obtain a prediction group.
[0178] In implementation, the specific realization of this step may include: splicing the feature representation vector group of the predicted head entity and the feature representation vector group of the sample text to obtain a spliced feature representation vector group; based on the spliced feature representation vector group, determine the predicted tail entity associated with the predicted head entity and the relationship between the predicted head entity and the predicted tail entity to obtain a prediction group.
[0179] As an example, in order to facilitate the joint extraction model to determine the predicted tail entity associated with the predicted head entity, the feature representation vector group of the predicted head entity and the feature representation vector group of the sample text can be spliced to obtain a spliced feature representation vector group. For example, if the feature representation vector group of the sample text is 512 bits and the feature representation vector group of the predicted head entity is 256 bits, then the spliced feature representation vector group is 768 bits.
[0180] In some embodiments, the feature representation vector group of the predicted head entity includes the feature vector of each word unit in the predicted head entity, and the feature representation vector group of the sample text includes the feature vector of each word unit in the sample text. Therefore, based on the concatenated feature representation vector group, the specific implementation of determining the predicted tail entity associated with the predicted head entity may include: based on the concatenated feature representation vector group, determining the probability that the word unit corresponding to each feature vector is the starting position of the predicted tail entity corresponding to the predicted head entity and the probability that the word unit corresponding to each feature vector is the ending position of the predicted tail entity corresponding to the predicted head entity; based on the probability that the word unit corresponding to each feature vector is the starting position of the predicted tail entity corresponding to the predicted head entity and the probability that the word unit corresponding to each feature vector is the ending position of the predicted tail entity corresponding to the predicted head entity, determining the predicted tail entity.
[0181] Taking the sample text as "Leader Zhang San attended meeting A and meeting B", and the predicted head entities as "Zhang San" and "attended", the feature representation vector group of "Leader Zhang San attended meeting A and meeting B" can be concatenated with the feature representation vector group of "Zhang San" and "attended" to obtain a concatenated feature representation vector group. The concatenated feature representation vector group is input into the second prediction layer for processing. After linear mapping and nonlinear transformation, the probability of each word being the starting position of the predicted tail entity corresponding to "Zhang San" and the probability of each word being the ending position of the predicted tail entity corresponding to "Zhang San" can be obtained, as well as the probability of each word being the starting position of the predicted tail entity corresponding to "attended" and the probability of each word being the ending position of the predicted tail entity corresponding to "attended".
[0182] Suppose the probability that each word is the starting position of the predicted tail entity corresponding to "Zhang San" is [c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14]; the probability that each word is the ending position of the predicted tail entity corresponding to "Zhang San" is [d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12, d13, d14], the probability that each word is the starting position of the predicted tail entity corresponding to "attend" is [e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14], and the probability that each word is the ending position of the predicted tail entity corresponding to "attend" is [f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14].
[0183] Suppose a1 is the largest among the probabilities of the starting positions of the predicted tail entities corresponding to "Zhang San", b2 is the largest among the probabilities of the ending positions of the predicted tail entities corresponding to "Zhang San", and the word corresponding to a1 and the word corresponding to b2 are adjacent. Therefore, the word "lead" corresponding to a1 and the word "guide" corresponding to b2 can be combined as a predicted head entity, and the predicted tail entity corresponding to "Zhang San" is obtained as "leadership". Suppose e8 and e12 are the two larger ones among the probabilities of the starting positions of the predicted tail entities corresponding to "attend", and f10 and f14 are the two larger ones among the probabilities of the ending positions of the predicted tail entities corresponding to "attend", and the word corresponding to e8 and the word corresponding to f10 are the closest, and the word corresponding to e12 and the word corresponding to f14 are the closest. Since the word corresponding to e8 and the word corresponding to f10 cannot form a word, the word "A" corresponding to e8, the word "meeting" corresponding to f9, and the word "session" corresponding to f10 can be combined as a predicted head entity. Since the word corresponding to e12 and the word corresponding to f14 cannot form a word, the word "B" corresponding to e12, the word "meeting" corresponding to f13, and the word "session" corresponding to f14 can be combined as a predicted head entity. That is, the predicted tail entities corresponding to "attend" are obtained as "A meeting" and "B meeting".
[0184] Through the above process, the predicted tail entity corresponding to the predicted head entity "Zhang San" is obtained as "leadership", and the relationship is position; the predicted tail entities corresponding to "attend" include "A meeting", and the relationship is meeting name; the predicted tail entities corresponding to "attend" include "B meeting", and the relationship is meeting name. That is, three prediction groups can be obtained: (Zhang San, position, leadership), (attend, meeting name, A meeting), and (attend, meeting name, B meeting).
[0185] Step S212: Determine the loss value based on the prediction group and the label group.
[0186] Continuing with the above example, the loss value can be obtained by calculating the loss function of the prediction groups (Zhang San, position, leader) (attendance, meeting name, meeting A) and (attendance, meeting name, meeting B) and the label groups (Zhang San, position, leader), (attendance, attendees, Zhang San), (attendance, meeting name, meeting A) and (attendance, meeting name, meeting B).
[0187] Step S214: Train the joint extraction model based on the loss value until the training stop condition is reached.
[0188] In the implementation, if the loss value is greater than or equal to the preset threshold, the joint extraction model continues to be trained; if the loss value is less than the preset threshold, the training is stopped.
[0189] That is to say, when the loss value is greater than or equal to the preset threshold, it means that there is still a certain deviation between the predicted results of the joint extraction model and the actual results, and it is still necessary to adjust the parameters of the joint extraction model and obtain sample text to continue training the model; when the loss value is less than the preset threshold, it means that the predicted results of the joint extraction model are close enough to the actual results, and training can be stopped.
[0190] The joint extraction model training method provided in the present specification obtains sample text and a label group, wherein the label group is used to characterize the relationship between entities in the sample text, the entities include named entities and trigger words in the sample text, and the trigger words are used to characterize the behavior in the sample text; the sample text is input into the encoding layer of the joint extraction model to obtain a feature representation vector group of the sample text, and the feature representation vector group of the sample text is input into the first prediction layer of the joint extraction model to obtain a predicted head entity; the feature representation vector group of the predicted head entity is obtained, and the feature representation vector group of the predicted head entity and the feature representation vector group of the sample text are simultaneously input into the second prediction layer of the joint extraction model to obtain a prediction group; a loss value is determined based on the prediction group and the label group; and the joint extraction model is trained based on the loss value until a training stop condition is reached. When training the joint extraction model, the present specification sets the labels for event extraction and information extraction of the sample text in the label group, and trains the joint extraction model through the encoding layer, the first prediction layer and the second prediction layer, so as to obtain a joint extraction model capable of jointly extracting event extraction and information extraction. Only through the joint extraction model, information extraction and event extraction can be realized simultaneously to obtain the required information in the text. Compared with the prior art of extracting information and extracting events separately through multiple models, the consumption of computing resources and the occupation of memory resources are greatly reduced, and the extraction efficiency of the joint extraction model is improved.
[0191] Figure 3A flowchart of a joint extraction method provided according to an embodiment of this specification is shown, which may specifically include the following steps:
[0192] Step S302: Obtain the text to be extracted.
[0193] Step S304: input the text to be extracted into the encoding layer of the joint extraction model to obtain a feature representation vector group of the text to be extracted, and input the feature representation vector group of the text to be extracted into the first prediction layer of the joint extraction model to determine the head entity in the text to be extracted.
[0194] Among them, the feature representation vector group of the text to be extracted includes the feature vector of each word unit in the text to be extracted, the head entity is obtained from the entity in the text to be extracted, and the joint extraction model is trained by the joint extraction model training method described in the above embodiment.
[0195] The encoding layer includes the BERT model and the BiLSTM model. The first prediction layer includes a fully connected layer and an activation function layer.
[0196] As an example, the word vector of each word unit in the text to be extracted can be determined, the word vector of each word unit can be input into the BERT model to obtain the feature vector of each word unit, and the feature vector of each word unit can be input into the BiLSTM model to obtain the feature representation vector group of the text to be extracted.
[0197] In implementation, based on the feature representation vector group of the sample text, the probability of the word unit corresponding to each feature vector being the starting position of the head entity and the probability of the word unit corresponding to each feature vector being the ending position of the head entity can be determined. Based on the probability of the word unit corresponding to each feature vector being the starting position of the head entity and the probability of the word unit corresponding to each feature vector being the ending position of the head entity, the head entity in the text to be extracted can be determined.
[0198] Step S306: Obtain a feature representation vector group of the head entity, and input the feature representation vector group of the head entity and the feature representation vector group of the text to be extracted into the second prediction layer of the joint extraction model at the same time to determine the extraction result of the text to be extracted.
[0199] The second prediction layer includes a fully connected layer and an activation function layer. The activation function may be a sigmoid activation function.
[0200] In implementation, the feature representation vector group of the head entity can be spliced with the feature representation vector group of the sample text to obtain a spliced feature representation vector group. Based on the spliced feature representation vector group, the tail entity associated with the head entity and the relationship between the head entity and the tail entity are determined to obtain the extraction result.
[0201] The extraction results include a head entity, a tail entity associated with the head entity, and a relationship between the head entity and the tail entity.
[0202] In some embodiments, the feature representation vector group of the head entity includes the feature vector of each word unit in the head entity, so the concatenated feature representation vector includes multiple feature vectors. The specific implementation of determining the tail entity associated with the head entity may include: based on the concatenated feature representation vector group, determining the probability that the word unit corresponding to each feature vector is the starting position of the tail entity corresponding to the head entity, and determining the probability that the word unit corresponding to each feature vector is the ending position of the tail entity corresponding to the head entity. Based on the probability that the word unit corresponding to each feature vector is the starting position of the tail entity corresponding to the head entity and the probability that the word unit corresponding to each feature vector is the ending position of the tail entity corresponding to the head entity, the tail entity can be determined.
[0203] Furthermore, the output group including the trigger word among the multiple output groups of the second prediction layer can be converted into the form of event extraction results, which can more clearly determine the trigger word and the argument role.
[0204] The joint extraction method provided in this specification can obtain the text to be extracted, input the text to be extracted into the encoding layer of the joint extraction model, obtain the feature representation vector group of the text to be extracted, and input the feature representation vector group of the text to be extracted into the first prediction layer of the joint extraction model to determine the head entity in the text to be extracted. The joint extraction model is trained by the joint extraction model training method described in the above embodiment; obtain the feature representation vector group of the head entity, and input the feature representation vector group of the head entity and the feature representation vector group of the text to be extracted into the second prediction layer of the joint extraction model at the same time to determine the extraction result of the text to be extracted. In this way, event extraction and information extraction can be realized simultaneously only through the joint extraction model to obtain the information required in the text. Compared with the prior art of extracting information and event respectively through multiple models, the consumption of computing resources and the occupation of memory resources are greatly reduced, and the extraction efficiency of the joint extraction model is improved.
[0205] Figure 4 A flowchart of another joint extraction method provided according to an embodiment of this specification is shown, which may specifically include the following steps:
[0206] Step S402: Obtain the text to be extracted.
[0207] For example, the text to be extracted may be "Leader Zhang San attended the expo."
[0208] Step S404: Determine the word vector of each character in the text to be extracted.
[0209] Taking the text to be extracted as "Leader Zhang San attended the Expo" as an example, the word vector of each word in the text to be extracted can be determined by querying the word vector table.
[0210] Step S406: Input the word vector of each character in the text to be extracted into the BERT model in the encoding layer to obtain the feature vector of each character.
[0211] Step S408: Input the feature vector of each word into the BiLSTM model in the encoding layer to obtain a feature representation vector group of the text to be extracted.
[0212] Step S410: inputting the feature representation vector group of the text to be extracted into the first prediction layer to obtain a head entity, wherein the first prediction layer includes a fully connected layer and an activation function layer.
[0213] As an example, the activation function may be a sigmoid activation function.
[0214] As an example, the feature representation vector group of the text to be extracted can be input into the fully connected layer. The feature vector of each word is linearly mapped and nonlinearly transformed by the fully connected layer, so as to obtain the probability that each word is the starting position of the head entity and the probability that each word is the ending position of the head entity. The probability output by the fully connected layer is input into the activation function layer, and the activation function layer can normalize the obtained probability, and then determine the head entity based on the two probabilities corresponding to each word after normalization.
[0215] Taking the text to be extracted as "Leader Zhang San attended the expo" as an example, after the feature representation vector group of "Leader Zhang San attended the expo" is input into the first prediction layer, the head entities "attendance" and "Zhang San" can be obtained.
[0216] Step S412: Obtain a feature representation vector group of the head entity.
[0217] Taking the text to be extracted as "Leader Zhang San attended the expo" as an example, the head entities obtained are "attendance" and "Zhang San", and the feature representation vector group of "attendance" and the feature representation vector group of "Zhang San" can be obtained from the encoding layer.
[0218] Step S414: Input the feature representation vector group of the head entity and the feature representation vector group of the text to be extracted into the second prediction layer to obtain the extraction result, wherein the second prediction layer includes a fully connected layer and an activation function layer.
[0219] As an example, the feature representation vector group of the head entity and the feature representation vector group of the text to be extracted can be spliced to obtain a spliced feature representation vector group. The spliced feature representation vector group is input into the second prediction layer, and the spliced feature representation vector group is first linearly mapped and nonlinearly transformed through the fully connected layer to obtain the probability that the word corresponding to each feature vector is the starting position of the tail entity and the probability that the word corresponding to each feature vector is the ending position of the tail entity, and then the obtained probability is input into the activation function layer, and the activation function layer can normalize the obtained probability, and then determine the probability of each word as the starting position of the tail entity corresponding to each head entity based on the probability corresponding to each word after the normalization, and determine the probability of each word as the ending position of the tail entity corresponding to each head entity, and then determine the tail entity corresponding to each head entity. In addition, based on the determined head entity and the determined tail entity, the relationship between each group of head entities and tail entities can be determined, and the extraction result can be obtained.
[0220] The extraction result includes a head entity, a tail entity corresponding to the head entity, and a relationship between the head entity and the tail entity.
[0221] Continuing with the above example, the feature representation vector group of "attendance", the feature representation vector group of "Zhang San" and the feature representation vector group of "Leader Zhang San attended the expo" are simultaneously input into the fully connected layer to obtain the output vector of the fully connected layer. The output vector of the fully connected layer is input into the activation function layer, and the tail entities "Zhang San" and "Expo" corresponding to "attendance" and the tail entity "Leader" corresponding to "Zhang San" can be obtained. The relationship between "attendance" and "Zhang San" is the attendee, the relationship between "attendance" and "Expo" is the name of the conference, and the relationship between "Zhang San" and "Leader" is the position. Therefore, three groups of output results can be obtained (attendance, attendees, Zhang San), (attendance, conference name, expo) and (Zhang San, position, leader).
[0222] Furthermore, the result corresponding to the event extraction in the output result of the second prediction layer may be converted into the form of event extraction.
[0223] Continuing with the above example, in the output results, (attendance, attendee, Zhang San) and (attendance, conference name, expo) are the corresponding results of event extraction, which can be converted to: [trigger word: attendance, argument role: {attendee: Zhang San, conference name: expo}]. In this way, the relevant information of this conference event can be clearly understood.
[0224] In this example, the corresponding result of information extraction is (Zhang San, position, leader).
[0225] The joint extraction method provided in this specification can obtain the text to be extracted, input the text to be extracted into the encoding layer of the joint extraction model, obtain the feature representation vector group of the text to be extracted, and input the feature representation vector group of the text to be extracted into the first prediction layer of the joint extraction model to determine the head entity in the text to be extracted. The joint extraction model is trained by the joint extraction model training method described in the above embodiment; obtain the feature representation vector group of the head entity, and input the feature representation vector group of the head entity and the feature representation vector group of the text to be extracted into the second prediction layer of the joint extraction model at the same time to determine the extraction result of the text to be extracted. In this way, event extraction and information extraction can be realized simultaneously only through the joint extraction model to obtain the information required in the text. Compared with the prior art of extracting information and event respectively through multiple models, the consumption of computing resources and the occupation of memory resources are greatly reduced, and the extraction efficiency of the joint extraction model is improved.
[0226] Corresponding to the above-mentioned joint extraction model training method embodiment, this specification also provides a joint extraction model training device embodiment, Figure 5 FIG. 1 shows a schematic diagram of the structure of a joint extraction model training device provided in an embodiment of this specification. Figure 5 As shown, the device comprises:
[0227] A first acquisition module 502 is used to acquire a sample text and a tag group, wherein the tag group is used to characterize the relationship between entities in the sample text, the entities include named entities and trigger words in the sample text, and the trigger words are used to characterize the behavior in the sample text;
[0228] A first prediction module 504 is used to input the sample text into the encoding layer of the joint extraction model to obtain a feature representation vector group of the sample text, and input the feature representation vector group of the sample text into the first prediction layer of the joint extraction model to obtain a predicted header entity;
[0229] A second prediction module 506 is used to obtain a feature representation vector group of the predicted header entity, and input the feature representation vector group of the predicted header entity and the feature representation vector group of the sample text into the second prediction layer of the joint extraction model at the same time to obtain a prediction group;
[0230] A determination module 508, configured to determine a loss value based on the prediction group and the label group;
[0231] The training module 510 is used to train the joint extraction model based on the loss value until a training stop condition is reached.
[0232] Optionally, the first acquisition module 502 is used to:
[0233] Acquire multiple sample texts and labels of each sample text from a corpus, wherein the corpus includes an event extraction corpus and an information extraction corpus;
[0234] A label group for each sample text is determined based on the label for each sample text.
[0235] Optionally, the first acquisition module 502 is used to:
[0236] If the sample text is obtained from a corpus extracted from the event, the label of the sample text includes a trigger word, an argument role, and an entity corresponding to the argument role, and the trigger word, argument role, and entity corresponding to the argument role in the label of the sample text are determined as a label group.
[0237] Optionally, the first acquisition module 502 is used to:
[0238] If the sample text is obtained from the information extraction corpus, the label of the sample text includes a triple, and the triple is used to characterize the relationship between entities in the sample text, the label of the sample text is determined as the label group of the sample text.
[0239] Optionally, the first prediction module 504 is used to:
[0240] The feature representation vector group of the sample text includes a feature vector of each word unit in the sample text, and based on the feature representation vector group of the sample text, determining the probability that the word unit corresponding to each feature vector in the feature representation vector group is the starting position of the predicted head entity and the probability that the word unit corresponding to each feature vector is the ending position of the predicted head entity;
[0241] The predicted head entity is determined based on the probability that the word unit corresponding to each feature vector is the starting position of the predicted head entity and the probability that the word unit corresponding to each feature vector is the ending position of the predicted head entity, wherein the predicted head entity is obtained from the entity in the sample text.
[0242] Optionally, the second prediction module 506 is used to:
[0243] Concatenating the feature representation vector group of the predicted header entity with the feature representation vector group of the sample text to obtain a concatenated feature representation vector group;
[0244] Based on the concatenated feature representation vector group, the prediction tail entity associated with the prediction head entity and the relationship between the prediction head entity and the prediction tail entity are determined to obtain the prediction group, wherein the prediction group includes the prediction head entity, the prediction tail entity associated with the prediction head entity, and the relationship between the prediction head entity and the prediction tail entity.
[0245] Optionally, the second prediction module 506 is used to:
[0246] The feature representation vector group of the prediction head entity includes a feature vector of each word unit in the prediction head entity, and based on the concatenated feature representation vector group, determining a probability that the word unit corresponding to each feature vector is the starting position of the prediction tail entity corresponding to the prediction head entity and a probability that the word unit corresponding to each feature vector is the ending position of the prediction tail entity corresponding to the prediction head entity;
[0247] The predicted tail entity is determined based on the probability that the word unit corresponding to each feature vector is the starting position of the predicted tail entity corresponding to the predicted head entity and the probability that the word unit corresponding to each feature vector is the ending position of the predicted tail entity corresponding to the predicted head entity.
[0248] Optionally, the training module 510 is used to:
[0249] If the loss value is greater than or equal to a preset threshold, continue training the joint extraction model;
[0250] If the loss value is less than the preset threshold, the training is stopped.
[0251] The joint extraction model training method provided in the present specification obtains sample text and a label group, wherein the label group is used to characterize the relationship between entities in the sample text, the entities include named entities and trigger words in the sample text, and the trigger words are used to characterize the behavior in the sample text; the sample text is input into the encoding layer of the joint extraction model to obtain a feature representation vector group of the sample text, and the feature representation vector group of the sample text is input into the first prediction layer of the joint extraction model to obtain a predicted head entity; the feature representation vector group of the predicted head entity is obtained, and the feature representation vector group of the predicted head entity and the feature representation vector group of the sample text are simultaneously input into the second prediction layer of the joint extraction model to obtain a prediction group; a loss value is determined based on the prediction group and the label group; and the joint extraction model is trained based on the loss value until a training stop condition is reached. When training the joint extraction model, the present specification sets the labels for event extraction and information extraction of the sample text in the label group, and trains the joint extraction model through the encoding layer, the first prediction layer and the second prediction layer, so as to obtain a joint extraction model capable of jointly extracting event extraction and information extraction. Only through the joint extraction model, information extraction and event extraction can be realized simultaneously to obtain the required information in the text. Compared with the prior art of extracting information and extracting events separately through multiple models, the consumption of computing resources and the occupation of memory resources are greatly reduced, and the extraction efficiency of the joint extraction model is improved.
[0252] The above is a schematic scheme of a joint extraction model training device of this embodiment. It should be noted that the technical scheme of the joint extraction model training device and the technical scheme of the joint extraction model training method mentioned above belong to the same concept, and the details not described in detail in the technical scheme of the joint extraction model training device can be found in the description of the technical scheme of the joint extraction model training method mentioned above.
[0253] Corresponding to the above-mentioned joint extraction method embodiment, this specification also provides a joint extraction device embodiment, Figure 6 FIG. 1 shows a schematic diagram of the structure of a combined extraction device provided in an embodiment of this specification. Figure 6 As shown, the device comprises:
[0254] The second acquisition module 602 is used to acquire the text to be extracted;
[0255] A first determination module 604 is used to input the text to be extracted into the encoding layer of the joint extraction model to obtain a feature representation vector group of the text to be extracted, and input the feature representation vector group of the text to be extracted into the first prediction layer of the joint extraction model to determine the head entity in the text to be extracted, wherein the joint extraction model is trained by the joint extraction model training method described in the above embodiment;
[0256] The second determination module 606 is used to obtain the feature representation vector group of the head entity, and input the feature representation vector group of the head entity and the feature representation vector group of the text to be extracted into the second prediction layer of the joint extraction model at the same time to determine the extraction result of the text to be extracted.
[0257] Optionally, the first determining module 604 is used to:
[0258] The feature representation vector group of the text to be extracted includes the feature vector of each word unit in the sample text to be extracted, and based on the feature representation vector group of the text to be extracted, the probability that the word unit corresponding to each feature vector in the feature representation vector group is the starting position of the head entity and the probability that the word unit corresponding to each feature vector is the ending position of the head entity are determined;
[0259] Based on the probability that the word unit corresponding to each feature vector is the starting position of the head entity and the probability that the word unit corresponding to each feature vector is the ending position of the head entity, the head entity in the text to be extracted is determined, wherein the head entity is obtained from the entity in the text to be extracted.
[0260] Optionally, the second determining module 606 is used to:
[0261] Concatenating the feature representation vector group of the head entity with the feature representation vector group of the text to be extracted to obtain a concatenated feature representation vector group;
[0262] Based on the concatenated feature representation vector group, the tail entity associated with the head entity and the relationship between the head entity and the tail entity are determined to obtain an extraction result, wherein the extraction result includes the head entity, the tail entity associated with the head entity, and the relationship between the head entity and the tail entity.
[0263] Optionally, the second determining module 606 is used to:
[0264] The feature representation vector group of the head entity includes a feature vector of each word unit in the head entity, and based on the concatenated feature representation vector group, determining a probability that the word unit corresponding to each feature vector is the starting position of the tail entity corresponding to the head entity and a probability that the word unit corresponding to each feature vector is the ending position of the tail entity corresponding to the head entity;
[0265] The tail entity is determined based on the probability that the word unit corresponding to each feature vector is the starting position of the tail entity corresponding to the head entity and the probability that the word unit is the ending position of the tail entity corresponding to the head entity.
[0266] The joint extraction method provided in this specification can obtain the text to be extracted, input the text to be extracted into the encoding layer of the joint extraction model, obtain the feature representation vector group of the text to be extracted, and input the feature representation vector group of the text to be extracted into the first prediction layer of the joint extraction model to determine the head entity in the text to be extracted. The joint extraction model is trained by the joint extraction model training method described in the above embodiment; obtain the feature representation vector group of the head entity, and input the feature representation vector group of the head entity and the feature representation vector group of the text to be extracted into the second prediction layer of the joint extraction model at the same time to determine the extraction result of the text to be extracted. In this way, event extraction and information extraction can be realized simultaneously only through the joint extraction model to obtain the information required in the text. Compared with the prior art of extracting information and event respectively through multiple models, the consumption of computing resources and the occupation of memory resources are greatly reduced, and the extraction efficiency of the joint extraction model is improved.
[0267] Figure 7 The structure block diagram of a computing device 700 provided according to an embodiment of the present specification is shown. The components of the computing device 700 include but are not limited to a memory 710 and a processor 720. The processor 720 is connected to the memory 710 via a bus 730, and the database 750 is used to store data.
[0268] The computing device 700 also includes an access device 740 that enables the computing device 700 to communicate via one or more networks 760. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 740 may include one or more of any type of network interface (e.g., a network interface card (NIC)) whether wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.
[0269] In one embodiment of the present specification, the above components of the computing device 700 and Figure 7 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 7 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.
[0270] The computing device 700 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. The computing device 700 may also be a mobile or stationary server.
[0271] Among them, the processor 720 is used to execute the steps of the above-mentioned joint extraction model training method, or to execute the steps of the above-mentioned joint extraction method.
[0272] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the joint extraction model training method or the joint extraction method mentioned above belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be referred to the description of the technical scheme of the joint extraction model training method or the joint extraction method mentioned above.
[0273] An embodiment of the present specification also provides a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of the above-mentioned joint extraction model training method, or implement the steps of the above-mentioned joint extraction method.
[0274] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the joint extraction model training method or the joint extraction method belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the joint extraction model training method or the joint extraction method.
[0275] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0276] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0277] It should be noted that, for the convenience of description, the aforementioned method embodiments are all described as a series of action combinations, but those skilled in the art should be aware that this specification is not limited by the order of the actions described, because according to this specification, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this specification.
[0278] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0279] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The optional embodiments do not describe all the details in detail, nor do they limit the invention to only the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of this specification, so that technicians in the relevant technical field can well understand and use this specification. This specification is limited only by the claims and their full scope and equivalents.
Claims
1. A joint extraction model training method, characterized in that: The method comprises: Acquire a sample text and a tag group, wherein the tag group is used to characterize the relationship between entities in the sample text, the entities include named entities and trigger words in the sample text, and the trigger words are used to characterize the behavior in the sample text; Inputting the sample text into the encoding layer of the joint extraction model to obtain a feature representation vector group of the sample text; Based on the feature representation vector group of the sample text, determining the probability of a word unit corresponding to each feature vector in the feature representation vector group being used as the start position and the end position of the predicted head entity; Determine the predicted head entity based on the probability that the word unit corresponding to each feature vector is the start position and the end position of the predicted head entity; Acquire a feature representation vector group of the predicted header entity, and concatenate the feature representation vector group of the predicted header entity with the feature representation vector group of the sample text to obtain a concatenated feature representation vector group; Based on the concatenated feature representation vector group, determining the probability that the word unit corresponding to each feature vector is used as the start position and the end position of the predicted tail entity corresponding to the predicted head entity; Based on the probability that the word unit corresponding to each feature vector is the start position and the end position of the predicted tail entity corresponding to the predicted head entity, the predicted tail entity and the relationship between the predicted head entity and the predicted tail entity are determined to obtain a prediction group; Determining a loss value based on the prediction group and the label group; The joint extraction model is trained based on the loss value until a training stop condition is reached.
2. The joint extraction model training method according to claim 1, characterized in that: The obtaining of sample text and tag groups includes: Acquire multiple sample texts and labels of each sample text from a corpus, wherein the corpus includes an event extraction corpus and an information extraction corpus; A label group for each sample text is determined based on the label for each sample text.
3. The joint extraction model training method according to claim 2, characterized in that: If the sample text is obtained from the corpus extracted from the event, the label of the sample text includes a trigger word, an argument role, and an entity corresponding to the argument role, and determining the label group of each sample text based on the label of each sample text includes: The trigger words, argument roles, and entities corresponding to the argument roles in the labels of the sample text are determined as a label group.
4. The joint extraction model training method according to claim 2, characterized in that: If the sample text is obtained from the corpus of the information extraction, the label of the sample text includes a triple, and the triple is used to characterize the relationship between entities in the sample text, and the label group of each sample text is determined based on the label of each sample text, including: The label of the sample text is determined as a label group of the sample text.
5. The joint extraction model training method according to claim 1, characterized in that: The training of the joint extraction model based on the loss value until a training stop condition is reached includes: If the loss value is greater than or equal to a preset threshold, continue training the joint extraction model; If the loss value is less than the preset threshold, the training is stopped.
6. A joint extraction method, characterized in that: The method comprises: Get the text to be extracted; Input the text to be extracted into the encoding layer of the joint extraction model to obtain a feature representation vector group of the text to be extracted, and input the feature representation vector group of the text to be extracted into the first prediction layer of the joint extraction model to determine the head entity in the text to be extracted, wherein the joint extraction model is trained by the joint extraction model training method according to any one of claims 1 to 5 above; The feature representation vector group of the head entity is obtained, and the feature representation vector group of the head entity and the feature representation vector group of the text to be extracted are simultaneously input into the second prediction layer of the joint extraction model to obtain the extraction result of the text to be extracted.
7. A joint extraction model training device, characterized in that: The device comprises: A first acquisition module is used to acquire sample text and a tag group, wherein the tag group is used to characterize the relationship between entities in the sample text, the entities include named entities and trigger words in the sample text, and the trigger words are used to characterize the behavior in the sample text; A first prediction module is used to input the sample text into the encoding layer of the joint extraction model to obtain a feature representation vector group of the sample text; based on the feature representation vector group of the sample text, determine the probability that the word unit corresponding to each feature vector in the feature representation vector group is used as the starting position and the ending position of the predicted head entity; based on the probability that the word unit corresponding to each feature vector is used as the starting position and the ending position of the predicted head entity, determine the predicted head entity; A second prediction module is used to obtain a feature representation vector group of the predicted head entity, and concatenate the feature representation vector group of the predicted head entity with the feature representation vector group of the sample text to obtain a concatenated feature representation vector group; based on the concatenated feature representation vector group, determine the probability that the word unit corresponding to each feature vector is the starting position and the ending position of the predicted tail entity corresponding to the predicted head entity; based on the probability that the word unit corresponding to each feature vector is the starting position and the ending position of the predicted tail entity corresponding to the predicted head entity, determine the predicted tail entity and the relationship between the predicted head entity and the predicted tail entity to obtain a prediction group; A determination module, configured to determine a loss value based on the prediction group and the label group; A training module is used to train the joint extraction model based on the loss value until a training stop condition is reached.
8. A combined extraction device, characterized in that: The device comprises: The second acquisition module is used to acquire the text to be extracted; A first determination module is used to input the text to be extracted into the encoding layer of the joint extraction model to obtain a feature representation vector group of the text to be extracted, and input the feature representation vector group of the text to be extracted into the first prediction layer of the joint extraction model to determine the head entity in the text to be extracted, wherein the joint extraction model is trained by the joint extraction model training method according to any one of claims 1 to 5 above; The second determination module is used to obtain the feature representation vector group of the head entity, and input the feature representation vector group of the head entity and the feature representation vector group of the text to be extracted into the second prediction layer of the joint extraction model at the same time to determine the extraction result of the text to be extracted.
9. A computing device comprising: Memory and processor; The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the steps of the joint extraction model training method described in any one of claims 1-5, or to implement the steps of the joint extraction method described in claim 6.
10. A computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of the joint extraction model training method described in any one of claims 1 to 5, or implement the steps of the joint extraction method described in claim 6.
Citation Information
Patent Citations
An entity relationship joint extraction method and system based on an attention mechanism
CN109902145A
Entity relationship extraction method, model training method and related devices
CN110413999A