A word processing method and device based on multi-task model

Through the combination of multi-task models, the shared feedforward neural network is used for entity recognition, relationship extraction and coreference resolution processing, which solves the problem of inability to share information between tasks in the existing technology and improves the accuracy of entity recognition and relationship extraction.

CN113761922BActive Publication Date: 2024-09-27BEIJING KINGSOFT DIGITAL ENTERTAINMENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010508099.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-06-05
Publication Date
2024-09-27
Estimated Expiration
2040-06-05

AI Technical Summary

Technical Problem

In the existing technology, entity recognition, relationship extraction and coreference resolution tasks are performed separately, and information cannot be shared, resulting in unsatisfactory results.

Method used

A word processing method based on a multi-task model is adopted. Through the combination of the entity recognition model, the relationship extraction model and the coreference resolution model, the feedforward neural network is shared to perform entity recognition processing, relationship extraction and coreference resolution processing to achieve information sharing.

Benefits of technology

It improves the accuracy and recall rate of entity recognition, relationship extraction and coreference resolution, and enhances the accuracy of word processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113761922B
    Figure CN113761922B
Patent Text Reader

Abstract

The present application provides a word processing method and device based on a multi-task model, wherein the method includes: obtaining a candidate entity segment, and generating a candidate entity segment encoding vector based on the candidate entity segment; performing entity recognition processing and classification pruning processing on the candidate entity segment encoding vector through an entity recognition model to obtain a recognition pruned encoding vector; inputting the recognition pruned encoding vector into a relationship extraction model for processing to determine the relationship between the words in the candidate entity segment; inputting the recognition pruned encoding vector into a coreference resolution model for processing to determine the coreference relationship between the words in the candidate entity segment. The method and device provided by the present application can improve the accuracy and recall rate of relationship extraction, coreference resolution, and entity recognition, and improve the accuracy of word processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a word processing method and device based on a multi-task model, a training method and device for a multi-task model, a computing device, and a computer-readable storage medium. Background Art

[0002] Entity recognition refers to identifying and extracting entities with specific meaning or strong referentiality in unstructured text, such as names of people, places, organizational structure names, dates and times, proper nouns, etc.

[0003] A relationship is a connection between two or more entities. Relationship extraction is to detect and identify certain semantic relationships between entities from text. For example, in the sentence "Beijing is the capital, political center and cultural center of China", the relationship expressed can be (China, capital, Beijing), (China, political center, Beijing) or (China, cultural center, Beijing).

[0004] Coreference resolution is a special type of relationship extraction. One of the entities in coreference resolution is usually a different way of saying another entity in the current context. The relationship between the two entities can be expressed as (entity 1, coreference, entity 2).

[0005] At present, the entity recognition task, relationship extraction task, and coreference resolution task of a sentence are all carried out separately. Information cannot be shared between multiple tasks, and they cannot constrain each other, which leads to unsatisfactory results of entity recognition, relationship extraction, and coreference resolution. Summary of the invention

[0006] In view of this, the embodiments of the present application provide a word processing method and device based on a multi-task model, a training method and device for a multi-task model, a computing device and a computer-readable storage medium to solve the technical defects existing in the prior art.

[0007] The present application embodiment provides a word processing method based on a multi-task model, including:

[0008] Obtaining a candidate entity segment, and generating a candidate entity segment encoding vector based on the candidate entity segment;

[0009] Performing entity recognition processing and classification pruning processing on the candidate entity fragment encoding vector through an entity recognition model to obtain a recognition pruning encoding vector;

[0010] Inputting the identified pruned encoding vector into a relation extraction model for processing to determine the relationship between words in the candidate entity segment;

[0011] The identified pruned coding vector is input into a coreference resolution model for processing to determine the coreference relationship between the words in the candidate entity segment.

[0012] Optionally, inputting the identified pruned encoding vector into a relation extraction model for processing to determine the relation between words in the candidate entity segment comprises:

[0013] Scoring the identification pruned coding vector through a relation extraction model, and pruning the identification pruned coding vector based on the score to obtain a relation extraction coding vector;

[0014] A first relationship pair encoding vector is generated based on the relationship extraction encoding vector, relationship extraction processing is performed on the first relationship pair encoding vector through the relationship extraction model to obtain a relationship extraction result, and the relationship between words in the candidate entity fragment is determined based on the relationship extraction result.

[0015] Optionally, inputting the identified pruned encoding vector into a coreference resolution model for processing to determine the coreference relationship between words in the candidate entity segment includes:

[0016] Scoring the identification pruned coding vector by a coreference resolution model, and pruning the identification pruned coding vector based on the score to obtain a coreference resolution coding vector;

[0017] A second relationship pair encoding vector is generated based on the coreference resolution encoding vector, coreference resolution processing is performed on the second relationship pair encoding vector through the coreference resolution model to obtain a coreference resolution result, and the coreference relationship between the words in the candidate entity fragment is determined based on the coreference resolution result.

[0018] Optionally, the entity recognition model, the relationship extraction model, and the coreference resolution model share a feedforward neural network for scoring;

[0019] The step of performing entity recognition processing and classification pruning processing on the candidate entity segment encoding vector through the entity recognition model to obtain the recognition pruning encoding vector includes:

[0020] Inputting the candidate entity segment encoding vector into an entity recognition model, and scoring the candidate entity segment encoding vector through the feedforward neural network;

[0021] The candidate entity fragment coding vectors are classified based on the scores of the candidate entity fragment coding vectors to obtain classification labels of the candidate entity fragment coding vectors, and the candidate entity fragment coding vectors are pruned to obtain recognized pruned coding vectors.

[0022] Optionally, the relationship extraction model and the entity recognition model share a feedforward neural network for scoring;

[0023] Scoring the recognition pruned coding vector by using a relation extraction model, and pruning the recognition pruned coding vector based on the score, including:

[0024] Inputting the recognition pruned coding vector into the relation extraction model, scoring the recognition pruned coding vector through the feedforward neural network, and obtaining a score of the recognition pruned coding vector;

[0025] The recognition pruned coding vectors with scores greater than or equal to a preset threshold are used as relation extraction coding vectors.

[0026] Optionally, the coreference resolution model and the entity recognition model share a feedforward neural network for scoring;

[0027] Scoring the recognition pruned coding vector by a coreference resolution model, and pruning the recognition pruned coding vector based on the score, including:

[0028] Inputting the recognition pruned coding vector into the coreference resolution model, scoring the recognition pruned coding vector through the feedforward neural network, and obtaining a score of the recognition pruned coding vector;

[0029] The recognition pruning coding vector with a score greater than or equal to a preset threshold is used as the coreference resolution coding vector.

[0030] Optionally, the extracting the encoding vector based on the relationship to generate the first relationship pair encoding vector comprises:

[0031] Obtaining a first initial relation pair encoding vector based on the relation extraction encoding vector and the classification label of the relation extraction encoding vector;

[0032] The first initial relationship pair coding vector is subjected to classification prediction processing, and the first initial relationship pair coding vector is pruned according to a preset ratio based on a result of the classification prediction to obtain a first relationship pair coding vector.

[0033] Optionally, the performing classification prediction processing on the first initial relationship pair encoding vector, and pruning the first initial relationship pair encoding vector according to a preset ratio based on a result of the classification prediction to obtain the first relationship pair encoding vector includes:

[0034] Scoring the first initial relationship pair encoding vector by a feedforward neural network to obtain a score of the first initial relationship pair encoding vector;

[0035] Performing classification prediction processing on the first initial relationship pair encoding vector to obtain a category of the first initial relationship pair encoding vector;

[0036] The first initial relationship pair encoding vector is pruned based on the category and score of the first initial relationship pair encoding vector to obtain a first relationship pair encoding vector.

[0037] Optionally, obtaining a first initial relationship pair encoding vector based on the relationship extraction encoding vector and a classification label of the relationship extraction encoding vector includes:

[0038] Encoding the classification label of the relation extraction encoding vector to generate a first label vector;

[0039] Based on any two of the relation extraction encoding vectors and their corresponding first label vectors, a first initial relation pair encoding vector of any two of the relation extraction encoding vectors is obtained.

[0040] Optionally, obtaining a first initial relationship pair encoding vector based on the relationship extraction encoding vector and a classification label of the relationship extraction encoding vector includes:

[0041] Encoding the classification label of the relation extraction encoding vector to generate a first label vector;

[0042] Determine a semantic vector between any two relation extraction encoding vectors based on positions of the any two relation extraction encoding vectors in the candidate entity fragment;

[0043] Based on any two of the relationship extraction encoding vectors, the semantic vector between the any two relationship extraction encoding vectors and the first label vector corresponding to each of the relationship extraction encoding vectors, a first initial relationship pair encoding vector of any two of the relationship extraction encoding vectors is obtained.

[0044] Optionally, determining the semantic vector between the arbitrary two relation extraction encoding vectors includes:

[0045] Determine multiple word vectors between the arbitrary two relation extraction encoding vectors;

[0046] Pooling or attention processing is performed on multiple word vectors between any two relationship extraction encoding vectors to obtain corresponding semantic vectors.

[0047] Optionally, obtaining a first initial relation pair encoding vector of any two of the relation extraction encoding vectors comprises:

[0048] According to the semantic relationship between any two of the relationship extraction coding vectors in the candidate entity fragment, the first initial relationship pair coding vector of the forward semantic relationship and the first initial relationship pair coding vector of the reverse semantic relationship of any two of the relationship extraction coding vectors are obtained respectively.

[0049] Optionally, scoring the first initial relationship pair encoding vector by a feedforward neural network to obtain a score of the first initial relationship pair encoding vector includes:

[0050] The first initial relationship pair encoding vector of the positive semantic relationship and the first initial relationship pair encoding vector of the reverse semantic relationship of any two of the relationship extraction encoding vectors are scored through a feedforward neural network, and the score of the first initial relationship pair encoding vector of the reverse semantic relationship is made less than a preset threshold.

[0051] Optionally, generating a second relation pair encoding vector based on the coreference resolution encoding vector includes:

[0052] Obtaining a second initial relation pair encoding vector based on the coreference resolution encoding vector and the classification label of the coreference resolution encoding vector;

[0053] The second initial relationship pair coding vector is subjected to classification prediction processing, and the second initial relationship pair coding vector is pruned according to a preset ratio based on a result of the classification prediction to obtain a second relationship pair coding vector.

[0054] Optionally, obtaining a second initial relation pair encoding vector based on the coreference resolution encoding vector and a classification label of the coreference resolution encoding vector includes:

[0055] Encoding the classification labels of the coreference elimination coding vector to generate a second label vector;

[0056] Based on any two of the coreference resolution coding vectors and their corresponding second label vectors, a second initial relation pair coding vector of any two of the coreference resolution coding vectors is obtained.

[0057] Optionally, obtaining a second initial relation pair encoding vector based on the coreference resolution encoding vector and a classification label of the coreference resolution encoding vector includes:

[0058] Encoding the classification labels of the coreference elimination coding vector to generate a second label vector;

[0059] Determine a semantic vector between any two coreference resolution coding vectors based on positions of the any two coreference resolution coding vectors in the candidate entity segment;

[0060] Based on any two of the coreference resolution coding vectors, the semantic vector between the any two coreference resolution coding vectors, and the second label vector corresponding to each of the coreference resolution coding vectors, a second initial relationship pair coding vector of any two of the coreference resolution coding vectors is obtained.

[0061] Optionally, determining the semantic vector between the arbitrary two coreference resolution coding vectors includes:

[0062] Determine a plurality of word vectors between the arbitrary two coreference resolution encoding vectors;

[0063] Pooling or attention processing is performed on multiple word vectors between any two coreference resolution encoding vectors to obtain corresponding semantic vectors.

[0064] Optionally, performing classification prediction processing on the second initial relationship pair encoding vector, and pruning the second initial relationship pair encoding vector according to a preset ratio based on a result of the classification prediction to obtain a second relationship pair encoding vector, includes:

[0065] Scoring the second initial relationship pair encoding vector by a feedforward neural network to obtain a score of the second initial relationship pair encoding vector;

[0066] Performing classification prediction processing on the second initial relationship pair encoding vector to obtain a category of the second initial relationship pair encoding vector;

[0067] The second initial relationship pair encoding vector is pruned based on the category and score of the second initial relationship pair encoding vector to obtain a second relationship pair encoding vector.

[0068] Optionally, performing relation extraction processing on the first relation pair encoding vector by using the relation extraction model to obtain a relation extraction result includes:

[0069] The first relationship pair encoding vector is scored using the relationship extraction model, and classification prediction processing is performed on the first relationship pair encoding vector based on the scoring result to obtain a relationship extraction result.

[0070] Optionally, performing coreference resolution processing on the second relationship pair encoding vector by using the coreference resolution model to obtain a coreference resolution result includes:

[0071] The second relationship pair encoding vector is scored using the coreference resolution model, and classification prediction processing is performed on the second relationship pair encoding vector based on the scoring result to obtain a coreference resolution result.

[0072] The present application embodiment discloses a multi-task model training method, including:

[0073] Obtain at least two sample candidate entity pairs and a classification label of each of the sample candidate entity pairs, and generate a sample candidate entity fragment encoding vector based on the sample candidate entities of each sample candidate entity pair;

[0074] Performing entity recognition processing and classification pruning processing on the sample candidate entity fragment encoding vector through an entity recognition model to obtain a sample recognition pruning encoding vector;

[0075] Inputting the sample identification pruning coding vector into the relation extraction model and the coreference resolution model for processing respectively, to obtain a first sample relation pair coding vector and a second sample relation pair coding vector;

[0076] Based on the sample identification pruning coding vector, the first sample relationship pair coding vector, and the second sample relationship pair coding vector, the loss values ​​of the entity recognition model, the relationship extraction model, and the coreference resolution model are respectively determined, and the entity recognition model, the relationship extraction model, and the coreference resolution model are trained.

[0077] Optionally, the sample identification pruning coding vector is input into a relation extraction model and a coreference resolution model for processing respectively to obtain a first sample relation pair coding vector and a second sample relation pair coding vector, including:

[0078] Inputting the sample identification pruned coding vector into the relationship extraction model, scoring the sample identification pruned coding vector through the relationship extraction model, and pruning the sample identification pruned coding vector based on the score to obtain a sample relationship extraction coding vector, and generating a first sample relationship pair coding vector based on the sample relationship extraction coding vector;

[0079] The sample identification pruned coding vector is input into the coreference resolution model, the sample identification pruned coding vector is scored by the coreference resolution model, and the sample identification pruned coding vector is pruned based on the score to obtain a sample coreference resolution coding vector, and a second sample relationship pair coding vector is generated based on the sample coreference resolution coding vector.

[0080] Optionally, determining the loss values ​​of the entity recognition model, the relationship extraction model, and the coreference resolution model based on the sample recognition pruning encoding vector, the first sample relationship pair encoding vector, and the second sample relationship pair encoding vector, respectively, includes:

[0081] The loss value of the entity recognition model is calculated using a cross entropy loss function based on the score of the sample recognition pruned coding vector and the classification label of the sample recognition pruned coding vector;

[0082] Calculate the loss value of the relationship extraction model using a cross entropy loss function based on the score of the first sample relationship pair encoding vector and the classification label of the first sample relationship pair encoding vector;

[0083] Based on the score of the second sample relationship pair encoding vector and the classification label of the second sample relationship pair encoding vector, a cross entropy loss function is used to calculate the loss value of the coreference resolution model.

[0084] Optionally, the first sample relationship pair encoding vector includes two sample relationship extraction encoding vectors;

[0085] The loss value of the relationship extraction model is calculated using a cross entropy loss function based on the first sample relationship pair encoding vector and the classification label of the first sample relationship pair encoding vector, including:

[0086] In the case where the classification label is a symmetric relationship label, two sample relationship extraction code vectors of the first sample relationship pair code vector are reversely arranged to generate a reverse first sample relationship pair code vector;

[0087] The first sample relationship pair encoding vector and the classification label, the reverse first sample relationship pair encoding vector and the classification label are respectively used to calculate the loss value of the relationship extraction model using the cross entropy loss function.

[0088] The embodiment of the present application discloses a word processing device based on a multi-task model, comprising:

[0089] An entity segment acquisition module is configured to acquire candidate entity segments and generate candidate entity segment encoding vectors based on the candidate entity segments;

[0090] An entity recognition pruning module is configured to perform entity recognition processing and classification pruning processing on the candidate entity segment encoding vector through an entity recognition model to obtain a recognition pruning encoding vector;

[0091] A relation extraction processing module, configured to input the identified pruned encoding vector into a relation extraction model for processing, and determine the relationship between words in the candidate entity segment;

[0092] The coreference resolution processing module is configured to input the identified pruned coding vector into a coreference resolution model for processing, and determine the coreference relationship between the words in the candidate entity segment.

[0093] The present application embodiment discloses a multi-task model training device, including:

[0094] A sample acquisition module is configured to acquire at least two sample candidate entity pairs and a classification label of each of the sample candidate entity pairs, and generate a sample candidate entity fragment encoding vector based on the sample candidate entity of each sample candidate entity pair;

[0095] A sample recognition module is configured to perform entity recognition processing and classification pruning processing on the sample candidate entity fragment encoding vector through an entity recognition model to obtain a sample recognition pruning encoding vector;

[0096] A sample processing module is configured to input the sample identification pruning coding vector into a relation extraction model and a coreference resolution model for processing, respectively, to obtain a first sample relation pair coding vector and a second sample relation pair coding vector;

[0097] The model training module is configured to determine the loss values ​​of the entity recognition model, the relationship extraction model and the coreference resolution model based on the sample recognition pruning coding vector, the first sample relationship pair coding vector and the second sample relationship pair coding vector, and train the entity recognition model, the relationship extraction model and the coreference resolution model.

[0098] An embodiment of the present application discloses a computing device, including a memory, a processor, and computer instructions stored in the memory and executable on the processor. When the processor executes the instructions, the steps of the word processing method of the multi-task model or the training method of the multi-task model as described above are implemented.

[0099] An embodiment of the present application discloses a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of the word processing method of the multi-task model or the training method of the multi-task model as described above.

[0100] The word processing method and device based on the multi-task model provided in the present application first perform entity recognition processing and classification pruning processing on the candidate entity fragment coding vector through the entity recognition model to obtain the recognition pruned coding vector, so as to reduce the negative examples in the candidate entity fragment coding vector, and then process the recognition pruned coding vector through the relationship extraction model and the coreference resolution model respectively, which can enhance the understanding of the candidate entity fragment by the relationship extraction model and the coreference resolution model, provide a basis for the execution of the relationship extraction task and the coreference resolution task, and effectively improve the accuracy of word processing.

[0101] The word processing method and device based on the multi-task model provided in the present application realize the organic combination of the relationship extraction model, the coreference resolution model, and the entity recognition model, realize the organic combination of the relationship extraction task, the coreference resolution task, and the entity recognition task, and realize the sharing of information in the above three tasks, which can effectively improve the accuracy and recall rate of relationship extraction, coreference resolution, and entity recognition, and effectively improve the accuracy of word processing based on the multi-task model for determining word relationships.

[0102] Secondly, in this embodiment, based on the semantic relationship between any two relationship extraction coding vectors in the candidate entity fragment, the first initial relationship pair coding vector of the forward semantic relationship and the first initial relationship pair coding vector of the reverse semantic relationship of any two relationship extraction coding vectors are obtained respectively, thereby introducing the consideration of semantic relationship in the process of obtaining the relationship extraction result, so that the relationship extraction result can be more accurate.

[0103] The training method and device of the multi-task model provided in the present application first organically combine the relationship extraction task, the coreference resolution task, and the entity recognition task during the training process, and then train the relationship extraction model, the coreference resolution model, and the entity recognition model separately, which can effectively improve the effect of model training and improve the performance of the relationship extraction model, the coreference resolution model, and the entity recognition model. BRIEF DESCRIPTION OF THE DRAWINGS

[0104] Figure 1 is a structural diagram of a multi-task model according to an embodiment of the present application;

[0105] Figure 2 is a schematic diagram of the steps of a word processing method based on a multi-task model according to an embodiment of the present application;

[0106] Figure 3 is a flowchart of steps of a word processing method based on a multi-task model according to another embodiment of the present application;

[0107] Figure 4 It is a flowchart of the steps of the training method of the multi-task model described in one embodiment of the present application;

[0108] Figure 5 is a structural diagram of a word processing device based on a multi-task model according to an embodiment of the present application;

[0109] Figure 6 It is a structural schematic diagram of a training device for a multi-task model according to an embodiment of the present application;

[0110] Figure 7 It is a schematic diagram of the structure of a computing device described in an embodiment of the present application. DETAILED DESCRIPTION

[0111] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application 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 the present application, so the present application is not limited by the specific implementation disclosed below.

[0112] 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.

[0113] 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, such 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.

[0114] First, the terms involved in one or more embodiments of the present invention are explained.

[0115] Entity recognition: refers to identifying and extracting entities with specific meaning or strong referentiality in unstructured text, such as names of people, places, organizational structure names, dates and times, proper nouns, etc.

[0116] Entity Recognition Model: A model used to perform entity recognition tasks.

[0117] Relation extraction: Detect and identify certain semantic relationships between entities from the text, such as the sentence "Beijing is the capital, political center and cultural center of China", where the relationship expressed can be (China, capital, Beijing), (China, political center, Beijing) or (China, cultural center, Beijing).

[0118] Relation extraction model: A model used to perform relation extraction tasks.

[0119] Co-reference resolution: a special relationship extraction. One of the entities in co-reference resolution is usually a different way of saying another entity in the current context. The relationship between the two entities can be expressed as (entity 1, co-reference, entity 2).

[0120] Coreference Resolution Model: A model for performing coreference resolution tasks.

[0121] Candidate entity fragment (span): a fragment consisting of one or more words in a sentence.

[0122] Candidate entity span encoding vector (span embedding): The vector generated by the candidate entity span after the encoder's encoding process.

[0123] Identify pruned encoding vector: the encoding vector remaining after the candidate entity segment encoding vector is pruned.

[0124] Pruning: Filter according to preset rules.

[0125] Relation extraction encoding vector: the encoding vector remaining after pruning the recognition pruned encoding vector based on the relation extraction processing result.

[0126] First label vector: an encoding vector obtained by encoding the classification label of the relation extraction encoding vector.

[0127] The first initial relationship pair encoding vector is an encoding vector formed by combining the two relationship extraction encoding vectors and their first label vectors and the distance feature vectors.

[0128] First relation pair encoding vector: the encoding vector remaining after pruning the first initial relation pair encoding vector based on the score of the first initial relation pair encoding vector.

[0129] Co-reference resolution code vector: the code vector remaining after pruning the recognition pruned code vector based on the result of the coreference resolution process.

[0130] Second label vector: an encoding vector obtained by encoding the classification label of the coreference resolution encoding vector.

[0131] Second relationship pair encoding vector: an encoding vector formed by combining two coreference resolution encoding vectors and their second label vectors and a distance feature vector.

[0132] Feedforward Neural Network (FFNN): A simplest neural network, where neurons are arranged in layers, each neuron is only connected to the neurons in the previous layer, receives the output of the previous layer, and outputs it to the next layer. There is no feedback between the layers. It is one of the most widely used and fastest growing artificial neural networks. In this application, the entity recognition model, the relationship extraction model, and the coreference resolution model share a feedforward neural network for scoring.

[0133] Convolutional Neural Networks (CNN): is a type of feedforward neural network that includes convolution calculations and has a deep structure. It is one of the representative algorithms of deep learning. In this application, the character-level features corresponding to each word are obtained through CNN network encoding.

[0134] Classification label: A label used to identify the type of encoded vector.

[0135] Accuracy: refers to the ratio of the number of correctly identified entities to the number of identified entities. The value is between 0 and 1. The larger the value, the higher the accuracy.

[0136] Recall rate: refers to the ratio of the number of correctly identified entities to the number of entities in the sample. The value is between 0 and 1. The larger the value, the higher the recall rate.

[0137] Weighted harmonic mean: also known as F1 value, F1 value = (2*accuracy*recall) / (accuracy+recall).

[0138] In the present application, a word processing method and apparatus based on a multi-task model, a training method and apparatus for a multi-task model, a computing device and a computer-readable storage medium are provided, which are described in detail one by one in the following embodiments.

[0139] like Figure 1 As shown, this embodiment provides a multi-task model, which is used in the multi-task model-based word processing method described in this application, including an encoder, an entity recognition model, a relationship extraction model and a coreference resolution model, wherein the entity recognition model, the relationship extraction model and the coreference resolution model share a feedforward neural network.

[0140] The entity recognition model is a model for identifying entities in unstructured input text. In this embodiment, the entity recognition model performs entity recognition processing and classification pruning processing on the candidate entity fragment encoding vector to obtain a recognition pruned encoding vector.

[0141] The relationship extraction model is a model used to detect, identify, and extract semantic relationships between entities. In this embodiment, the relationship extraction model scores the recognition pruned coding vector and prunes the recognition pruned coding vector based on the score to obtain a relationship extraction coding vector; a first relationship pair coding vector is generated based on the relationship extraction coding vector, and the first relationship pair coding vector is subjected to relationship extraction processing by the relationship extraction model to obtain a relationship extraction result, and the relationship between words in the candidate entity fragment is determined based on the relationship extraction result.

[0142] The coreference resolution model is a model for detecting, identifying, and extracting entities with coreference relationships. In this embodiment, the coreference resolution model scores the recognition pruned coding vector and prunes the recognition pruned coding vector based on the score to obtain a coreference resolution coding vector; a second relationship pair coding vector is generated based on the coreference resolution coding vector, and the second relationship pair coding vector is processed by the coreference resolution model to obtain a coreference resolution result, and the relationship between words in the candidate entity fragment is determined based on the coreference resolution result.

[0143] The multi-task model provided in this embodiment organically combines the relationship extraction model, entity recognition model, and coreference resolution model. The three share a feedforward neural network for scoring, which can realize information sharing among the relationship extraction model, entity recognition model, and coreference resolution model, thereby improving the accuracy and recall rate of the above-mentioned relationship extraction model, entity recognition model, and coreference resolution model.

[0144] like Figure 2 As shown, Figure 2 It is a flowchart showing the steps of a word processing method based on a multi-task model according to an embodiment of the present application, including steps S210 to S240, wherein step S230 and step S240 are parallel steps and there is no necessary order of execution.

[0145] S210: Obtain a candidate entity segment, and generate a candidate entity segment encoding vector based on the candidate entity segment.

[0146] The candidate entity segment is a word set composed of one or more words in the target sentence, target paragraph, or target article, and each word represents an entity. Specifically, the candidate entity segment can be obtained by performing word segmentation on the target sentence, target paragraph, or target article, and then extracting one or more target words from the result of the word segmentation to form a word set.

[0147] For example, suppose that after word segmentation processing is performed on the target sentence, 10 words including word segmentation processing results A1-A10 are obtained, and a word set consisting of A1-A6 is extracted from the above word segmentation processing results, and the above word set is used as a candidate entity segment.

[0148] In practical applications, the candidate entity fragments may be input into an encoder for encoding processing to generate a candidate entity fragment encoding vector.

[0149] In this embodiment, the encoder includes a bidirectional LSTM, a pre-trained BERT model, a CNN network, and any combination thereof.

[0150] Preferably, a sentence containing several candidate entity fragments is first encoded by a pre-trained BERT model to obtain a word-level feature vector of the sentence, and then encoded by a CNN network to obtain a character-level feature vector of the sentence. The word-level feature vector and the character-level feature vector are concatenated to obtain a concatenated vector, and then the concatenated vector is encoded by a bidirectional LSTM network to obtain a feature vector with context features. Finally, the encoding vector of each candidate entity fragment is calculated based on the extracted candidate entity fragments using an attention mechanism. The encoding vector of the candidate entity fragment can be expressed by the following formula:

[0151]

[0152] Among them, g i The encoding vector representing the candidate entity fragment, x START(i) * 、x END(i) * The vector representing the start and end positions of the candidate entity fragment, Φ (i) represents additional features, It represents the result of calculating the words in each candidate entity segment based on the attention mechanism. The specific calculation process is as follows:

[0153]

[0154]

[0155]

[0156]

[0157] Specifically, t represents the candidate entity segment, i represents the word in the candidate entity segment, and formula (2) represents the encoding vector x corresponding to each word in the candidate entity segment t * The vector (h) output by the forward propagation of the bidirectional LSTM t,1 ) and the vector of back-propagation output (h t,-1 ), formula (3) indicates that the parameter α of the candidate entity segment t is obtained by multiplying its parameter w with the score of the candidate entity segment given by the feedforward neural network, and formula (4) indicates the weight a of each word in the candidate entity segment i,t Based on the parameter α of the candidate entity segment in which it is located and the total parameter of the word in the candidate entity segment, formula (5) represents the encoding vector corresponding to each word in the candidate entity segment: The weight parameter a of the word in the candidate entity segment i,t and the candidate entity fragment encoding vector xt get.

[0158] This embodiment obtains candidate entity segments and performs encoding processing on the candidate entity segments to prepare for the execution of other subsequent tasks, thereby improving the efficiency of the execution of subsequent tasks.

[0159] S220. Perform entity recognition processing and classification pruning processing on the candidate entity fragment encoding vector through an entity recognition model to obtain a recognition pruning encoding vector.

[0160] It should be noted that, in this embodiment, the entity recognition model, the relationship extraction model, and the coreference resolution model share a feedforward neural network for scoring.

[0161] Specifically, the step S220 may also include steps S221 and S222.

[0162] S221. Input the candidate entity segment encoding vector into an entity recognition model, and score the candidate entity segment encoding vector through the feedforward neural network.

[0163] The score of each candidate entity segment coding vector is composed of a basic score (Mention score) and a classification score (classifier score), and the above basic score and classification score are obtained by scoring through a feedforward neural network. The score of the candidate entity segment coding vector can be the sum of the basic score and the classification score, the average value, the weighted average value, etc., and this application does not limit this.

[0164] The feedforward neural network uses the principle of deep learning to score the candidate entity fragment coding vector. Specifically, the candidate entity fragment coding vector is calculated or encoded again by using the feedforward neural network, and the corresponding score is mapped to obtain the score of the candidate entity fragment coding vector. It should be noted that the mapping of the score by the feedforward neural network can be continuously adjusted through the execution of subsequent tasks, the calculation of loss values, the return of gradients, etc. The score of the candidate entity fragment coding vector can be a ten-point score, a hundred-point score, a thousand-point score, etc., and this application does not limit this.

[0165] This embodiment scores the candidate entity segment encoding vectors and then performs entity recognition processing, which can improve the accuracy of entity recognition processing and improve the effect of the entity recognition model.

[0166] S222. Classify the candidate entity fragment coding vector based on the score of the candidate entity fragment coding vector to obtain a classification label of the candidate entity fragment coding vector, and prune the candidate entity fragment coding vector to obtain a recognized pruned coding vector.

[0167] In practical applications, the candidate entity fragment coding vectors are classified based on their scores to obtain a classification label for each candidate entity fragment coding vector, and then the category to which each candidate entity fragment coding vector belongs can be obtained. A certain proportion of the candidate entity fragment coding vectors in one or several categories can be pruned according to the classification results, and the remaining candidate entity fragment coding vectors can be used as identification pruned coding vectors. Alternatively, candidate entity fragment coding vectors with scores less than a preset threshold can be pruned, and the remaining candidate entity fragment coding vectors can be used as identification pruned coding vectors. The present application does not impose any restrictions on this.

[0168] For example, suppose the candidate entity fragment encoding vectors exist in n categories, namely, the first category, the second category, ... the nth category, among which the nth category is a negative example, that is, all candidate entity fragment encoding vectors that do not belong to the previous category are classified as the nth category. After classification, m1 of the m candidate entity fragment encoding vectors belong to the first category, m2 belong to the second category, ... m n belongs to the nth class (m1+m2+…m n =m), then the candidate entity segment encoding vectors can be pruned in the following three ways: (1) p1% of the candidate entity segment encoding vectors are pruned in the first category, p2% of the candidate entity segment encoding vectors are pruned in the second category, and so on. n % of the candidate entity fragment encoding vectors, and the remaining candidate entity fragment encoding vectors are used as recognition pruning encoding vectors, where p1, p2, ... n The values ​​of can be the same or different; (2) The encoding vectors of candidate entity fragments of the first, second, ..., n-1th categories are not pruned, and the encoding vectors of candidate entity fragments of the nth category are pruned. n % of the candidate entity fragment coding vectors, and the remaining candidate entity fragment coding vectors are used as recognition pruned coding vectors; (3) the candidate entity fragment coding vectors whose scores of one or more categories are less than a preset threshold are pruned, and the remaining candidate entity fragment coding vectors are used as recognition pruned coding vectors, wherein the preset threshold of the score can be determined according to the specific situation, and the present application does not impose any restrictions on this.

[0169] In this embodiment, classification and pruning of candidate entity fragment encoding vectors helps to improve the quality of input encoding vectors for subsequent relationship extraction models and coreference resolution models, laying a foundation for the execution of relationship extraction tasks and coreference resolution tasks.

[0170] S230: Input the identified pruned coding vector into a relation extraction model for processing to determine the relationship between the words in the candidate entity segment.

[0171] Specifically, the step S230 may also include steps S231 to S232.

[0172] S231. Score the recognition pruned coding vector through a relation extraction model, and prune the recognition pruned coding vector based on the score to obtain a relation extraction coding vector.

[0173] Specifically, the recognition pruned coding vector can be input into the relationship extraction model, and the recognition pruned coding vector can be scored by the feedforward neural network to obtain the score of the recognition pruned coding vector, and then the recognition pruned coding vector with a score greater than or equal to a preset threshold is used as the relationship extraction coding vector.

[0174] Among them, the score of each recognition pruned code vector is composed of a basic score and a classification score, and the above basic score and classification score are both obtained by scoring through a feedforward neural network.

[0175] This embodiment scores the recognition pruned coding vector and further processes the recognition pruned coding vector based on the entity recognition task, which helps to pave the way for the execution of the subsequent relationship extraction task.

[0176] S232. Generate a first relationship pair encoding vector based on the relationship extraction encoding vector, perform relationship extraction processing on the first relationship pair encoding vector through the relationship extraction model to obtain a relationship extraction result, and determine the relationship between the words in the candidate entity fragment based on the relationship extraction result.

[0177] Specifically, the step S232 may also include steps S2321 to S2323.

[0178] S2321. Obtain a first initial relationship pair encoding vector based on the relationship extraction encoding vector and the classification label of the relationship extraction encoding vector.

[0179] Specifically, the classification label of the relationship extraction encoding vector may be encoded to generate a first label vector; and a first initial relationship pair encoding vector may be obtained based on the relationship extraction encoding vector and the first label vector.

[0180] In practical applications, each first initial relationship pair encoding vector is composed of two relationship extraction encoding vectors and classification label encoding vectors corresponding to the two relationship extraction encoding vectors. In other words, the relationship extraction encoding vectors of the two words in the candidate entity segment and the first label vectors of the two words can be concatenated to obtain the first initial relationship pair encoding vector, as shown below:

[0181] span_pair_embeddings=torch.cat([span1_embeddings, span2_embeddings, span1_embeddings*span2_embeddings, span1_label_embedding, span2_label_embedding], -1).

[0182] Among them, torch.cat is a function used to splice two or more vectors together, span_pair_embeddings represents the first initial relationship pair encoding vector, span1_embeddings represents the relationship extraction encoding vector 1, span2_embeddings represents the relationship extraction encoding vector 2, span1_label_embedding represents the label vector of the relationship extraction encoding vector 1, and span2_label_embedding represents the label vector of the relationship extraction encoding vector 2.

[0183] It should be noted that the classification label is a type of feature information of the candidate entity fragment. In addition, other types of feature information, such as distance, etc., can be combined when generating the first initial relationship pair encoding vector, depending on the specific situation. This application does not impose any restrictions on this.

[0184] For example, the relationship extraction encoding vectors of two words in the candidate entity segment, the first label vectors of the two words, and the distance feature vector between the two words can be concatenated to obtain the first initial relationship pair encoding vector, as shown below:

[0185] span_pair_embeddings=torch.cat([span1_embeddings, span2_embeddings, span1_embeddings*span2_embeddings, antecedent_distance_embeddings, span1_label_embedding, span2_label_embedding], -1).

[0186] Among them, torch.cat is a function used to splice two or more vectors together, span_pair_embeddings represents the first initial relationship pair encoding vector, span1_embeddings represents the relationship extraction encoding vector 1, span2_embeddings represents the relationship extraction encoding vector 2, antecedent_distance_embeddings represents the distance feature vector between the relationship extraction encoding vector 1 and the relationship extraction encoding vector 2, span1_label_embedding represents the label vector of the relationship extraction encoding vector 1, and span2_label_embedding represents the label vector of the relationship extraction encoding vector 2.

[0187] For another example, a specific method for generating the first initial relationship pair encoding vector includes:

[0188] Encoding the classification label of the relation extraction encoding vector to generate a first label vector;

[0189] Determine a semantic vector between any two relation extraction encoding vectors based on positions of the any two relation extraction encoding vectors in the candidate entity fragment;

[0190] Based on any two of the relationship extraction encoding vectors, the semantic vector between the any two relationship extraction encoding vectors and the first label vector corresponding to each of the relationship extraction encoding vectors, a first initial relationship pair encoding vector of any two of the relationship extraction encoding vectors is obtained.

[0191] Specifically, determining the semantic vector between any two relationship extraction encoding vectors includes: determining multiple word vectors between the any two relationship extraction encoding vectors; performing pooling or attention processing on the multiple word vectors between any two relationship extraction encoding vectors to obtain a corresponding semantic vector.

[0192] In a specific application, for the candidate entity fragment [w1, w2, …, wx-1, wx], [w1, w2] is the relationship extraction coding vector span1, [wx-1, wx] is the relationship extraction coding vector span2, then [w3, …, wx-2] is the word vector between any two relationship extraction coding vectors span1 and span2, and the word vector [w3, …, wx-2] between the two relationship extraction coding vectors span1 and span2 is pooled or paid attention to obtain the corresponding semantic vector, thereby increasing the semantic information of the first initial relationship pair coding vector and enhancing the expressiveness of the first initial relationship pair coding vector.

[0193] Regarding the pooling process, it should be noted that for the word vector [w3, ..., wx-2], if all this information is retained, there will be information redundancy, which increases the difficulty of calculation. At this time, the pooling process is equivalent to a dimensionality reduction operation to compress the vector and retain the main features. The pooling process is to take the maximum value or average value of a small matrix area to replace the area, so as to obtain the final semantic vector. The size of the small matrix can be set according to actual needs.

[0194] For attention processing, the calculation formula is as shown in the above formulas (3) to (5), which will not be repeated here.

[0195] Specifically, the calculation formula of the first initial relationship encoding vector is as follows:

[0196] span_pair_embeddings=torch.cat([span1_embeddings, span2_embeddings, span1_embeddings*span2_embeddings, segment_info, span1_label_embedding, span2_label_embedding], -1).

[0197] Among them, torch.cat is a function used to splice two or more vectors together, span_pair_embeddings represents the first initial relation pair encoding vector, span1_embeddings represents relation extraction encoding vector 1, span2_embeddings represents relation extraction encoding vector 2, segment_info represents the word vector between relation extraction encoding vector 1 and relation extraction encoding vector 2, span1_label_embedding represents the label vector of relation extraction encoding vector 1, and span2_label_embedding represents the label vector of relation extraction encoding vector 2.

[0198] It should be noted that in the process of calculating span_pair_embeddings, not all words can have a relationship. For example, in a paragraph of text, words that are far apart basically have no relationship. Therefore, a distance threshold is set in this embodiment. If the distance between span1 and span2 exceeds the threshold, the span_pair_embeddings of span1 and span2 are directly pruned. The value of the distance threshold can be set according to actual needs, for example, the distance threshold is set to 60 word units.

[0199] Optionally, obtaining the first initial relationship pair encoding vector of any two of the relationship extraction encoding vectors includes: according to the semantic relationship between any two of the relationship extraction encoding vectors in the candidate entity fragment, respectively obtaining the first initial relationship pair encoding vector of the forward semantic relationship and the first initial relationship pair encoding vector of the reverse semantic relationship of any two of the relationship extraction encoding vectors.

[0200] That is, when span_pair_embeddings are generated, both span_pair_embedding12 and span_pair_embedding21 are generated.

[0201] It should be noted that the positive and negative semantic relationships are not necessarily consistent with the specific arrangement order. Here, it is assumed that the relationship is an asymmetric relationship, and the positive semantic relationship is considered to be correct and consistent with the annotation, while the negative semantic relationship is incorrect and inconsistent with the data annotation. For example, if method is used for task, then [span1(method)span2(task)] is considered to be the correct relationship of the positive semantic relationship, and the reverse order is the wrong negative relationship. At this time, span1 and span2 are arranged in the order of first and last.

[0202] But if we change the notation, if it is part of, the possible expressions in the sentence are 1) span1 is part of span2; 2) span 1 includes span2.

[0203] In both sentences, the span pairs are marked as a part of relationship, but the positive semantic relationship in 1) is [span1 span2], while the positive semantic relationship in 2) is [span2 span1].

[0204] This embodiment obtains a first initial relationship pair encoding vector based on the relationship extraction encoding vector and the classification label of the relationship extraction encoding vector, which helps to improve the execution efficiency and effect of the relationship extraction task.

[0205] S2322. Perform classification prediction processing on the first initial relationship pair coding vector, and prune the first initial relationship pair coding vector according to a preset ratio based on the classification prediction result to obtain a first relationship pair coding vector.

[0206] Specifically, the first initial relationship pair encoding vector can be scored through a feedforward neural network to obtain the score of the first initial relationship pair encoding vector; the first initial relationship pair encoding vector can be classified and predicted to obtain the category of the first initial relationship pair encoding vector; the first initial relationship pair encoding vector can be pruned based on the category and score of the first initial relationship pair encoding vector to obtain the first relationship pair encoding vector.

[0207] In practical applications, the category of the first initial relationship pair encoding vector can be determined by the softmax function. The formula of the softmax function is as follows:

[0208]

[0209] Among them, Si represents the softmax value corresponding to the i-th first initial relationship pair encoding vector; i represents the i-th first initial relationship pair encoding vector; j represents the total number of first initial relationship pair encoding vectors.

[0210] Specifically, the category of the first initial relationship pair encoding vector is the category of the relationship between the two words therein. In practical applications, the first initial relationship pair encoding vector can also be pruned based on the category and score of the first initial relationship pair encoding vector. A certain proportion of one or more categories of first initial relationship pair encoding vectors can be pruned, or first initial relationship pair encoding vectors with scores less than a preset threshold can be pruned. This can be determined based on the specific situation, and the present application does not impose any restrictions on this.

[0211] Optionally, in the case where the classification label is a directional classification label, it is a label attribute with obvious directionality, such as used for. Since the labeled data is usually [method (head entity label), used for (relationship label), task (tail entity label)], it is not the other way around. Therefore, according to this classification score, pruning is performed according to the preset proportions according to the categories. When obtaining the pair span-embeddings that make up the high scores, it is necessary to especially compare the scores of pair span-embedding12 and pair span-embedding21 in the current category. If pair span-embedding12 is relatively high in the current category, then pair span-embedding21 should be a negative example, so it is forced to be given a very low score. In the actual application stage, the score can be set to 0 or other scores.

[0212] Specifically, the first initial relationship pair encoding vector is scored through a feedforward neural network to obtain the score of the first initial relationship pair encoding vector, including: scoring the first initial relationship pair encoding vector of the forward semantic relationship and the first initial relationship pair encoding vector of the reverse semantic relationship of any two of the relationship extraction encoding vectors through a feedforward neural network, and making the score of the first initial relationship pair encoding vector of the reverse semantic relationship less than a preset threshold.

[0213] In this embodiment, the preset threshold value can be set to multiple values, such as 0, or other values.

[0214] This embodiment obtains the first relationship pair encoding vector by scoring, classifying and pruning the first initial relationship pair encoding vector, which helps to further improve the execution efficiency and effect of the relationship extraction task.

[0215] S2323. Score the first relationship pair encoding vector through the relationship extraction model, and perform classification prediction processing on the first relationship pair encoding vector based on the scoring result to obtain a relationship extraction result, and determine the relationship between the words in the candidate entity fragment based on the relationship extraction result.

[0216] Specifically, the relationship extraction process includes scoring and classification prediction processing. In other words, the first relationship pair encoding vector is scored through the relationship extraction model, and the first relationship pair encoding vector is classified and predicted based on the scoring result, that is, the relationship extraction process is completed, the relationship extraction result is obtained, and the relationship between words is determined.

[0217] This embodiment performs relation extraction processing on the encoding vector of the first relation pair to determine the relationship between words, which can improve the accuracy of the relation extraction task and further effectively improve the accuracy of determining the relationship between words.

[0218] S240: Input the identified pruned coding vector into a coreference resolution model for processing to determine the coreference relationship between the words in the candidate entity segment.

[0219] Specifically, the step S240 may also include steps S241 to S242.

[0220] S241. Score the recognition pruned coding vector using a coreference resolution model, and prune the recognition pruned coding vector based on the score to obtain a coreference resolution coding vector.

[0221] Specifically, the recognition pruned coding vector can be input into the coreference resolution model, and the recognition pruned coding vector can be scored by the feedforward neural network to obtain the score of the recognition pruned coding vector, and then the recognition pruned coding vector with a score greater than or equal to a preset threshold is used as the coreference resolution coding vector.

[0222] Among them, the score of each recognition pruned code vector is composed of a basic score and a classification score, and the above basic score and classification score are both obtained by scoring through a feedforward neural network.

[0223] This embodiment scores the recognition pruned coding vectors and further processes the recognition pruned coding vectors based on the entity recognition task, which helps to pave the way for the subsequent coreference resolution task.

[0224] S242. Generate a second relationship pair encoding vector based on the coreference resolution encoding vector, perform coreference resolution processing on the second relationship pair encoding vector through the coreference resolution model to obtain a coreference resolution result, and determine the coreference relationship between the words in the candidate entity fragment based on the coreference resolution result.

[0225] Specifically, in the step S242, generating a second relationship pair encoding vector based on the coreference resolution encoding vector includes S2421-S2422:

[0226] S2421. Obtain a second initial relationship pair encoding vector based on the coreference resolution encoding vector and the classification label of the coreference resolution encoding vector.

[0227] In a specific implementation scheme, step S2421 includes: encoding the classification label of the coreference elimination coding vector to generate a second label vector; based on any two of the coreference elimination coding vectors and their corresponding second label vectors, obtaining a second initial relationship pair coding vector of any two of the coreference elimination coding vectors.

[0228] In practical applications, each second relationship pair encoding vector is composed of two coreference resolution encoding vectors and classification label encoding vectors corresponding to two coreference resolution encoding vectors. In other words, the coreference resolution encoding vectors of the two words in the candidate entity segment and the second label vectors of the two words can be concatenated to obtain the second relationship pair encoding vector, as shown below:

[0229] span_pair_embeddings=torch.cat([span1_embeddings, span2_embeddings, span1_embeddings*span2_embeddings, span1_label_embedding, span2_label_embedding], -1).

[0230] Among them, torch.cat is a function used to concatenate two or more vectors together, span_pair_embeddings represents the second relationship pair encoding vector, span1_embeddings represents the coreference resolution encoding vector 1, span2_embeddings represents the coreference resolution encoding vector 2, span1_label_embedding represents the label vector of the coreference resolution encoding vector 1, and span2_label_embedding represents the label vector of the coreference resolution encoding vector 2.

[0231] It should be noted that the classification label is a type of feature information of the candidate entity fragment. In addition, other types of feature information, such as distance, etc., can be combined when generating the second relationship pair encoding vector, depending on the specific situation. This application does not impose any restrictions on this.

[0232] For example, the coreference resolution encoding vectors of the two words in the candidate entity segment, the second label vectors of the two words, and the distance feature vector between the two words can be concatenated to obtain the second relationship pair encoding vector, as shown below:

[0233] span_pair_embeddings=torch.cat([span1_embeddings, span2_embeddings, span1_embeddings*span2_embeddings, antecedent_distance_embeddings, span1_label_embedding, span2_label_embedding], -1).

[0234] Among them, torch.cat is a function used to concatenate two or more vectors together, span_pair_embeddings represents the second relationship pair encoding vector, span1_embeddings represents the coreference resolution encoding vector 1, span2_embeddings represents the coreference resolution encoding vector 2, antecedent_distance_embeddings represents the distance feature vector between the coreference resolution encoding vector 1 and the coreference resolution encoding vector 2, span1_label_embedding represents the label vector of the coreference resolution encoding vector 1, and span2_label_embedding represents the label vector of the coreference resolution encoding vector 2.

[0235] This embodiment obtains a second relationship pair encoding vector based on the coreference resolution encoding vector and the classification label of the coreference resolution encoding vector, which helps to improve the execution efficiency and effect of the coreference resolution task.

[0236] In another specific implementation scheme, step S2421 includes: encoding the classification labels of the coreference resolution coding vectors to generate a second label vector; determining the semantic vector between any two coreference resolution coding vectors based on the positions of the any two coreference resolution coding vectors in the candidate entity fragment; obtaining the second initial relationship pair coding vector of any two coreference resolution coding vectors based on any two coreference resolution coding vectors, the semantic vector between the any two coreference resolution coding vectors and the second label vector corresponding to each coreference resolution coding vector.

[0237] Specifically, determining the semantic vector between any two coreference resolution coding vectors includes: determining multiple word vectors between any two coreference resolution coding vectors; performing pooling or attention processing on the multiple word vectors between any two coreference resolution coding vectors to obtain a corresponding semantic vector.

[0238] In a specific application, for the candidate entity fragment [z1, z2, …, zx-1, zx], [z1, z2] is the coreference resolution coding vector span3, [zx-1, zx] is the coreference resolution coding vector span4, then [z3, …, zx-2] is the word vector between any two coreference resolution coding vectors span3 and span4, and the word vector [z3, …, zx-2] between the two coreference resolution coding vectors span3 and span4 is pooled or attended to obtain the corresponding semantic vector, thereby increasing the semantic information of the second initial relationship pair coding vector and enhancing the expressiveness of the second initial relationship pair coding vector.

[0239] Specifically, the calculation formula of the second initial relationship encoding vector is as follows:

[0240] span_pair_embeddings=torch.cat([span3_embeddings, span4_embeddings, span3_embeddings*span4_embeddings, segment_info, span3_label_embedding, span4_label_embedding], -1).

[0241] Among them, torch.cat is a function used to concatenate two or more vectors together, span_pair_embeddings represents the second initial relationship pair encoding vector, span3_embeddings represents the coreference resolution encoding vector 1, span4_embeddings represents the coreference resolution encoding vector 2, segment_info represents the word vector between the coreference resolution encoding vector 1 and the coreference resolution encoding vector 2, span3_label_embedding represents the label vector of the coreference resolution encoding vector 1, and span4_label_embedding represents the label vector of the coreference resolution encoding vector 2.

[0242] It should be noted that in the process of calculating span_pair_embeddings, not all words can have a relationship. For example, in a paragraph of text, words that are far apart basically have no relationship. Therefore, a distance threshold is set in this embodiment. If the distance between span3 and span4 exceeds the threshold, the span_pair_embeddings of span3 and span4 are directly pruned. The value of the distance threshold can be set according to actual needs, for example, the threshold is set to 60 word units.

[0243] S2422. Perform classification prediction processing on the second initial relationship pair coding vector, and prune the second initial relationship pair coding vector according to a preset ratio based on the classification prediction result to obtain a second relationship pair coding vector.

[0244] Specifically, step S2422 includes:

[0245] Scoring the second initial relationship pair encoding vector by a feedforward neural network to obtain a score of the second initial relationship pair encoding vector;

[0246] Performing classification prediction processing on the second initial relationship pair encoding vector to obtain a category of the second initial relationship pair encoding vector;

[0247] The second initial relationship pair encoding vector is pruned based on the category and score of the second initial relationship pair encoding vector to obtain a second relationship pair encoding vector.

[0248] Specifically, the process of coreference resolution includes scoring and classification prediction processing. In other words, the second relationship pair encoding vector is scored through the coreference resolution model, and the second relationship pair encoding vector is classified and predicted based on the scoring result, that is, the coreference resolution processing is completed, the coreference resolution result is obtained, and the coreference relationship between words is determined.

[0249] This embodiment determines the coreference relationship between words by performing coreference resolution processing on the second relationship pair encoding vector, which can improve the accuracy of the coreference resolution task and further effectively improve the accuracy of determining the coreference relationship between words.

[0250] The word processing method based on the multi-task model provided in this embodiment first performs entity recognition processing and classification pruning processing on the candidate entity fragment coding vector through the entity recognition model to obtain the recognition pruned coding vector, so as to reduce the negative examples in the candidate entity fragment coding vector, and then performs relationship extraction processing and coreference resolution processing through the relationship extraction model and the coreference resolution model respectively, and prunes the recognition pruned coding vector again based on the results to obtain the relationship extraction coding vector and the coreference resolution coding vector, thereby realizing further screening of the recognition pruned coding vector based on different task requirements, wherein a first relationship pair coding vector is generated based on the relationship extraction coding vector, and a second relationship pair coding vector is generated based on the coreference resolution coding vector, which can further and more deeply strengthen the understanding of the candidate entity fragments by the relationship extraction model and the coreference resolution model, and provide a basis for the execution of the relationship extraction task and the coreference resolution task, and finally perform the relationship extraction process and the coreference resolution process respectively, and determine the relationship between words based on the above processing results, which can effectively improve the accuracy of word processing.

[0251] The word processing method based on the multi-task model provided in this embodiment realizes the organic combination of the relationship extraction model, the coreference resolution model, and the entity recognition model, realizes the organic combination of the relationship extraction task, the coreference resolution task, and the entity recognition task, and realizes the sharing of information in the above three tasks, which can effectively improve the accuracy and recall rate of relationship extraction, coreference resolution, and entity recognition, and effectively improve the accuracy of word processing based on the multi-task model for determining word relationships.

[0252] Secondly, in this embodiment, based on the semantic relationship between any two relationship extraction coding vectors in the candidate entity fragment, the first initial relationship pair coding vector of the forward semantic relationship and the first initial relationship pair coding vector of the reverse semantic relationship of any two relationship extraction coding vectors are obtained respectively, thereby introducing the consideration of semantic relationship in the process of obtaining the relationship extraction result, so that the relationship extraction result can be more accurate.

[0253] See also Figure 3 This embodiment provides a word processing method based on a multi-task model, including:

[0254] S310: Obtain a candidate entity segment, and generate a candidate entity segment encoding vector based on the candidate entity segment.

[0255] Among them, step S310 is the same as step S210 in the aforementioned embodiment. For a specific explanation of step S310, please refer to the detailed description of the aforementioned embodiment, which will not be repeated here.

[0256] S311, inputting the candidate entity segment encoding vector into an entity recognition model, and scoring the candidate entity segment encoding vector through the feedforward neural network.

[0257] S312. Classify the candidate entity fragment coding vector based on the score of the candidate entity fragment coding vector to obtain a classification label of the candidate entity fragment coding vector, and prune the candidate entity fragment coding vector to obtain a recognized pruned coding vector.

[0258] Among them, step S311 and step S312 are the same as steps S221 to S222 in the aforementioned embodiment. For the specific explanation of step S311 and step S312, please refer to the detailed description of the aforementioned embodiment, which will not be repeated here.

[0259] S313. Score the recognition pruned coding vector through a relation extraction model, and prune the recognition pruned coding vector based on the score to obtain a relation extraction coding vector.

[0260] S314. Generate a first relationship pair encoding vector based on the relationship extraction encoding vector, perform relationship extraction processing on the first relationship pair encoding vector through the relationship extraction model to obtain a relationship extraction result, and determine the relationship between the words in the candidate entity fragment based on the relationship extraction result.

[0261] Specifically, step S314 includes the following steps S341 to S343:

[0262] S341. Obtain a first initial relationship pair encoding vector based on the relationship extraction encoding vector and the classification label of the relationship extraction encoding vector.

[0263] S342. Perform classification prediction processing on the first initial relationship pair coding vector, and prune the first initial relationship pair coding vector according to a preset ratio based on the classification prediction result to obtain a first relationship pair coding vector.

[0264] S343. Score the first relationship pair encoding vector through the relationship extraction model, and perform classification prediction processing on the first relationship pair encoding vector based on the scoring result to obtain a relationship extraction result, and determine the relationship between the words in the candidate entity fragment based on the relationship extraction result.

[0265] Among them, step S313 and step S314 are the same as steps S231 to S232 in the aforementioned embodiment. For the specific explanation of step S313 and step S314, please refer to the detailed description of the aforementioned embodiment, which will not be repeated here.

[0266] S315. Score the recognition pruned code vector using a coreference resolution model, and prune the recognition pruned code vector based on the score to obtain a coreference resolution code vector.

[0267] S316. Obtain a second initial relationship pair encoding vector based on the coreference resolution encoding vector and the classification label of the coreference resolution encoding vector.

[0268] S317: Perform classification prediction processing on the second initial relationship pair encoding vector, and prune the second initial relationship pair encoding vector according to a preset ratio based on the classification prediction result to obtain a second relationship pair encoding vector.

[0269] For the detailed explanation of steps S315 to S317, please refer to the detailed content of step S240 in the aforementioned embodiment, which will not be described again here.

[0270] like Figure 4 As shown, this embodiment provides a multi-task model training method, including steps S410 to S440.

[0271] S410: Obtain at least two sample candidate entity pairs and a classification label of each of the sample candidate entity pairs, and generate a sample candidate entity segment encoding vector based on the sample candidate entities of each sample candidate entity pair.

[0272] For the specific content, please refer to the above embodiments, which will not be described again here.

[0273] S420, performing entity recognition processing and classification pruning processing on the sample candidate entity fragment encoding vector through an entity recognition model to obtain a sample recognition pruning encoding vector.

[0274] Specifically, assuming that there are n categories of sample candidate entity fragments (n≥1, and n is an integer), then the sample candidate entity fragments that do not belong to the above n categories are all negative examples. The sample candidate entity fragment encoding vectors are classified based on the scores of the sample candidate entity fragment encoding vectors to obtain the classification label of each sample candidate entity fragment encoding vector, and then the category to which each sample candidate entity fragment encoding vector belongs can be obtained. After pruning some sample candidate entity fragment encoding vectors in the negative examples according to a preset ratio, the remaining other sample candidate entity fragment encoding vectors are the identification pruned encoding vectors. Among them, the proportion of sample candidate entity fragment encoding vectors pruned in the negative examples can be determined according to the specific situation, such as one-sixth, one-fifth, etc., and this application does not limit this.

[0275] This embodiment classifies the encoding vectors of sample candidate entity fragments and prunes some encoding vectors in negative examples, so that the model can learn positive examples and negative examples in appropriate proportions at the same time, that is, learn from both correct and incorrect aspects at the same time, which helps to improve the model training effect.

[0276] S430, respectively inputting the sample identification pruning coding vector into a relation extraction model and a coreference resolution model for processing to obtain a first sample relation pair coding vector and a second sample relation pair coding vector.

[0277] Specifically, the step S430 may also include steps S431 and S432.

[0278] S431. Score the sample identification pruned coding vector through a relationship extraction model, and prune the sample identification pruned coding vector based on the score to obtain a sample relationship extraction coding vector, and generate a first sample relationship pair coding vector based on the sample relationship extraction coding vector.

[0279] For the specific content, please refer to the above embodiments, which will not be described again here.

[0280] S432. Score the sample identification pruned coding vector using a coreference resolution model, and prune the sample identification pruned coding vector based on the score to obtain a sample coreference resolution coding vector, and generate a second sample relationship pair coding vector based on the sample coreference resolution coding vector.

[0281] For the specific content, please refer to the above embodiments, which will not be described again here.

[0282] S440, determining the loss values ​​of the entity recognition model, the relationship extraction model and the coreference resolution model based on the sample recognition pruning coding vector, the first sample relationship pair coding vector and the second sample relationship pair coding vector, and training the entity recognition model, the relationship extraction model and the coreference resolution model.

[0283] Specifically, the loss value of the entity recognition model is calculated using a cross entropy loss function based on the score of the sample recognition pruned coding vector and the classification label of the sample recognition pruned coding vector;

[0284] Calculate the loss value of the relationship extraction model using a cross entropy loss function based on the score of the first sample relationship pair encoding vector and the classification label of the first sample relationship pair encoding vector;

[0285] Based on the score of the second sample relationship pair encoding vector and the classification label of the second sample relationship pair encoding vector, a cross entropy loss function is used to calculate the loss value of the coreference resolution model.

[0286] For example, during the entity recognition model training process, a set of loss values ​​obtained by cross entropy calculation may be [-0.0000, -6.8651, -9.8858, -9.3611, -9.4160, -8.8986, -10.0036], where the 7 numbers correspond to the numbers 0 to 6, and each number represents a classification label.

[0287] Through F.softmax, it becomes the classification probability [9.9856e-01, 1.0421e-03, 5.0818e-05, 8.5878e-05, 8.1292e-05, 1.3638e-04, 4.5174e-05], and the maximum value is the final loss value.

[0288] The formula for the cross entropy loss function is as follows:

[0289]

[0290] Cross entropy is the difference between two probability distributions p and q, where p represents the encoding vector of the classification label corresponding to the true distribution, i.e., the sample identification pruned encoding vector, the first sample relationship pair encoding vector, and the second sample relationship pair encoding vector, q represents the non-true distribution, i.e., the sample identification pruned encoding vector, the first sample relationship pair encoding vector, and the second sample relationship pair encoding vector, and H(p, q) represents the loss value.

[0291] Optionally, calculating the loss value of the relationship extraction model using a cross entropy loss function based on the first sample relationship pair encoding vector and the classification label of the first sample relationship pair encoding vector includes:

[0292] In the case where the classification label is a symmetric relationship label, two sample relationship extraction code vectors of the first sample relationship pair code vector are reversely arranged to generate a reverse first sample relationship pair code vector;

[0293] The first sample relationship pair encoding vector and the classification label, the reverse first sample relationship pair encoding vector and the classification label are respectively used to calculate the loss value of the relationship extraction model using the cross entropy loss function.

[0294] In a specific usage scenario, when the classification label is a symmetric relationship label, such as conjunction, it is usually (span1, span2, conjunction) when annotating, so data enhancement can be done to add the reverse first sample relationship pair encoding vector (span2, span1) to obtain (span2, span1, conjunction) and then calculate the loss value.

[0295] Specifically, based on the loss values ​​of the entity recognition model, the relationship extraction model, and the coreference resolution, the weight values ​​of each layer of neuron nodes in the model are reversely adjusted from the output layer to the input layer to train the model.

[0296] The training method of the multi-task model described in this embodiment first organically combines the relationship extraction task, the coreference resolution task, and the entity recognition task during the training process, and then trains the relationship extraction model, the coreference resolution model, and the entity recognition model separately, which can effectively improve the effect of model training and improve the performance of the relationship extraction model, the coreference resolution model, and the entity recognition model.

[0297] like Figure 5 As shown, this embodiment discloses a word processing device based on a multi-task model, including:

[0298] The entity segment acquisition module 510 is configured to acquire a candidate entity segment and generate a candidate entity segment encoding vector based on the candidate entity segment;

[0299] An entity recognition pruning module 520 is configured to perform entity recognition processing and classification pruning processing on the candidate entity segment encoding vector through an entity recognition model to obtain a recognition pruned encoding vector;

[0300] A relation extraction processing module 530 is configured to input the identified pruned encoding vector into a relation extraction model for processing to determine the relationship between words in the candidate entity segment;

[0301] The coreference resolution processing module 540 is configured to input the identified pruned encoding vector into a coreference resolution model for processing, and determine the coreference relationship between the words in the candidate entity segment.

[0302] Optionally, the relationship extraction processing module 530 is further configured to:

[0303] Scoring the identification pruned coding vector through a relation extraction model, and pruning the identification pruned coding vector based on the score to obtain a relation extraction coding vector;

[0304] In order to generate a first relationship pair encoding vector based on the relationship extraction encoding vector, the first relationship pair encoding vector is subjected to relationship extraction processing by the relationship extraction model to obtain a relationship extraction result, and the relationship between the words in the candidate entity fragment is determined based on the relationship extraction result.

[0305] Optionally, the coreference resolution processing module 540 is further configured to:

[0306] Scoring the identification pruned coding vector by a coreference resolution model, and pruning the identification pruned coding vector based on the score to obtain a coreference resolution coding vector;

[0307] A second relationship pair encoding vector is generated based on the coreference resolution encoding vector, coreference resolution processing is performed on the second relationship pair encoding vector through the coreference resolution model to obtain a coreference resolution result, and the relationship between the words in the candidate entity fragment is determined based on the coreference resolution result.

[0308] Optionally, the entity recognition model, the relationship extraction model, and the coreference resolution model share a feedforward neural network for scoring;

[0309] The entity recognition pruning module 520 is further configured to:

[0310] Inputting the candidate entity segment encoding vector into an entity recognition model, and scoring the candidate entity segment encoding vector through the feedforward neural network;

[0311] The candidate entity fragment coding vectors are classified based on the scores of the candidate entity fragment coding vectors, and the candidate entity fragment coding vectors are pruned based on the results of the classification process to obtain a recognized pruned coding vector.

[0312] Optionally, the relationship extraction model and the entity recognition model share a feedforward neural network for scoring;

[0313] The relationship extraction processing module 530 is further configured to:

[0314] Inputting the recognition pruned coding vector into the relation extraction model, scoring the recognition pruned coding vector through the feedforward neural network, and obtaining a score of the recognition pruned coding vector;

[0315] The recognition pruned coding vectors with scores greater than or equal to a preset threshold are used as relation extraction coding vectors.

[0316] Optionally, the coreference resolution model and the entity recognition model share a feedforward neural network for scoring;

[0317] The coreference resolution processing module 540 is further configured to:

[0318] Inputting the recognition pruned coding vector into the coreference resolution model, scoring the recognition pruned coding vector through the feedforward neural network, and obtaining a score of the recognition pruned coding vector;

[0319] The recognition pruning coding vector with a score greater than or equal to a preset threshold is used as the coreference resolution coding vector.

[0320] Optionally, the relationship extraction processing module 530 is further configured to:

[0321] Obtaining a first initial relation pair encoding vector based on the relation extraction encoding vector and the classification label of the relation extraction encoding vector;

[0322] The first initial relationship pair coding vector is subjected to classification prediction processing, and the first initial relationship pair coding vector is pruned according to a preset ratio based on a result of the classification prediction to obtain a first relationship pair coding vector.

[0323] Optionally, the relationship extraction processing module 530 is further configured to:

[0324] Scoring the first initial relationship pair encoding vector by a feedforward neural network to obtain a score of the first initial relationship pair encoding vector;

[0325] Performing classification prediction processing on the first initial relationship pair encoding vector to obtain a category of the first initial relationship pair encoding vector;

[0326] The first initial relationship pair encoding vector is pruned based on the category and score of the first initial relationship pair encoding vector to obtain a first relationship pair encoding vector.

[0327] Optionally, the relationship extraction processing module 530 is further configured to:

[0328] Encoding the classification label of the relation extraction encoding vector to generate a first label vector;

[0329] Based on any two of the relation extraction encoding vectors and their corresponding first label vectors, a first initial relation pair encoding vector of any two of the relation extraction encoding vectors is obtained.

[0330] Optionally, the relationship extraction processing module 530 is further configured to:

[0331] Encoding the classification label of the relation extraction encoding vector to generate a first label vector;

[0332] Determine a semantic vector between any two relation extraction encoding vectors based on positions of the any two relation extraction encoding vectors in the candidate entity fragment;

[0333] Based on any two of the relationship extraction encoding vectors, the semantic vector between the any two relationship extraction encoding vectors and the first label vector corresponding to each of the relationship extraction encoding vectors, a first initial relationship pair encoding vector of any two of the relationship extraction encoding vectors is obtained.

[0334] Optionally, the relationship extraction processing module 530 is further configured to:

[0335] Determine multiple word vectors between the arbitrary two relation extraction encoding vectors;

[0336] Pooling or attention processing is performed on multiple word vectors between any two relationship extraction encoding vectors to obtain corresponding semantic vectors.

[0337] Optionally, the relationship extraction processing module 530 is further configured to:

[0338] According to the semantic relationship between any two of the relationship extraction coding vectors in the candidate entity fragment, the first initial relationship pair coding vector of the forward semantic relationship and the first initial relationship pair coding vector of the reverse semantic relationship of any two of the relationship extraction coding vectors are obtained respectively.

[0339] Optionally, the relationship extraction processing module 530 is further configured to:

[0340] The first initial relationship pair encoding vector of the positive semantic relationship and the first initial relationship pair encoding vector of the reverse semantic relationship of any two of the relationship extraction encoding vectors are scored through a feedforward neural network, and the score of the first initial relationship pair encoding vector of the reverse semantic relationship is made less than a preset threshold.

[0341] Optionally, the coreference resolution processing module 540 is further configured to:

[0342] Obtaining a second initial relation pair encoding vector based on the coreference resolution encoding vector and the classification label of the coreference resolution encoding vector;

[0343] The second initial relationship pair coding vector is subjected to classification prediction processing, and the second initial relationship pair coding vector is pruned according to a preset ratio based on a result of the classification prediction to obtain a second relationship pair coding vector.

[0344] Optionally, the coreference resolution processing module 540 is further configured to:

[0345] Encoding the classification labels of the coreference elimination coding vector to generate a second label vector;

[0346] Based on any two of the coreference resolution coding vectors and their corresponding second label vectors, a second initial relation pair coding vector of any two of the coreference resolution coding vectors is obtained.

[0347] Optionally, the coreference resolution processing module 540 is further configured to:

[0348] Encoding the classification labels of the coreference elimination coding vector to generate a second label vector;

[0349] Determine a semantic vector between any two coreference resolution coding vectors based on positions of the any two coreference resolution coding vectors in the candidate entity segment;

[0350] Based on any two of the coreference resolution coding vectors, the semantic vector between the any two coreference resolution coding vectors, and the second label vector corresponding to each of the coreference resolution coding vectors, a second initial relationship pair coding vector of any two of the coreference resolution coding vectors is obtained.

[0351] Optionally, the coreference resolution processing module 540 is further configured to:

[0352] Determine a plurality of word vectors between the arbitrary two coreference resolution encoding vectors;

[0353] Pooling or attention processing is performed on multiple word vectors between any two coreference resolution encoding vectors to obtain corresponding semantic vectors.

[0354] Optionally, the coreference resolution processing module 540 is further configured to:

[0355] Scoring the second initial relationship pair encoding vector by a feedforward neural network to obtain a score of the second initial relationship pair encoding vector;

[0356] Performing classification prediction processing on the second initial relationship pair encoding vector to obtain a category of the second initial relationship pair encoding vector;

[0357] The second initial relationship pair encoding vector is pruned based on the category and score of the second initial relationship pair encoding vector to obtain a second relationship pair encoding vector.

[0358] Optionally, the relationship extraction processing module 530 is further configured to: score the first relationship pair encoding vector through the relationship extraction model, and perform classification prediction processing on the first relationship pair encoding vector based on the scoring result to obtain a relationship extraction result.

[0359] Optionally, the coreference resolution processing module 540 is further configured to: score the second relationship pair encoding vector using the coreference resolution model, and perform classification prediction processing on the second relationship pair encoding vector based on the scoring result to obtain a coreference resolution result.

[0360] The word processing device based on the multi-task model provided in this embodiment realizes the organic combination of the relationship extraction model, the coreference resolution model, and the entity recognition model, realizes the organic combination of the relationship extraction task, the coreference resolution task, and the entity recognition task, and realizes the sharing of information in the above three tasks, which can effectively improve the accuracy and recall rate of relationship extraction, coreference resolution, and entity recognition, and effectively improve the accuracy of word relationship determination based on the multi-task model.

[0361] like Figure 6 As shown, this embodiment discloses a training device for a multi-task model, including:

[0362] The sample acquisition module 610 is configured to acquire at least two sample candidate entity segments and a classification label of each sample candidate entity pair, and generate a sample candidate entity segment encoding vector based on the sample candidate entity segments;

[0363] The sample identification module 620 is configured to perform entity identification processing and classification pruning processing on the sample candidate entity fragment encoding vector through an entity identification model to obtain a sample identification pruning encoding vector;

[0364] The sample processing module 630 is configured to input the sample identification pruning coding vector into the relation extraction model and the coreference resolution model for processing, respectively, to obtain a first sample relation pair coding vector and a second sample relation pair coding vector;

[0365] The model training module 640 is configured to determine the loss values ​​of the entity recognition model, the relationship extraction model and the coreference resolution model based on the sample recognition pruning coding vector, the first sample relationship pair coding vector and the second sample relationship pair coding vector, and train the entity recognition model, the relationship extraction model and the coreference resolution model.

[0366] Optionally, the sample processing module 630 is further configured to:

[0367] Inputting the sample identification pruned coding vector into the relationship extraction model, scoring the sample identification pruned coding vector through the relationship extraction model, and pruning the sample identification pruned coding vector based on the score to obtain a sample relationship extraction coding vector, and generating a first sample relationship pair coding vector based on the sample relationship extraction coding vector;

[0368] The sample identification pruned coding vector is input into the coreference resolution model, the sample identification pruned coding vector is scored by the coreference resolution model, and the sample identification pruned coding vector is pruned based on the score to obtain a sample coreference resolution coding vector, and a second sample relationship pair coding vector is generated based on the sample coreference resolution coding vector.

[0369] Optionally, the model training module 640 is further configured to:

[0370] The loss value of the entity recognition model is calculated using a cross entropy loss function based on the score of the sample recognition pruned coding vector and the classification label of the sample recognition pruned coding vector;

[0371] Calculate the loss value of the relationship extraction model using a cross entropy loss function based on the score of the first sample relationship pair encoding vector and the classification label of the first sample relationship pair encoding vector;

[0372] Based on the score of the second sample relationship pair encoding vector and the classification label of the second sample relationship pair encoding vector, a cross entropy loss function is used to calculate the loss value of the coreference resolution model.

[0373] Optionally, the first sample relationship pair encoding vector includes two sample relationship extraction encoding vectors, and the model training module 640 is further configured to:

[0374] In the case where the classification label is a symmetric relationship label, two sample relationship extraction code vectors of the first sample relationship pair code vector are reversely arranged to generate a reverse first sample relationship pair code vector;

[0375] The first sample relationship pair encoding vector and the classification label, the reverse first sample relationship pair encoding vector and the classification label are respectively used to calculate the loss value of the relationship extraction model using the cross entropy loss function.

[0376] The training device of the multi-task model provided in the present application first organically combines the relationship extraction task, the coreference resolution task, and the entity recognition task during the training process, and then trains the relationship extraction model, the coreference resolution model, and the entity recognition model separately, which can effectively improve the effect of model training and improve the performance of the relationship extraction model, the coreference resolution model, and the entity recognition model.

[0377] It should be noted that the components in the device claim should be understood as the functional modules that must be established to implement the steps of the program flow or the steps of the method, and the functional modules are not actually divided or separated. The device claim defined by such a group of functional modules should be understood as the functional module architecture of the solution mainly implemented by the computer program recorded in the specification, and should not be understood as the physical device that mainly implements the solution by hardware.

[0378] like Figure 7 As shown, Figure 7 7 is a block diagram showing a computing device 700 according to an embodiment of the present specification. The components of the computing device 700 include but are not limited to a memory 770 and a processor 720. The processor 720 is connected to the memory 770 via a bus 730, and the database 750 is used to store data.

[0379] 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)) that is wired or wireless, such as an IEEE 802.77 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.

[0380] 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 7The 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.

[0381] 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 a PC. The computing device 700 may also be a mobile or stationary server. The computing device may execute the method described in any of the above embodiments.

[0382] An embodiment of the present application also provides a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of the multi-task model-based word processing method or the multi-task model training method as described above.

[0383] 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 multi-task model-based word processing method or the multi-task model training method are of the same concept, and the details not described in detail in the technical scheme of the storage medium can be found in the description of the technical scheme of the multi-task model-based word processing method or the multi-task model training method.

[0384] 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.

[0385] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences 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 the present application.

[0386] 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.

[0387] The preferred embodiments of the present application disclosed above are only used to help explain the present application. The optional embodiments do not describe all the details in detail, nor do they limit the invention to 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 the present application, so that those skilled in the art can understand and use the present application well. The present application is limited only by the claims and their full scope and equivalents.

Claims

1. A word processing method based on a multi-task model, characterized in that: include: Obtaining a candidate entity segment, and generating a candidate entity segment encoding vector based on the candidate entity segment; Performing entity recognition processing and classification pruning processing on the candidate entity fragment encoding vector through an entity recognition model to obtain a recognition pruning encoding vector; Scoring the identification pruned coding vector through a relation extraction model, and pruning the identification pruned coding vector based on the score to obtain a relation extraction coding vector; Generate a first relationship pair encoding vector based on the relationship extraction encoding vector, perform relationship extraction processing on the first relationship pair encoding vector through the relationship extraction model to obtain a relationship extraction result, and determine the relationship between the words in the candidate entity fragment based on the relationship extraction result, wherein the relationship extraction encoding vector is an identification pruned encoding vector with a score greater than or equal to a preset threshold, the first relationship pair encoding vector is the encoding vector remaining after pruning the first initial relationship pair encoding vector based on the score of the first initial relationship pair encoding vector, the first initial relationship pair encoding vector is an encoding vector based on the combination of two relationship extraction encoding vectors and their first label vectors and a distance feature vector, the first label vector is an encoding vector obtained by encoding the classification label of the relationship extraction encoding vector, the first initial relationship pair encoding vector includes a first initial relationship pair encoding vector for a positive semantic relationship and a first initial relationship pair encoding vector for a reverse semantic relationship, and the score of the first initial relationship pair encoding vector for the reverse semantic relationship is less than the preset threshold; The identified pruned coding vector is input into a coreference resolution model for processing to determine the coreference relationship between the words in the candidate entity segment.

2. The word processing method based on the multi-task model according to claim 1 is characterized in that: Inputting the identified pruned coding vector into a coreference resolution model for processing to determine the coreference relationship between words in the candidate entity segment includes: Scoring the identification pruned coding vector by a coreference resolution model, and pruning the identification pruned coding vector based on the score to obtain a coreference resolution coding vector; A second relationship pair encoding vector is generated based on the coreference resolution encoding vector, coreference resolution processing is performed on the second relationship pair encoding vector through the coreference resolution model to obtain a coreference resolution result, and the coreference relationship between the words in the candidate entity fragment is determined based on the coreference resolution result.

3. The word processing method based on the multi-task model according to claim 1, characterized in that: The entity recognition model, the relationship extraction model, and the coreference resolution model share a feedforward neural network for scoring; The step of performing entity recognition processing and classification pruning processing on the candidate entity segment encoding vector through the entity recognition model to obtain the recognition pruning encoding vector includes: Inputting the candidate entity segment encoding vector into an entity recognition model, and scoring the candidate entity segment encoding vector through the feedforward neural network; The candidate entity fragment coding vectors are classified based on the scores of the candidate entity fragment coding vectors to obtain classification labels of the candidate entity fragment coding vectors, and the candidate entity fragment coding vectors are pruned to obtain recognized pruned coding vectors.

4. The word processing method based on the multi-task model according to claim 1 is characterized in that: The relationship extraction model and the entity recognition model share a feedforward neural network for scoring; Scoring the recognition pruned coding vector by using a relation extraction model, and pruning the recognition pruned coding vector based on the score, including: Inputting the recognition pruned coding vector into the relation extraction model, scoring the recognition pruned coding vector through the feedforward neural network, and obtaining a score of the recognition pruned coding vector; The recognition pruned coding vectors with scores greater than or equal to a preset threshold are used as relation extraction coding vectors.

5. The word processing method based on the multi-task model according to claim 2 is characterized in that: The coreference resolution model and the entity recognition model share a feedforward neural network for scoring; Scoring the recognition pruned coding vector by a coreference resolution model, and pruning the recognition pruned coding vector based on the score, including: Inputting the recognition pruned coding vector into the coreference resolution model, scoring the recognition pruned coding vector through the feedforward neural network, and obtaining a score of the recognition pruned coding vector; The recognition pruning coding vector with a score greater than or equal to a preset threshold is used as the coreference resolution coding vector.

6. The word processing method based on the multi-task model according to claim 4 is characterized in that: The step of generating a first relationship pair encoding vector based on the relationship extraction encoding vector comprises: Obtaining a first initial relation pair encoding vector based on the relation extraction encoding vector and the classification label of the relation extraction encoding vector; The first initial relationship pair coding vector is subjected to classification prediction processing, and the first initial relationship pair coding vector is pruned according to a preset ratio based on a result of the classification prediction to obtain a first relationship pair coding vector.

7. The word processing method based on the multi-task model according to claim 6 is characterized in that: The performing classification prediction processing on the first initial relationship pair encoding vector, and pruning the first initial relationship pair encoding vector according to a preset ratio based on the classification prediction result to obtain the first relationship pair encoding vector, includes: Scoring the first initial relationship pair encoding vector by using the feedforward neural network to obtain a score of the first initial relationship pair encoding vector; Performing classification prediction processing on the first initial relationship pair encoding vector to obtain a category of the first initial relationship pair encoding vector; The first initial relationship pair encoding vector is pruned based on the category and score of the first initial relationship pair encoding vector to obtain a first relationship pair encoding vector.

8. The word processing method based on the multi-task model according to claim 7 is characterized in that: The step of obtaining a first initial relationship pair encoding vector based on the relationship extraction encoding vector and the classification label of the relationship extraction encoding vector includes: Encoding the classification label of the relation extraction encoding vector to generate a first label vector; Based on any two of the relation extraction encoding vectors and their corresponding first label vectors, a first initial relation pair encoding vector of any two of the relation extraction encoding vectors is obtained.

9. The word processing method based on the multi-task model according to claim 7, characterized in that: The step of obtaining a first initial relationship pair encoding vector based on the relationship extraction encoding vector and the classification label of the relationship extraction encoding vector includes: Encoding the classification label of the relation extraction encoding vector to generate a first label vector; Determine a semantic vector between any two relation extraction encoding vectors based on positions of the any two relation extraction encoding vectors in the candidate entity fragment; Based on any two of the relationship extraction encoding vectors, the semantic vector between the any two relationship extraction encoding vectors and the first label vector corresponding to each of the relationship extraction encoding vectors, a first initial relationship pair encoding vector of any two of the relationship extraction encoding vectors is obtained.

10. The word processing method based on the multi-task model according to claim 9, characterized in that: Determining the semantic vector between the arbitrary two relation extraction encoding vectors includes: Determine multiple word vectors between the arbitrary two relation extraction encoding vectors; Pooling or attention processing is performed on multiple word vectors between any two relationship extraction encoding vectors to obtain corresponding semantic vectors.

11. The word processing method based on the multi-task model according to claim 8 or 9, characterized in that: Obtaining a first initial relation pair encoding vector of any two of the relation extraction encoding vectors, comprising: According to the semantic relationship between any two of the relationship extraction coding vectors in the candidate entity fragment, the first initial relationship pair coding vector of the forward semantic relationship and the first initial relationship pair coding vector of the reverse semantic relationship of any two of the relationship extraction coding vectors are obtained respectively.

12. The word processing method based on the multi-task model according to claim 11, characterized in that: Scoring the first initial relationship pair encoding vector by a feedforward neural network to obtain a score of the first initial relationship pair encoding vector includes: The first initial relationship pair encoding vector of the positive semantic relationship and the first initial relationship pair encoding vector of the reverse semantic relationship of any two of the relationship extraction encoding vectors are scored through a feedforward neural network, and the score of the first initial relationship pair encoding vector of the reverse semantic relationship is made less than a preset threshold.

13. The word processing method based on the multi-task model according to claim 5, characterized in that: The generating a second relation pair encoding vector based on the coreference resolution encoding vector comprises: Obtaining a second initial relation pair encoding vector based on the coreference resolution encoding vector and the classification label of the coreference resolution encoding vector; The second initial relationship pair coding vector is subjected to classification prediction processing, and the second initial relationship pair coding vector is pruned according to a preset ratio based on the result of the classification prediction to obtain a second relationship pair coding vector.

14. The word processing method based on the multi-task model according to claim 13, characterized in that: Obtaining a second initial relation pair encoding vector based on the coreference resolution encoding vector and the classification label of the coreference resolution encoding vector includes: Encoding the classification labels of the coreference elimination coding vector to generate a second label vector; Based on any two of the coreference resolution coding vectors and their corresponding second label vectors, a second initial relation pair coding vector of any two of the coreference resolution coding vectors is obtained.

15. The word processing method based on the multi-task model according to claim 13, characterized in that: Obtaining a second initial relation pair encoding vector based on the coreference resolution encoding vector and the classification label of the coreference resolution encoding vector includes: Encoding the classification labels of the coreference elimination coding vector to generate a second label vector; Determine a semantic vector between any two coreference resolution coding vectors based on positions of the any two coreference resolution coding vectors in the candidate entity segment; Based on any two of the coreference resolution coding vectors, the semantic vector between the any two coreference resolution coding vectors, and the second label vector corresponding to each of the coreference resolution coding vectors, a second initial relationship pair coding vector of any two of the coreference resolution coding vectors is obtained.

16. The word processing method based on the multi-task model according to claim 15, characterized in that: Determining the semantic vector between the arbitrary two coreference resolution encoding vectors includes: Determine a plurality of word vectors between the arbitrary two coreference resolution encoding vectors; Pooling or attention processing is performed on multiple word vectors between any two coreference resolution encoding vectors to obtain corresponding semantic vectors.

17. The word processing method based on the multi-task model according to claim 14 or 15, characterized in that: The method of performing classification prediction processing on the second initial relationship pair encoding vector and pruning the second initial relationship pair encoding vector according to a preset ratio based on a result of the classification prediction to obtain a second relationship pair encoding vector includes: Scoring the second initial relationship pair encoding vector by a feedforward neural network to obtain a score of the second initial relationship pair encoding vector; Performing classification prediction processing on the second initial relationship pair encoding vector to obtain a category of the second initial relationship pair encoding vector; The second initial relationship pair encoding vector is pruned based on the category and score of the second initial relationship pair encoding vector to obtain a second relationship pair encoding vector.

18. The word processing method based on the multi-task model according to claim 1, characterized in that: Performing relation extraction processing on the first relation pair encoding vector by using the relation extraction model to obtain a relation extraction result includes: The first relationship pair encoding vector is scored using the relationship extraction model, and classification prediction processing is performed on the first relationship pair encoding vector based on the scoring result to obtain a relationship extraction result.

19. The word processing method based on the multi-task model according to claim 13, characterized in that: Performing coreference resolution processing on the second relationship pair encoding vector by using the coreference resolution model to obtain a coreference resolution result includes: The second relationship pair encoding vector is scored using the coreference resolution model, and classification prediction processing is performed on the second relationship pair encoding vector based on the scoring result to obtain a coreference resolution result.

20. A multi-task model training method, characterized in that: include: Obtain at least two sample candidate entity pairs and a classification label of each of the sample candidate entity pairs, and generate a sample candidate entity fragment encoding vector based on the sample candidate entities of each sample candidate entity pair; Performing entity recognition processing and classification pruning processing on the sample candidate entity fragment encoding vector through an entity recognition model to obtain a sample recognition pruning encoding vector; Input the sample identification pruned coding vector into a relationship extraction model, score the sample identification pruned coding vector through the relationship extraction model, and prune the sample identification pruned coding vector based on the score to obtain a sample relationship extraction coding vector, and generate a first sample relationship pair coding vector based on the sample relationship extraction coding vector, wherein the relationship extraction coding vector is an identification pruned coding vector with a score greater than or equal to a preset threshold, the first sample relationship pair coding vector is a coding vector remaining after pruning the first initial sample relationship pair coding vector based on the score of the first initial sample relationship pair coding vector, the first initial sample relationship pair coding vector is a coding vector composed of two sample relationship extraction coding vectors and their first label vectors and a distance feature vector, the first label vector is a coding vector obtained by encoding the classification label of the sample relationship extraction coding vector, the first initial sample relationship pair coding vector includes a first initial sample relationship pair coding vector of a positive semantic relationship and a first initial sample relationship pair coding vector of a reverse semantic relationship, and the score of the first initial relationship pair coding vector of the reverse semantic relationship is less than the preset threshold; Inputting the sample identification pruned coding vector into a coreference resolution model, scoring the sample identification pruned coding vector by the coreference resolution model, and pruning the sample identification pruned coding vector based on the score to obtain a sample coreference resolution coding vector, and generating a second sample relationship pair coding vector based on the sample coreference resolution coding vector; Inputting the sample identification pruning coding vector into the relation extraction model and the coreference resolution model for processing respectively, to obtain a first sample relation pair coding vector and a second sample relation pair coding vector; Based on the sample identification pruning coding vector, the first sample relationship pair coding vector, and the second sample relationship pair coding vector, the loss values ​​of the entity recognition model, the relationship extraction model, and the coreference resolution model are respectively determined, and the entity recognition model, the relationship extraction model, and the coreference resolution model are trained.

21. The multi-task model training method according to claim 20, characterized in that: Determining the loss values ​​of the entity recognition model, the relationship extraction model, and the coreference resolution model based on the sample recognition pruning encoding vector, the first sample relationship pair encoding vector, and the second sample relationship pair encoding vector, respectively, includes: The loss value of the entity recognition model is calculated using a cross entropy loss function based on the score of the sample recognition pruned coding vector and the classification label of the sample recognition pruned coding vector; Calculate the loss value of the relationship extraction model using a cross entropy loss function based on the score of the first sample relationship pair encoding vector and the classification label of the first sample relationship pair encoding vector; Based on the score of the second sample relationship pair encoding vector and the classification label of the second sample relationship pair encoding vector, a cross entropy loss function is used to calculate the loss value of the coreference resolution model.

22. The multi-task model training method according to claim 21, characterized in that: The first sample relationship pair encoding vector includes two sample relationship extraction encoding vectors; The loss value of the relationship extraction model is calculated using a cross entropy loss function based on the first sample relationship pair encoding vector and the classification label of the first sample relationship pair encoding vector, including: In the case where the classification label is a symmetric relationship label, two sample relationship extraction code vectors of the first sample relationship pair code vector are reversely arranged to generate a reverse first sample relationship pair code vector; The first sample relationship pair encoding vector and the classification label, the reverse first sample relationship pair encoding vector and the classification label are respectively used to calculate the loss value of the relationship extraction model using the cross entropy loss function.

23. A word processing device based on a multi-task model, characterized in that: include: An entity segment acquisition module is configured to acquire candidate entity segments and generate candidate entity segment encoding vectors based on the candidate entity segments; An entity recognition pruning module is configured to perform entity recognition processing and classification pruning processing on the candidate entity segment encoding vector through an entity recognition model to obtain a recognition pruning encoding vector; The relationship extraction processing module is configured to score the recognition pruned coding vector through a relationship extraction model, and prune the recognition pruned coding vector based on the score to obtain a relationship extraction coding vector; generate a first relationship pair coding vector based on the relationship extraction coding vector, perform relationship extraction processing on the first relationship pair coding vector through the relationship extraction model to obtain a relationship extraction result, and determine the relationship between the words in the candidate entity fragment based on the relationship extraction result, wherein the relationship extraction coding vector is a recognition pruned coding vector with a score greater than or equal to a preset threshold, and the first relationship pair coding vector is based on the first The score of the initial relationship pair coding vector is the coding vector remaining after pruning the first initial relationship pair coding vector, the first initial relationship pair coding vector is a coding vector based on the combination of the two relationship extraction coding vectors and their first label vectors and the distance feature vector, the first label vector is a coding vector obtained by encoding the classification label of the relationship extraction coding vector, the first initial relationship pair coding vector includes the first initial relationship pair coding vector of the positive semantic relationship and the first initial relationship pair coding vector of the reverse semantic relationship, and the score of the first initial relationship pair coding vector of the reverse semantic relationship is less than a preset threshold; The coreference resolution processing module is configured to input the identified pruned coding vector into a coreference resolution model for processing, and determine the coreference relationship between the words in the candidate entity segment.

24. A multi-task model training device, characterized in that: include: A sample acquisition module is configured to acquire at least two sample candidate entity pairs and a classification label of each of the sample candidate entity pairs, and generate a sample candidate entity fragment encoding vector based on the sample candidate entity of each sample candidate entity pair; A sample recognition module is configured to perform entity recognition processing and classification pruning processing on the sample candidate entity fragment encoding vector through an entity recognition model to obtain a sample recognition pruning encoding vector; The sample processing module is configured to input the sample identification pruned coding vector into the relationship extraction model, score the sample identification pruned coding vector through the relationship extraction model, and prune the sample identification pruned coding vector based on the score to obtain a sample relationship extraction coding vector, and generate a first sample relationship pair coding vector based on the sample relationship extraction coding vector, wherein the relationship extraction coding vector is an identification pruned coding vector with a score greater than or equal to a preset threshold, the first sample relationship pair coding vector is a coding vector remaining after pruning the first initial sample relationship pair coding vector based on the score of the first initial sample relationship pair coding vector, and the first initial sample relationship pair coding vector is a coding vector based on the two sample relationship extraction coding vectors and their first label vectors. and a coding vector composed of a combination of distance feature vectors, wherein the first label vector is a coding vector obtained by encoding the classification label of the sample relationship extraction coding vector, the first initial sample relationship pair coding vector includes a first initial sample relationship pair coding vector of a positive semantic relationship and a first initial sample relationship pair coding vector of a reverse semantic relationship, and the score of the first initial relationship pair coding vector of the reverse semantic relationship is less than a preset threshold; the sample identification pruned coding vector is input into a coreference resolution model, the sample identification pruned coding vector is scored by the coreference resolution model, and the sample identification pruned coding vector is pruned based on the score to obtain a sample coreference resolution coding vector, and a second sample relationship pair coding vector is generated based on the sample coreference resolution coding vector; The model training module is configured to determine the loss values ​​of the entity recognition model, the relationship extraction model and the coreference resolution model based on the sample recognition pruning coding vector, the first sample relationship pair coding vector and the second sample relationship pair coding vector, and train the entity recognition model, the relationship extraction model and the coreference resolution model.

25. A computing device comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, characterized in that: When the processor executes the instructions, the steps of the method described in any one of claims 1-19 or 20-22 are implemented.

26. A computer-readable storage medium storing computer instructions, characterized in that: When the instruction is executed by the processor, the steps of the method described in any one of claims 1-19 or 20-22 are implemented.