Network training method and device for event detection
By combining dynamic perception network and target feedback network, the dynamic perception network gradually increases the character of extracted words from the calculation layer, and the target feedback network recursively considers the label correlation between words, solving the problem of inaccurate event detection in the existing technology and improving event detection Accuracy and ability to identify the correlation of co-occurrence events.
Patent Information
- Application Number
- CN202011111486.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-16
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2040-10-16
AI Technical Summary
In the prior art, when performing event detection on detection text, it is difficult to accurately detect the type of event it contains, especially when dealing with ambiguous words and pairwise event trigger words.
An event detection is performed using a combination of dynamic perception network and target feedback network. The dynamic perception network extracts the eigenvectors of words by gradually increasing the computing layer, while the target feedback network further extracts the hidden vector by considering the label correlation between words through recursive means.
Improve the accuracy of event detection in the detection text, especially when identifying ambiguous words and pairwise event trigger words, and enhance the ability to recognize the correlation between co-occurring events.
Smart Images

Figure CN112199950B_ABST
Abstract
Description
Technical Field
[0001] One or more embodiments of the present specification relate to the field of machine learning technology, and more particularly, to a network training method and apparatus for event detection. Background Art
[0002] In an environment where the amount of news and information is growing explosively, detecting various events that people are concerned about in order to provide them to those in need and enable them to respond in a timely and adequate manner is an important current research direction. The processing platform can pre-define event trigger words corresponding to various event types, and set labels for various event types. It predicts the labels to which the words contained in the text to be detected belong, and then detects various event types from the text to be detected. For example, for the defined "senior resignation" event type, the corresponding event trigger words may include senior resignation, senior retirement, management resignation, etc. Detecting the event types contained in the text is closely related to the semantic understanding of the text and the words in the text.
[0003] Therefore, it is hoped that there will be an improved solution that can more accurately detect the event types contained in the text to be detected when performing event detection on the text to be detected. Summary of the invention
[0004] One or more embodiments of this specification describe a network training method and device for event detection to improve the accuracy of event detection. The specific technical solution is as follows.
[0005] In a first aspect, an embodiment provides a method for training a dynamic perception network for event detection, wherein the dynamic perception network comprises a plurality of candidate computing layers arranged in sequence; the method is executed by a processing platform, and includes:
[0006] Acquire a sample text containing a plurality of words, initial feature vectors corresponding to the plurality of words, and annotated labels, wherein the annotated labels include a first type of labels related to the event type and a second type of labels unrelated to the event type;
[0007] For any word in the sample text, the first several computing layers are gradually selected from the dynamic perception network, and the intermediate feature vector of the word is determined by the first several computing layers and the initial feature vector of the word, and the first predicted label is determined based on the first classifier and the intermediate feature vector of the word. When the first difference between the first predicted label and the corresponding annotation label is less than a first preset threshold, the first several computing layers are used as the computing layers corresponding to the word, and the intermediate feature vector of the word is used as the first feature vector of the word output by the dynamic perception network; the predicted label is the label to which the word belongs in the first category of labels or the second category of labels;
[0008] A first prediction loss is determined based on the first difference, and a model parameter in a calculation layer corresponding to the word is adjusted in a direction of reducing the first prediction loss.
[0009] In one embodiment, determining the intermediate feature vector of the word through the first several calculation layers and the initial feature vector of the word includes:
[0010] Through the first several calculation layers, the intermediate feature vector of the word is determined based on the initial feature vector of the word and the word information before the word in the sample text.
[0011] In one implementation, determining the intermediate feature vector of the word includes:
[0012] The initial feature vector of the word and the word information before the word are input into the first calculation layer of the first several calculation layers, and the calculation result of at least each calculation layer is input into the next calculation layer, and the calculation result of the last calculation layer of the first several calculation layers is used as the intermediate feature vector of the word.
[0013] In one embodiment, the method further includes inputting the initial feature vector of the word into the next calculation layer.
[0014] In one implementation, the word information preceding the word is determined based on a first feature vector of the word preceding the word.
[0015] In one embodiment, determining a first predicted label based on the first classifier and the intermediate feature vector of the word includes:
[0016] Determining a feature probability of the word based on the intermediate feature vector of the word, wherein the feature probability represents a probability that the intermediate feature vector is a first feature vector;
[0017] Input the intermediate feature vector of the word into the first classifier to obtain the initial predicted label of the word;
[0018] Based on the feature probability of the word and the initial predicted label of the word, the first predicted label of the word is determined.
[0019] In one implementation, when the first difference is not less than the first preset threshold, the method further includes:
[0020] Continue to add a first number of computing layers to the first plurality of computing layers;
[0021] At least the intermediate feature vector of the word is input into the first number of computing layers to obtain an updated intermediate feature vector of the word, and the step of determining a first predicted label based on the first classifier and the intermediate feature vector of the word is continued.
[0022] In one implementation, the first number is a preset number; or, the first number is determined based on a relative value between the first difference and the first preset threshold.
[0023] In a second aspect, an embodiment provides a target feedback network training method for event detection, the method being executed by a processing platform and comprising:
[0024] Obtaining a sample text containing a plurality of words, first feature vectors corresponding to the plurality of words, and annotation labels, wherein the first feature vector is determined by using the dynamic perception network trained in the first aspect;
[0025] Based on the first feature vectors corresponding to the multiple words respectively, according to a preset feature processing mechanism, determine the second feature vectors corresponding to the multiple words respectively;
[0026] According to the arrangement order of the multiple words in the sample text, based on the second feature vectors of the multiple words, through the target feedback network, the latent vectors corresponding to the multiple words are determined in sequence in the following recursive manner: for any one of the multiple words, the feature information of the previous word of the word and the second feature vector of the word are input into the target feedback network to obtain the latent vector of the word; the latent vector of the word is input into the second classifier to obtain the second predicted label of the word; wherein the feature information of the previous word includes the second predicted label of the previous word and the latent vector of the previous word;
[0027] Based on a second difference between a second predicted label of each word and a corresponding marked label, a second prediction loss is determined, and the target feedback network is adjusted in a direction of reducing the second prediction loss.
[0028] In one implementation, for a first word among the multiple words, feature information of a word preceding the first word includes a preset label and a preset latent vector.
[0029] In one implementation, the step of determining latent vectors corresponding to a plurality of words respectively includes:
[0030] According to the arrangement order of the multiple words in the sample text from front to back, based on the second feature vectors of the multiple words, the latent vectors corresponding to the multiple words are determined in sequence by the recursive method, and are respectively used as the corresponding first latent vectors;
[0031] According to the order of the plurality of words in the sample text from back to front, based on the second feature vectors of the plurality of words, the latent vectors corresponding to the plurality of words are sequentially determined in the recursive manner, and are respectively used as the corresponding second latent vectors;
[0032] For any one of the multiple words, the first latent vector and the second latent vector of the word are concatenated to obtain the latent vector of the word.
[0033] In one implementation, determining second feature vectors corresponding to a plurality of words respectively includes:
[0034] Using a self-attention mechanism, based on the first feature vectors corresponding to the multiple words, determine updated first feature vectors corresponding to the multiple words respectively;
[0035] Acquire a feature vector of an adjacent text of the sample text; the adjacent text is a sentence adjacent to the sample text in the corpus where the sample text is located;
[0036] Performing feature fusion on the updated first feature vectors respectively corresponding to the multiple words and the feature vectors of the adjacent text to obtain fused feature vectors respectively corresponding to the multiple words;
[0037] Obtaining initial feature vectors corresponding to a plurality of words of the sample text;
[0038] The initial feature vector and the fused feature vector of any one of the multiple words are concatenated to obtain a second feature vector of the word.
[0039] In one embodiment, the target feedback network is obtained based on a long short-term memory network (LSTM).
[0040] In a third aspect, an embodiment provides an event detection method combining a dynamic perception network and a target feedback network, which is executed by a computer, and the method includes:
[0041] Obtaining a text to be detected containing multiple words and initial feature vectors corresponding to the multiple words;
[0042] For any word in the text to be detected, the first several computing layers are gradually selected from the dynamic perception network, and the intermediate feature vector of the word is determined by the first several computing layers and the initial feature vector of the word, and the feature probability of the word is determined based on the intermediate feature vector of the word, and when the feature probability meets the preset probability condition, the intermediate feature vector of the word is used as the first feature vector of the word output by the dynamic perception network; the dynamic perception network is trained by the method of the first aspect; the feature probability represents the probability of the intermediate feature vector being the first feature vector;
[0043] Based on the first feature vectors corresponding to the multiple words respectively, according to a preset feature processing mechanism, determine the second feature vectors corresponding to the multiple words respectively;
[0044] According to the arrangement order of the multiple words in the text to be detected, based on the second feature vectors of the multiple words, through the target feedback network, the latent vectors corresponding to the multiple words are determined in sequence in the following recursive manner: for any one of the multiple words, the feature information of the previous word of the word and the second feature vector of the word are input into the target feedback network to obtain the latent vector of the word; the latent vector of the word is input into the second classifier to obtain the third predicted label of the word; the target feedback network is trained by the method of the second aspect;
[0045] Based on the third predicted labels of the plurality of words in the text to be detected, the event type included in the text to be detected is determined.
[0046] In a fourth aspect, an embodiment provides a dynamic perception network training device for event detection, wherein the dynamic perception network comprises a plurality of candidate computing layers arranged in sequence; the device is deployed in a processing platform, and includes:
[0047] A first acquisition module is configured to acquire a sample text containing a plurality of words, initial feature vectors corresponding to the plurality of words, and annotated labels, wherein the annotated labels include a first type of label related to an event type and a second type of label unrelated to the event type;
[0048] A first prediction module is configured to, for any word in the sample text, gradually select the first several computing layers from the dynamic perception network, and determine the intermediate feature vector of the word through the first several computing layers and the initial feature vector of the word, and determine the first predicted label based on the first classifier and the intermediate feature vector of the word, and when the first difference between the first predicted label and the corresponding annotation label is less than a first preset threshold, use the first several computing layers as the computing layers corresponding to the word, and use the intermediate feature vector of the word as the first feature vector of the word output by the dynamic perception network; the predicted label is the predicted label to which the word belongs in the first category of labels or the second category of labels;
[0049] The first adjustment module is configured to determine a first prediction loss based on the first difference, and adjust the model parameters in the calculation layer corresponding to the word in a direction of reducing the first prediction loss.
[0050] In one embodiment, the first prediction module, when determining the intermediate feature vector of the word through the first several calculation layers and the initial feature vector of the word, includes:
[0051] Through the first several calculation layers, the intermediate feature vector of the word is determined based on the initial feature vector of the word and the word information before the word in the sample text.
[0052] In one implementation, the first prediction module, when determining the intermediate feature vector of the word, includes:
[0053] The initial feature vector of the word and the word information before the word are input into the first calculation layer of the first several calculation layers, and the calculation result of at least each calculation layer is input into the next calculation layer, and the calculation result of the last calculation layer of the first several calculation layers is used as the intermediate feature vector of the word.
[0054] In one embodiment, the first prediction module, when determining the first predicted label based on the first classifier and the intermediate feature vector of the word, includes:
[0055] Determining a feature probability of the word based on the intermediate feature vector of the word, wherein the feature probability represents a probability that the intermediate feature vector is a first feature vector;
[0056] Input the intermediate feature vector of the word into the first classifier to obtain the initial predicted label of the word;
[0057] Based on the feature probability of the word and the initial predicted label of the word, the first predicted label of the word is determined.
[0058] In one embodiment, the first prediction module is further configured to:
[0059] When the first difference is not less than the first preset threshold, continue to add a first number of computing layers to the first plurality of computing layers;
[0060] At least the intermediate feature vector of the word is input into the first number of computing layers to obtain an updated intermediate feature vector of the word, and the determination of the first predicted label based on the first classifier and the intermediate feature vector of the word is continued.
[0061] In a fifth aspect, an embodiment provides a target feedback network training device for event detection, wherein the device is deployed in a processing platform and includes:
[0062] A second acquisition module is configured to acquire a sample text containing a plurality of words, first feature vectors corresponding to the plurality of words, and annotation labels, wherein the first feature vectors are determined by using the dynamic perception network trained in the first aspect;
[0063] A first determination module is configured to determine, based on the first feature vectors corresponding to the plurality of words respectively, the second feature vectors corresponding to the plurality of words respectively according to a preset feature processing mechanism;
[0064] The second prediction module is configured to, according to the arrangement order of the multiple words in the sample text, based on the second feature vectors of the multiple words, through the target feedback network, sequentially determine the latent vectors corresponding to the multiple words in the following recursive manner: for any one of the multiple words, input the feature information of the previous word of the word and the second feature vector of the word into the target feedback network to obtain the latent vector of the word; input the latent vector of the word into the second classifier to obtain the second predicted label of the word; wherein the feature information of the previous word includes the second predicted label of the previous word and the latent vector of the previous word;
[0065] The second adjustment module is configured to determine a second prediction loss based on a second difference between a second predicted label of each word and a corresponding marked label, and adjust the target feedback network in a direction of reducing the second prediction loss.
[0066] In one implementation, for a first word among the multiple words, feature information of a word preceding the first word includes a preset label and a preset latent vector.
[0067] In one implementation, when the second prediction module determines the latent vectors corresponding to the plurality of words, the method includes:
[0068] According to the arrangement order of the multiple words in the sample text from front to back, based on the second feature vectors of the multiple words, the latent vectors corresponding to the multiple words are determined in sequence by the recursive method, and are respectively used as the corresponding first latent vectors;
[0069] According to the order of the plurality of words in the sample text from back to front, based on the second feature vectors of the plurality of words, the latent vectors corresponding to the plurality of words are sequentially determined in the recursive manner, and are respectively used as the corresponding second latent vectors;
[0070] For any one of the multiple words, the first latent vector and the second latent vector of the word are concatenated to obtain the latent vector of the word.
[0071] In one embodiment, the target feedback network is obtained based on a long short-term memory network (LSTM).
[0072] In a sixth aspect, an embodiment provides an event detection device combining a dynamic perception network and a target feedback network, wherein the device is deployed in a computer and includes:
[0073] A third acquisition module is configured to acquire a text to be detected containing multiple words and initial feature vectors corresponding to the multiple words;
[0074] The feature extraction module is configured to, for any word in the text to be detected, gradually select the first several computing layers from the dynamic perception network, and determine the intermediate feature vector of the word through the first several computing layers and the initial feature vector of the word, and determine the feature probability of the word based on the intermediate feature vector of the word, and when the feature probability meets the preset probability condition, use the intermediate feature vector of the word as the first feature vector of the word output by the dynamic perception network; the dynamic perception network is trained by the method of the first aspect; the feature probability represents the probability of the intermediate feature vector being the first feature vector;
[0075] A first determination module is configured to determine, based on the first feature vectors corresponding to the plurality of words respectively, the second feature vectors corresponding to the plurality of words respectively according to a preset feature processing mechanism;
[0076] The third prediction module is configured to, according to the arrangement order of the multiple words in the text to be detected, based on the second feature vectors of the multiple words, through the target feedback network, sequentially determine the latent vectors corresponding to the multiple words in the following recursive manner: for any one of the multiple words, input the feature information of the previous word of the word and the second feature vector of the word into the target feedback network to obtain the latent vector of the word; input the latent vector of the word into the second classifier to obtain the third prediction label of the word; the target feedback network is trained by the method of the second aspect;
[0077] The second determination module is configured to determine the event type contained in the text to be detected based on the third predicted labels of multiple words in the text to be detected.
[0078] In a seventh aspect, an embodiment provides a computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute any one of the methods in the first to sixth aspects.
[0079] In an eighth aspect, an embodiment provides a computing device, comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method described in any one of the first to sixth aspects is implemented.
[0080] In the method and device provided in the embodiments of this specification, the dynamic perception network used for event detection includes multiple alternative computing layers. In the process of training the dynamic perception network, when extracting the first feature vector for each word in the sample text, the number of computing layers used may be different. The number of selected computing layers is associated with the difference between the first predicted label and the annotated label of the word. The first feature vector can make the difference between the first predicted label and the annotated label of the word less than a threshold. In this way, it is achieved that for words with different recognition difficulties, different numbers of computing layers are used to extract features. The dynamic perception network takes a longer time to extract features for words that are more difficult to recognize, and the extracted features are more accurate, which can improve the accuracy of event detection in the text to be detected. BRIEF DESCRIPTION OF THE DRAWINGS
[0081] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0082] Figure 1 A schematic diagram of an implementation scenario of an embodiment disclosed in this specification;
[0083] Figure 2 A schematic diagram of a flow chart of a dynamic perception network training method for event detection provided by an embodiment;
[0084] Figure 3 A schematic diagram of the computing layer used when the dynamic perception network N1 is used to determine the first feature vector T1 of each word in the sample text;
[0085] Figure 4 A schematic diagram of a processing flow of the dynamic perception network N1;
[0086] Figure 5 A flowchart of a target feedback network training method for event detection provided by an embodiment;
[0087] Figure 6 A processing flow diagram of the target feedback network N2;
[0088] Figure 7 A flowchart of an event detection method combining a dynamic perception network and a target feedback network provided in an embodiment;
[0089] Figure 8 A schematic block diagram of a dynamic perception network training device for event detection provided by an embodiment;
[0090] Fig. 9 A schematic block diagram of a target feedback network training device for event detection provided by an embodiment;
[0091] Fig.10 A schematic block diagram of an event detection device combining a dynamic perception network and a target feedback network is provided in an embodiment. DETAILED DESCRIPTION
[0092] The solution provided in this specification is described below in conjunction with the accompanying drawings.
[0093] Figure 1 This is a schematic diagram of an implementation scenario of an embodiment disclosed in this specification. It includes a dynamic perception network N1 and a target feedback network N2. The text A to be detected contains multiple words. The initial feature vector T0 of each word is respectively input into the dynamic perception network N1, and the first feature vector T1 of each word is obtained from the dynamic perception network N1. According to the preset feature processing mechanism, the second feature vector T2 corresponding to each word can be determined. Then, the second feature vectors T2 of multiple words are respectively input into the target feedback network N2 to obtain the latent vector T3 of each word. The latent vector T3 of each word is input into the classifier (not shown in the figure), and the predicted label Y of each word can be obtained. The predicted label Y is used to identify the label to which a word belongs in the first category of labels or the second category of labels. The first category of labels is a label related to a predefined event type, and the second category of labels is a label unrelated to the predefined event type. For example, in Figure 1 In the example, the first type of tags may include tags X and C, and the second type of tags may include tags O. Based on the predicted tags Y of multiple words in the text A to be detected, the event type included in the text A to be detected can be determined. For example, based on the tags X and C included in the text A, it can be determined that the text A to be detected includes a senior management resignation event. Figure 1 In the figure, the first eigenvector T1, the second eigenvector T2 and the latent vector T3 are all represented by circles. From the vertical perspective, Figure 1 In the text to be detected A "The general manager of..." is about to leave his job...", each Chinese character has an initial feature vector T0, a first feature vector T1, a second feature vector T2, a latent vector T3 and a predicted label Y correspondingly.
[0094] The text to be detected may include one or more sentences, such as a paragraph, an article or a sentence. The words in the text to be detected may include single Chinese characters in Chinese, words in English or other languages, or segmented words obtained after segmenting the text to be detected.
[0095] In order to more accurately determine the event type included in the text to be detected, a key point is to more accurately determine the predicted label Y of each word in the text to be detected A, that is, to more accurately identify the trigger words contained in the event type. For various types of texts generated in practice, sometimes the trigger word recognition results are ambiguous, and sometimes the trigger words of different events appear in pairs in the text. Based on these text characteristics, the present application provides an event detection method that can more accurately extract the feature vectors of each word in the text to be detected, wherein a dynamic perception network and a target feedback network are used to extract the feature vectors of the words. When the feature vector of a word can express the word more accurately, the event detection result based on the predicted label of the word will also be more accurate. Among them, the dynamic perception network is used to extract the first feature vector of the word, and different numbers of computing layers are used for feature extraction for different words, so that ambiguous words can be learned longer. The target feedback network is used to further extract the features of the word and obtain the hidden vector of the word. The target feedback network can consider the label association between words, so that the trigger word recognition of events that appear in pairs can promote each other. Below, the training process of the dynamic perception network and the target feedback network is explained respectively.
[0096] Figure 2 A flow chart of a dynamic perception network training method for event detection provided by an embodiment. Figure 1 The scene diagram shown is Figure 2 The embodiment shown is used for illustration. The dynamic perception network N1 includes a plurality of alternative computing layers arranged in sequence. Each computing layer may include one or more neurons, and the neurons include corresponding functions and parameters to be trained. The computing layer has inputs and outputs, and data can be transmitted in sequence between adjacent computing layers. The total number of computing layers of the dynamic perception network N1 can be preset. The method is executed by a processing platform, and the processing platform can be implemented by any device, equipment, platform, equipment cluster, etc. with computing and processing capabilities. The method includes the following steps S210 to S230.
[0097] Step S210, obtaining a sample text containing multiple words, initial feature vectors T0 corresponding to the multiple words, and annotated labels. The annotated labels include first-class labels related to event types and second-class labels unrelated to event types.
[0098] Wherein, the sample text can be any one in the training set. The training set can include multiple sample texts. The sample text can include one or more sentences, for example, the sample text can be a paragraph, an article or a sentence. The words in the sample text or the text to be detected mentioned in the embodiments of this specification can be understood as the smallest unit when performing feature extraction. The smallest unit can be a single Chinese character in Chinese, a word in English or other languages, a word segmentation obtained after the sample text is segmented, or other expressions. The initial feature vectors T0 and annotation labels corresponding to multiple words in the sample text can be obtained from the training set. Wherein, each word can have its corresponding initial feature vector and annotation label.
[0099] The initial feature vector of a word may be a feature representation obtained using a bag-of-words model, or a feature representation obtained using a word set model, or an initial feature vector of a word in a sample text determined using other methods.
[0100] Step S220, for any word W in the sample text, gradually select the first several computing layers from the dynamic perception network N1, and determine the intermediate feature vector of the word W through the first several computing layers and the initial feature vector of the word W, and determine the first predicted label based on the first classifier and the intermediate feature vector of the word W. When the first difference between the first predicted label and the corresponding annotation label is less than a first preset threshold, use the first several computing layers as the computing layers corresponding to the word W, and use the intermediate feature vector of the word W as the first feature vector T1 of the word W output by the dynamic perception network N1.
[0101] The predicted label is the label to which the word W belongs in the first or second category of labels. The first classifier is used to determine the first predicted label corresponding to the word W according to the intermediate feature vector of the input word W. The first classifier can be a classifier implemented by linear regression, logistic regression or softmax function.
[0102] In this step, the first feature vector T1 of each word in the sample text can be determined in the same manner as the above word W. Multiple words can be input into the dynamic perception network N1 in sequence according to a certain order, and the dynamic perception network N1 determines the first feature vector T1 of each word in the multiple words in the manner provided in this step.
[0103] When the first difference is not less than the first preset threshold, the first number of computing layers can be further added to the first number of computing layers, at least the intermediate feature vector of the word is input into the first number of computing layers, and the updated intermediate feature vector of the word is obtained, and the step of determining the first predicted label based on the first classifier and the intermediate feature vector of the word is continued. The first number of computing layers corresponding to the word W are continuous first number of computing layers, and include each added computing layer.
[0104] The following takes word W as an example to explain in detail the implementation method of the dynamic perception network N1 determining the first feature vector T1 of word W. For word W, the initial feature vector T0 of word W can be input into the first computing layer of the dynamic perception network N1, and the first k1 computing layers are used to extract the features of word W to obtain the intermediate feature vector of word W. k1 can be a preset number, for example, it can be 1, 2, 3 or other numbers. The intermediate feature vector is input into the first classifier to obtain the first predicted label of the word, and the first difference between the first predicted label and the annotated label of word W is calculated to determine whether the first difference is less than the first preset threshold.
[0105] If the first difference is not less than the first preset threshold, it is considered that the intermediate feature vector cannot accurately represent the features of word W, and a first number k2 of calculation layers can be added to the first K1 calculation layers, and the intermediate feature vector of word W is input into the first number k2 calculation layers to obtain an updated intermediate feature vector of the word, and then the process is returned to input the intermediate feature vector of the word into the first classifier to obtain the first predicted label of the word, and the step of calculating the first difference between the first predicted label and the marked label of word W is repeated to determine whether the first difference is less than the first preset threshold.
[0106] If the first difference is less than the first preset threshold, it is considered that the intermediate feature vector is accurate enough and can be used as the first feature vector T1 of the word W. The first several calculation layers at this time are used as the calculation layers corresponding to the word W, and the intermediate feature vector of the word W is used as the first feature vector T1 of the word W output by the dynamic perception network N1.
[0107] The first quantity k2 may be a preset quantity, or may be determined based on the relative value of the first difference and the first preset threshold. For example, when the first quantity k2 is determined based on the relative value of the first difference and the first preset threshold, the quantity corresponding to the relative value of the first difference and the first preset threshold may be determined according to the correspondence between the preset different relative values and quantities, and used as the first quantity k2. Specifically, when the relative value is small, a corresponding smaller quantity may be set, and when the relative value is large, a corresponding larger quantity may be set.
[0108] During the process of gradually increasing the computational layers, if it is determined that the first difference is less than the first preset threshold, the increase of the computational layers is stopped, and all the selected computational layers can be used as the computational layers corresponding to the word W. If all the selected computational layers have reached the maximum number of computational layers (i.e., the total number of computational layers) of the dynamic perception network N1, even if the first difference is not less than the first preset threshold at this time, the increase of the computational layers is stopped, and all the computational layers corresponding to the total number of computational layers are used as the computational layers corresponding to the word W.
[0109] Figure 3 It is a schematic diagram of the computational layers used when determining the first feature vector T1 of each word in the sample text by using the dynamic perception network N1. Among them, multiple horizontal lines are used to represent the computational layers corresponding to each word. In Figure 3 On the right side, taking the initial feature vector x9 as an example, the process of determining its first feature vector T1 by using the dynamic computational layers is shown. Among them, the initial feature vector x9 is input into the first computational layer, and k1 computational layers are used to determine the intermediate feature vector t1 of the word "职", and the intermediate feature vector t1 is input into the first classifier to determine the first predicted label of the word "职", calculate the first difference between the first predicted label and the labeled label, and judge whether the first difference is less than the first preset threshold. When it is not satisfied, continue to add k2 computational layers on the basis of k1 computational layers, input the intermediate feature vector t1 into the k2 computational layers, obtain the intermediate feature vector t2 of the word "职", and continue to judge whether the first difference is less than the first preset threshold. Suppose the first difference is less than the first preset threshold at this time, then the intermediate feature vector t2 is used as the first feature vector T1 of the word "职" output by the dynamic perception network N1, and the k1 and k2 computational layers are jointly used as the computational layers corresponding to the word "职", that is Figure 3 the computational layers shown above the word "职" in
[0110] The calculation method of the neurons in each computational layer can adopt the calculation method of a linear function or the calculation method of convolution. The embodiments of this specification do not make specific limitations on this.
[0111] Step S230, determine the first prediction loss based on the first difference, and adjust the model parameters in the computational layers corresponding to the word W in the direction of reducing the first prediction loss.
[0112] When determining the first prediction loss based on the first difference, the first difference can be substituted into the set loss function to calculate the first prediction loss. When adjusting the model parameters in the computational layers, the backpropagation algorithm can be used.
[0113] For different words in the sample text, the model parameters of the computational layers corresponding to each word are adjusted separately. For example, for Figure 3For the character "的" in , adjust the model parameters of the first two computational layers in the dynamic perception network N1. For the character "总", adjust the model parameters of its first four computational layers. For the character "经", adjust the model parameters of its first six computational layers.
[0114] The above steps S210 - S230 are for model training on a single sample text. For multiple sample texts in the training set, the dynamic perception network N1 can be trained multiple times separately until a preset convergence condition is met. The preset convergence condition can include that the dynamic perception network N1 has been trained using a sufficient number of sample texts, or that a sufficient number of first prediction losses are less than a preset loss threshold, etc. The judgment of the size relationship between the first difference and the first preset threshold in step S220 can determine whether the intermediate feature vector is accurate enough, thereby enabling more computational layers to be used to extract features for words that are more difficult to recognize, and fewer computational layers to be used to extract features for words that are easier to recognize. This not only improves the recognition accuracy of difficult-to-recognize words but also generally ensures the processing efficiency as much as possible.
[0115] Since the words in the text are interrelated, in order to further improve the recognition efficiency of the dynamic perception network for word features, in one embodiment, when determining the intermediate feature vector of the word W through the first several computational layers and the initial feature vector of the word W in step S220, specifically, the first several computational layers can be used to determine the intermediate feature vector of the word W based on the initial feature vector of the word W and the word information of the words before the word W in the sample text.
[0116] In this embodiment, according to the arrangement order of each word in the sample text, each word and the word information before it can be input into the dynamic perception network N1 in sequence, and the dynamic perception network N1 determines the first feature vector T1 of each word respectively. In this way, the first feature vector T1 of the word W obtained contains the feature information of each word before the word W in the sample text, making the first feature vector T1 more accurate.
[0117] The word information before the word W can be determined based on the first feature vector T1 of the word before the word W. For example, the word information before the word W can be the first feature vector T1 of the word before the word W, or information associated with the feature information of the word before the word W. For the first word in the sample text, the word information before the first word can be preset data or randomly determined data.
[0118] When determining the intermediate feature vector of the word, the initial feature vector T0 of the word W and the word information before the word W can be input into the first calculation layer of the first several calculation layers, and at least the calculation result of each calculation layer can be input into the next calculation layer, and the calculation result of the last calculation layer of the first several calculation layers can be used as the intermediate feature vector of the word. In another embodiment, the initial feature vector T0 of the word W can also be input into the next calculation layer.
[0119] Figure 4 FIG. 1 is a schematic diagram of a processing flow of a dynamic perception network N1, which shows the process of determining the first feature vector of word t-1 and the process of determining the first feature vector of word t. Word t-1 is the previous word of word t. Figure 4 Taking the left half of the figure as an example, in the process of determining the first feature vector, the input item of the first calculation layer S0 includes the initial feature vector x_t-1 of word t-1 and the word information of the previous word of word t-1 (see Figure 4 The initial feature vector of word t-1 can be directly input into each computing layer S0, S1...Sn, or the result after processing can be input into these computing layers. The result after processing the initial feature vector x_t-1 can be obtained based on the product of the initial feature vector x_t-1 and the first parameter matrix, and the first parameter matrix can be the parameters to be trained in the dynamic perception network N1.
[0120] When the calculation result of the calculation layer S0 cannot satisfy the condition that the first difference is less than the first preset threshold, the calculation result of the calculation layer S0 and the initial feature vector x_t-1 of word t-1 can be input into the calculation layer S1, see Figure 4 The solid arrow and the dotted arrow point to the circle S1.
[0121] In another embodiment, the step of determining the first predicted label based on the first classifier and the intermediate feature vector of the word in step S220 may specifically include the following steps 1a to 3a.
[0122] Step 1a, determining the feature probability of the word W based on the intermediate feature vector of the word W, the feature probability indicating the probability of the intermediate feature vector being the first feature vector. When determining the feature probability of the word W, it can be obtained based on the product of the intermediate feature vector of the word W and the second parameter matrix. The second parameter matrix can be a parameter matrix to be trained in the dynamic perception network N1.
[0123] Step 2a: input the intermediate feature vector of the word W into the first classifier to obtain the initial predicted label of the word W.
[0124] Step 3a, determining a first predicted label of the word W based on the feature probability of the word W and the initial predicted label of the word W. Specifically, the first predicted label of the word W can be determined based on the product of the feature probability of the word W and the initial predicted label of the word W.
[0125] Combine the following Figure 4 This embodiment is described. For the selected several computing layers, when the intermediate feature vector of word t-1 is obtained from the computing layer Sn, it can be acted on with the second parameter matrix to obtain the feature probability f_t-1. The intermediate feature vector of word t-1 is input into the first classifier to obtain the initial predicted label y_t-1, and the first predicted label Y_t-1 of word t-1 is obtained based on the product of the feature probability f_t-1 of word t-1 and the initial predicted label y_t-1 of word t-1.
[0126] In the previous embodiment, the word information before a word can be the first feature vector of the previous word of the word, or can be information associated with the feature information of the previous word. Figure 4 In the example shown, word t-1 is the previous word of word t. Relative to word t, the word information S_t-1 of word t-1 can be obtained based on the product of the calculation result of the calculation layer Sn and the feature probability f_t-1. Here, the calculation result of the calculation layer Sn is the first feature vector of word t-1.
[0127] The above content explains the process of training the dynamic perception network. Next, the training process of the target feedback network will be explained.
[0128] Figure 5 A flow chart of a target feedback network training method for event detection provided by an embodiment. Figure 1 The scene diagram shown is Figure 5 The method is described in the embodiment shown. The method is executed by a processing platform, and the processing platform can be implemented by any device, equipment, platform, equipment cluster, etc. with computing and processing capabilities. The method includes the following steps S510 to S540.
[0129] Step S510, obtaining a sample text containing multiple words, first feature vectors T1 corresponding to the multiple words, and annotation labels. The first feature vector T1 can be Figure 2 The dynamic perception network N1 trained in the embodiment is determined. The sample text obtained in this step can be any one in the training set, and the annotation labels of each word in the sample text can be obtained from the training set. For the description of the sample text and the annotation labels, please refer to the relevant description in step S210, which will not be repeated here.
[0130] Step S520, based on the first feature vectors corresponding to the multiple words, determine the second feature vectors corresponding to the multiple words according to a preset feature processing mechanism. The preset feature processing mechanism may include a self-attention mechanism and / or a feature fusion mechanism.
[0131] The processing of the first feature vector is described below in combination with the self-attention mechanism and the feature fusion mechanism. When determining the second feature vectors T2 corresponding to the plurality of words, the following steps 1b to 5b may be specifically included.
[0132] Step 1b, using the self-attention mechanism, based on the first feature vectors T1 corresponding to the multiple words, respectively, determines the updated first feature vectors corresponding to the multiple words. Specifically, the weight of each word can be determined by using the self-attention mechanism and the first feature vectors T1 corresponding to the multiple words, and the weight of each word is superimposed on the first feature vector T1 of the word to obtain the updated first feature vector. Step 1b is the process of processing the first feature vector using the self-attention mechanism. Using the processing of the self-attention mechanism, different degrees of importance can be given to different words, making the features of each word in the sample text more reasonable.
[0133] Step 2b, obtain the feature vector of the adjacent text of the sample text, the adjacent text is the sentence adjacent to the sample text in the corpus where the sample text is located. When the sample text is a paragraph in an article, the corpus where the sample text is located is the article. When the sample text is several sentences in a paragraph, the corpus where the sample text is located is the paragraph. The adjacent text is the text that is semantically related to the sample text.
[0134] The feature vector of the adjacent text may be obtained based on the feature vectors of each word in the adjacent text. The feature vector of each word in the adjacent text may be the initial feature vector or the first feature vector of the word. The feature vector of the adjacent text is used to characterize the features of the adjacent text as a whole.
[0135] Step 3b, feature fusion of the updated first feature vectors corresponding to the multiple words and the feature vector of the adjacent text to obtain fused feature vectors corresponding to the multiple words. Specifically, the updated first feature vectors corresponding to the multiple words can be constructed into a matrix, and a fusion matrix can be obtained based on the product of the matrix and the feature vector of the adjacent text. The fusion matrix can include the fused feature vectors corresponding to the multiple words.
[0136] The above steps 2b and 3b can be understood as a process of processing the first feature vector using a feature fusion mechanism. The feature fusion mechanism can enable the sample text to fuse feature information of adjacent texts, thereby enriching the feature meaning of each word in the sample text.
[0137] Step 4b, obtaining initial feature vectors T0 corresponding to multiple words of the sample text.
[0138] Step 5b, concatenate the initial feature vector T0 of any word W among the multiple words and the fused feature vector of the word W to obtain a second feature vector T2 of the word W. During concatenation, the initial feature vector T0 may be placed in front of or behind the fused feature vector according to a preset rule.
[0139] The processing of the first eigenvector may be performed by a self-attention mechanism alone or by a feature fusion mechanism alone. The above processing procedures are only several feasible embodiments and do not constitute a limitation on the embodiments of this specification. The processing of the first eigenvector may also be performed by other processing methods.
[0140] See also Figure 1 After the processing of step S520, the second feature vectors T2 of the multiple words are obtained based on the first feature vectors T1 of the multiple words.
[0141] Step S530, according to the arrangement order of multiple words in the sample text, based on the second feature vectors T2 of the multiple words, through the target feedback network N2, the latent vectors corresponding to the multiple words are determined in turn in the following recursive manner: for any word W among the above multiple words, the feature information of the previous word of the word W and the second feature vector T2 of the word W are input into the target feedback network N2 to obtain the latent vector T3 of the word W; the latent vector T3 of the word W is input into the second classifier to obtain the second predicted label of the word W. The latent vector is used to characterize the feature of the word W, and is a deeper feature representation of the word W.
[0142] The feature information of the previous word includes the second predicted label of the previous word and the latent vector of the previous word. For the first word among multiple words, the feature information of the previous word of the first word includes a preset label and a preset latent vector, that is, the preset label and the preset latent vector can be regarded as features in the feature information of the previous word of the first word. The preset latent vector here can also be replaced by a randomly determined latent vector, and this specification does not specifically limit this.
[0143] The second classifier is used to determine the second predicted label corresponding to the word W according to the latent vector of the input word W, and the second predicted label is the label to which the word W belongs in the first category of labels or the second category of labels. The second classifier can be a classifier implemented by a function such as linear regression, logistic regression or softmax.
[0144] In this step, the second predicted label of the previous word and the hidden vector of the previous word are used as part of the features of the word W to input the target feedback network N2 to obtain the hidden vector of the word W. In other words, the hidden vector of each word is combined with the label information and feature information of the previous words in the sample text, so that the obtained prediction results can be fed back to the subsequent words, thereby better discovering the correlation between co-occurrence events and improving the expression ability of the hidden vector.
[0145] The target feedback network N2 can be obtained based on the Long Short-Term Memory (LSTM) network, by improving the structure of the LSTM and changing the input item of each word, that is, the predicted label and latent vector of the previous word are also used as input items, and the second feature vector T2 of the word W is input into the LSTM. The target feedback network N2 can also be obtained based on the improvement of the Recurrent Neural Network (RNN).
[0146] Figure 6 Schematic diagram of a processing flow of the target feedback network N2. Each circle represents the processing of the target feedback network N2 on the corresponding word in the sample text. For any word W, its input includes the hidden vector T3 of the previous word, the second predicted label of the previous word ( Figure 6 The word W is represented by the dashed line (shown in the middle) and the second feature vector T2 of the word W.
[0147] Step S540: Determine a second prediction loss based on a second difference between the second predicted label of each word and the corresponding marked label, and adjust the target feedback network N2 in a direction of reducing the second prediction loss.
[0148] When determining the second prediction loss based on the second difference, the second difference can be substituted into the set loss function to calculate the second prediction loss. When adjusting the model parameters in the target feedback network N2, a back propagation algorithm can be used. When adjusting the model parameters in the target feedback network N2, each word can be adjusted once, or multiple words can be adjusted once.
[0149] The above steps S510 to S540 can be understood as a model training process for a sample text. For multiple sample texts in the training set, the target feedback network N2 can be trained multiple times until the preset convergence condition is met. The convergence condition may include using a sufficient number of sample texts to train the target feedback network N2, or a sufficient number of second prediction losses are less than a preset loss threshold, etc.
[0150] In this embodiment, when determining the latent vector of any word W, the second predicted label of the previous word and the latent vector of the previous word are used as part of the features of the word W to input the target feedback network N2 to obtain the latent vector of the word W. In this way, the obtained prediction results can be fed back to the subsequent words, which improves the expression ability of the latent vector, and further can better discover the correlation between co-occurring events, so that events that appear in pairs promote each other's recognition and improve the accuracy of event detection.
[0151] In another embodiment of the present specification, the target feedback network N2 may also be implemented based on a bidirectional LSTM. When determining the latent vectors corresponding to the plurality of words in step S530, the following steps 1c to 3c may be included.
[0152] Step 1c, according to the order of the words in the sample text from front to back, based on the second feature vectors T2 of the words, the latent vectors corresponding to the words are determined in turn through the above recursive method, and are used as the corresponding first latent vectors. After determining the first latent vector of a word, the first latent vector can be input into the second classifier to obtain the first sub-prediction label of the word.
[0153] For any word W, the first sub-prediction label and the first latent vector of the previous word of the word W, as well as the second feature vector T2 of the word W are input into the target feedback network to obtain the first latent vector of the word W.
[0154] Step 2c, according to the order of the multiple words in the sample text from back to front, based on the second feature vectors T2 of the multiple words, the latent vectors corresponding to the multiple words are determined in turn through the above recursive method, and are respectively used as the corresponding second latent vectors. After determining the second latent vector of a word, the second latent vector can be input into the second classifier to obtain the second sub-prediction label of the word.
[0155] For any word W, the second sub-prediction label and the second latent vector of the previous word of the word W, as well as the second feature vector T2 of the word W are input into the target feedback network to obtain the second latent vector of the word W.
[0156] Step 3c, for any word W among the multiple words, concatenate the first latent vector of the word W and the second latent vector of the word W to obtain the latent vector of the word W. After obtaining the latent vector of the word W, the latent vector of the word W can be input into the second classifier to obtain the second predicted label of the word. When implementing the above step S530 based on the bidirectional LSTM, there may be other implementations, which will not be repeated here.
[0157] In this embodiment, the bidirectional LSTM can be used to extract deeper feature information of the sample text, making the obtained second predicted label more accurate.
[0158] The above content provides a training method for the dynamic perception network N1 and the target feedback network N2. After training the two networks, the two networks can be applied separately or in combination to the feature extraction of words to obtain a deeper and more accurate feature vector, thereby making other applications based on this feature vector more accurate. Among them, combining the dynamic perception network N1 and the target feedback network N2 for application in event detection has been introduced in the form of an example at the beginning of this specification. Below, this application embodiment is introduced in more detail.
[0159] Figure 7 The following is a flow chart of an event detection method combining a dynamic perception network and a target feedback network provided by an embodiment. Figure 1 The embodiment shown, Figure 7 The method can be executed by a computer, and the computer can be implemented by any device, equipment, platform, equipment cluster, etc. having computing and processing capabilities. The method includes the following steps S710 to S750.
[0160] Step S710, obtain a text to be detected containing multiple words and initial feature vectors T0 corresponding to the multiple words. The text to be detected may include one or more sentences, such as a paragraph, an article or a sentence. The text to be detected may belong to the same type of text as the above-mentioned sample text. The description of the words in the text to be detected can also be found in the description of the words in the sample text in step S210, which will not be repeated here. The method for obtaining the initial feature vectors T0 corresponding to the multiple words in the text to be detected can be found in the description in step S210.
[0161] Step S720, for any word in the text to be detected, gradually select the first several computing layers from the dynamic perception network N1, and determine the intermediate feature vector of the word through the first several computing layers and the initial feature vector T0 of the word, and determine the feature probability of the word based on the intermediate feature vector of the word. When the feature probability meets the preset probability condition, the intermediate feature vector of the word is used as the first feature vector of the word output by the dynamic perception network.
[0162] Among them, the dynamic perception network can be used Figure 2 The feature probability represents the probability of the intermediate feature vector being the first feature vector.
[0163] The difference between this step and step S220 is that there is no need to use the intermediate feature vector to determine the first predicted label. Instead, the feature probability is judged to select the appropriate calculation layer for each word. For an explanation of the feature probability, please refer to Figure 4 Related instructions.
[0164] In step S720, when determining the feature probability of the word based on the intermediate feature vector of the word, reference may be made to the description in the above step 1a, which will not be repeated here.
[0165] The above-mentioned preset probability condition may include judging that the feature probability is greater than a preset probability threshold, or judging that the probability sum value is greater than a preset probability threshold. The probability sum value is the sum value of multiple feature probabilities calculated for the word. For example, for a certain word, if the feature probability is calculated three times, three judgments are required, and in each judgment, the probability sum values of the previous feature probabilities are judged. In the last judgment, the probability sum value of the three feature probabilities is compared with the preset probability threshold.
[0166] Step S730, based on the first feature vectors corresponding to the multiple words, according to the preset feature processing mechanism, determine the second feature vectors corresponding to the multiple words. The execution process of this step can refer to the specific description in step S520. The only difference is that the multiple words in this step are multiple words in the text to be detected, while the multiple words in step S520 are multiple words in the sample text.
[0167] Step S740, according to the arrangement order of multiple words in the text to be detected, based on the second feature vectors of the multiple words, through the target feedback network N2, the following recursive method is used to determine the latent vectors corresponding to the multiple words in turn: for any one of the multiple words, the feature information of the previous word of the word and the second feature of the word are input to the target feedback network N2 to obtain the latent vector of the word; the latent vector of the word is input into the second classifier to obtain the third predicted label of the word. The third predicted label is the label to which the word belongs in the first category of labels or the second category of labels. The third predicted label is the predicted label of each word in the text to be detected, and the second predicted label is the predicted label of each word in the sample text.
[0168] The target feedback network N2 can be used Figure 5 The specific implementation of step S740 can refer to step S530, which will not be repeated here.
[0169] Step S750, based on the third predicted labels of the multiple words in the text to be detected, determine the event type contained in the text to be detected. Specifically, the first type of labels in the third predicted labels of the multiple words can be compared with the labels corresponding to the preset event types, and the event type contained in the text to be detected is determined according to the comparison result.
[0170] In this embodiment, a dynamic perception network and a target feedback network are combined to jointly extract the latent vector of each word in the text to be detected. The dynamic perception network can improve the learning effect of ambiguous words, and the target feedback network can consider the label association between words, so that the recognition of event trigger words that appear in pairs is more accurate. Combining the two networks can cover the difficult-to-detect words that often appear in the text to be detected, improve the accuracy of word feature extraction, and thus improve the accuracy of event detection.
[0171] The foregoing describes certain embodiments of the present specification, and other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims may be performed in an order different from that in the embodiments, and the desired results may still be achieved. In addition, the processes depicted in the accompanying drawings do not necessarily have to be performed in the specific order or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0172] Figure 8 A schematic block diagram of a dynamic perception network training device for event detection provided in an embodiment. The dynamic perception network includes a plurality of alternative computing layers arranged in sequence. Figure 2 The device 800 is deployed in a processing platform and includes:
[0173] A first acquisition module 810 is configured to acquire a sample text containing a plurality of words, initial feature vectors corresponding to the plurality of words, and annotated labels, wherein the annotated labels include a first type of label related to an event type and a second type of label unrelated to the event type;
[0174] The first prediction module 820 is configured to, for any word in the sample text, gradually select the first several computing layers from the dynamic perception network, and determine the intermediate feature vector of the word through the first several computing layers and the initial feature vector of the word, determine the first predicted label based on the first classifier and the intermediate feature vector of the word, and when the first difference between the first predicted label and the corresponding annotation label is less than a first preset threshold, use the first several computing layers as the computing layers corresponding to the word, and use the intermediate feature vector of the word as the first feature vector of the word output by the dynamic perception network; the predicted label is the predicted label to which the word belongs in the first category of labels or the second category of labels;
[0175] The first adjustment module 830 is configured to determine a first prediction loss based on the first difference, and adjust the model parameters in the calculation layer corresponding to the word in a direction of reducing the first prediction loss.
[0176] In one embodiment, the first prediction module 820, when determining the intermediate feature vector of the word through the first several calculation layers and the initial feature vector of the word, includes:
[0177] Through the first several calculation layers, the intermediate feature vector of the word is determined based on the initial feature vector of the word and the word information before the word in the sample text.
[0178] In one embodiment, the first prediction module 820 determines the intermediate feature vector of the word by:
[0179] The initial feature vector of the word and the word information before the word are input into the first calculation layer of the first several calculation layers, and the calculation result of at least each calculation layer is input into the next calculation layer, and the calculation result of the last calculation layer of the first several calculation layers is used as the intermediate feature vector of the word.
[0180] In one embodiment, the first prediction module 820, when at least inputting the calculation result of each calculation layer to the next calculation layer, also inputs the initial feature vector of the word to the next calculation layer.
[0181] In one implementation, the word information preceding the word is determined based on a first feature vector of the word preceding the word.
[0182] In one embodiment, the first prediction module 820, when determining the first predicted label based on the first classifier and the intermediate feature vector of the word, includes:
[0183] Determining a feature probability of the word based on the intermediate feature vector of the word, wherein the feature probability represents a probability that the intermediate feature vector is a first feature vector;
[0184] Input the intermediate feature vector of the word into the first classifier to obtain the initial predicted label of the word;
[0185] Based on the feature probability of the word and the initial predicted label of the word, the first predicted label of the word is determined.
[0186] In one implementation, the first prediction module 820 is further configured to:
[0187] When the first difference is not less than the first preset threshold, continue to add a first number of computing layers to the first plurality of computing layers;
[0188] At least the intermediate feature vector of the word is input into the first number of computing layers to obtain an updated intermediate feature vector of the word, and the first predicted label is determined based on the first classifier and the intermediate feature vector of the word.
[0189] In one implementation, the first number is a preset number; or, the first number is determined based on a relative value between the first difference and the first preset threshold.
[0190] Fig. 9 The present invention provides a schematic block diagram of a target feedback network training device for event detection provided by an embodiment. Figure 5 The device 900 is deployed in a processing platform and includes:
[0191] A second acquisition module 910 is configured to acquire a sample text containing a plurality of words, first feature vectors corresponding to the plurality of words, and annotation labels, wherein the first feature vector is determined by using the dynamic perception network trained according to claim 1;
[0192] The first determination module 920 is configured to determine, based on the first feature vectors corresponding to the multiple words respectively, the second feature vectors corresponding to the multiple words respectively according to a preset feature processing mechanism;
[0193] The second prediction module 930 is configured to, according to the arrangement order of the multiple words in the sample text, based on the second feature vectors of the multiple words, and through the target feedback network, sequentially determine the latent vectors corresponding to the multiple words in the following recursive manner: for any one of the multiple words, input the feature information of the previous word of the word and the second feature vector of the word into the target feedback network to obtain the latent vector of the word; input the latent vector of the word into the second classifier to obtain the second predicted label of the word; wherein the feature information of the previous word includes the second predicted label of the previous word and the latent vector of the previous word;
[0194] The second adjustment module 940 is configured to determine a second prediction loss based on a second difference between a second predicted label of each word and a corresponding labeled label, and adjust the target feedback network in a direction of reducing the second prediction loss.
[0195] In one implementation, for a first word among the multiple words, feature information of a word preceding the first word includes a preset label and a preset latent vector.
[0196] In one implementation, the second prediction module 930, when determining the latent vectors corresponding to the plurality of words, includes:
[0197] According to the arrangement order of the multiple words in the sample text from front to back, based on the second feature vectors of the multiple words, the latent vectors corresponding to the multiple words are determined in sequence by the recursive method, and the latent vectors are respectively used as the corresponding first latent vectors;
[0198] According to the order of the plurality of words in the sample text from back to front, based on the second feature vectors of the plurality of words, the latent vectors corresponding to the plurality of words are sequentially determined in the recursive manner as the corresponding second latent vectors;
[0199] For any one of the multiple words, the first latent vector and the second latent vector of the word are concatenated to obtain the latent vector of the word.
[0200] In one implementation, the first determining module 920 is specifically configured as follows:
[0201] Using a self-attention mechanism, based on the first feature vectors corresponding to the multiple words, determine updated first feature vectors corresponding to the multiple words respectively;
[0202] Acquire a feature vector of an adjacent text of the sample text; the adjacent text is a sentence adjacent to the sample text in the corpus where the sample text is located;
[0203] Performing feature fusion on the updated first feature vectors respectively corresponding to the multiple words and the feature vectors of the adjacent text to obtain fused feature vectors respectively corresponding to the multiple words;
[0204] Obtaining initial feature vectors corresponding to a plurality of words of the sample text;
[0205] The initial feature vector and the fused feature vector of any one of the multiple words are concatenated to obtain a second feature vector of the word.
[0206] In one embodiment, the target feedback network is obtained based on a long short-term memory network (LSTM).
[0207] Fig.10 The present invention provides a schematic block diagram of an event detection device combining a dynamic perception network and a target feedback network. Figure 7 The device 100 is deployed in a computer and includes:
[0208] The third acquisition module 110 is configured to acquire a text to be detected including a plurality of words and initial feature vectors corresponding to the plurality of words respectively;
[0209] The feature extraction module 120 is configured to, for any word in the text to be detected, gradually select the first several computing layers from the dynamic perception network, and determine the intermediate feature vector of the word through the first several computing layers and the initial feature vector of the word, and determine the feature probability of the word based on the intermediate feature vector of the word, and when the feature probability meets the preset probability condition, use the intermediate feature vector of the word as the first feature vector of the word output by the dynamic perception network; the dynamic perception network adopts Figure 2The feature probability represents the probability of the intermediate feature vector being the first feature vector;
[0210] The first determination module 130 is configured to determine, based on the first feature vectors corresponding to the multiple words respectively, the second feature vectors corresponding to the multiple words respectively according to a preset feature processing mechanism;
[0211] The third prediction module 140 is configured to, according to the arrangement order of the multiple words in the text to be detected, based on the second feature vectors of the multiple words, through the target feedback network, sequentially determine the latent vectors corresponding to the multiple words in the following recursive manner: for any one of the multiple words, input the feature information of the previous word of the word and the second feature vector of the word into the target feedback network to obtain the latent vector of the word; input the latent vector of the word into the second classifier to obtain the third predicted label of the word; the target feedback network adopts Figure 5 The method is trained;
[0212] The second determination module 150 is configured to determine the event type included in the text to be detected based on the third predicted labels of multiple words in the text to be detected.
[0213] The above device embodiments correspond to the method embodiments. For specific descriptions, please refer to the description of the method embodiments, which will not be repeated here. The device embodiments are obtained based on the corresponding method embodiments and have the same technical effects as the corresponding method embodiments. For specific descriptions, please refer to the corresponding method embodiments.
[0214] The present specification also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed in a computer, the computer is caused to execute Figures 1 to 7 Any of the methods described above.
[0215] The embodiment of the present specification also provides a computing device, including a memory and a processor, wherein the memory stores an executable code, and when the processor executes the executable code, Figures 1 to 7 Any of the methods described above.
[0216] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the storage medium and computing device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0217] Those skilled in the art should be aware that in one or more of the above examples, the functions described in the embodiments of the present invention may be implemented using hardware, software, firmware, or any combination thereof. When implemented using software, these functions may be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium.
[0218] The specific implementation methods described above further describe the purpose, technical solutions and beneficial effects of the embodiments of the present invention in detail. It should be understood that the above description is only a specific implementation method of the embodiments of the present invention and is not intended to limit the scope of protection of the present invention. Any modification, equivalent replacement, improvement, etc. made on the basis of the technical solution of the present invention shall be included in the scope of protection of the present invention.
Claims
1. A method for training a dynamic perception network for event detection, wherein the dynamic perception network comprises a plurality of candidate computing layers arranged in sequence; the method is executed by a processing platform, comprising: Acquire a sample text containing a plurality of words, initial feature vectors corresponding to the plurality of words, and annotated labels, wherein the annotated labels include a first type of labels related to the event type and a second type of labels unrelated to the event type; For any word in the sample text, the first several computing layers are gradually selected from the dynamic perception network, and the intermediate feature vector of the word is determined by the first several computing layers and the initial feature vector of the word, and the first predicted label is determined based on the first classifier and the intermediate feature vector of the word. When the first difference between the first predicted label and the corresponding annotation label is less than a first preset threshold, the first several computing layers are used as the computing layers corresponding to the word, and the intermediate feature vector of the word is used as the first feature vector of the word output by the dynamic perception network; the predicted label is the label to which the word belongs in the first category of labels or the second category of labels; A first prediction loss is determined based on the first difference, and a model parameter in a calculation layer corresponding to the word is adjusted in a direction of reducing the first prediction loss.
2. The method according to claim 1, determining the intermediate feature vector of the word through the first several calculation layers and the initial feature vector of the word, comprising: Through the first several calculation layers, the intermediate feature vector of the word is determined based on the initial feature vector of the word and the word information before the word in the sample text.
3. The method according to claim 2, determining the intermediate feature vector of the word, comprising: The initial feature vector of the word and the word information before the word are input into the first calculation layer of the first several calculation layers, and the calculation result of at least each calculation layer is input into the next calculation layer, and the calculation result of the last calculation layer of the first several calculation layers is used as the intermediate feature vector of the word.
4. The method according to claim 3 further includes inputting the initial feature vector of the word into the next calculation layer.
5. The method according to claim 2, wherein the word information before the word is determined based on a first feature vector of the word before the word.
6. The method according to claim 1, determining a first predicted label based on a first classifier and an intermediate feature vector of the word, comprising: Determining a feature probability of the word based on the intermediate feature vector of the word, wherein the feature probability represents a probability that the intermediate feature vector is a first feature vector; Input the intermediate feature vector of the word into the first classifier to obtain the initial predicted label of the word; Based on the feature probability of the word and the initial predicted label of the word, the first predicted label of the word is determined.
7. The method according to claim 1, when the first difference is not less than the first preset threshold, further comprising: Continue to add a first number of computing layers to the first plurality of computing layers; At least the intermediate feature vector of the word is input into the first number of computing layers to obtain an updated intermediate feature vector of the word, and the step of determining a first predicted label based on the first classifier and the intermediate feature vector of the word is continued.
8. The method according to claim 7, wherein the first number is a preset number; or, the first number is determined based on a relative value between the first difference and the first preset threshold.
9. A method for training a target feedback network for event detection, the method being performed by a processing platform, comprising: Obtaining a sample text containing a plurality of words, first feature vectors corresponding to the plurality of words, and annotation labels, wherein the first feature vector is determined by using the dynamic perception network trained according to claim 1; Based on the first feature vectors corresponding to the multiple words respectively, according to a preset feature processing mechanism, determine the second feature vectors corresponding to the multiple words respectively; According to the arrangement order of the multiple words in the sample text, based on the second feature vectors of the multiple words, through the target feedback network, the latent vectors corresponding to the multiple words are determined in sequence in the following recursive manner: for any one of the multiple words, the feature information of the previous word of the word and the second feature vector of the word are input into the target feedback network to obtain the latent vector of the word; the latent vector of the word is input into the second classifier to obtain the second predicted label of the word; wherein the feature information of the previous word includes the second predicted label of the previous word and the latent vector of the previous word; Based on a second difference between a second predicted label of each word and a corresponding marked label, a second prediction loss is determined, and the target feedback network is adjusted in a direction of reducing the second prediction loss.
10. The method according to claim 9, wherein: For a first word among the multiple words, feature information of a word preceding the first word includes a preset label and a preset latent vector.
11. According to the method of claim 9, the step of determining latent vectors corresponding to the plurality of words comprises: According to the arrangement order of the multiple words in the sample text from front to back, based on the second feature vectors of the multiple words, the latent vectors corresponding to the multiple words are determined in sequence by the recursive method, and the latent vectors are respectively used as the corresponding first latent vectors; According to the order of the plurality of words in the sample text from back to front, based on the second feature vectors of the plurality of words, the latent vectors corresponding to the plurality of words are sequentially determined in the recursive manner as the corresponding second latent vectors; For any one of the multiple words, the first latent vector and the second latent vector of the word are concatenated to obtain the latent vector of the word.
12. The method according to claim 9, determining the second feature vectors corresponding to the plurality of words respectively comprises: Using a self-attention mechanism, based on the first feature vectors corresponding to the multiple words, determine updated first feature vectors corresponding to the multiple words respectively; Acquire a feature vector of an adjacent text of the sample text; the adjacent text is a sentence adjacent to the sample text in the corpus where the sample text is located; Performing feature fusion on the updated first feature vectors respectively corresponding to the multiple words and the feature vectors of the adjacent text to obtain fused feature vectors respectively corresponding to the multiple words; Obtaining initial feature vectors corresponding to a plurality of words of the sample text; The initial feature vector and the fused feature vector of any one of the multiple words are concatenated to obtain a second feature vector of the word.
13. According to the method of claim 9, the target feedback network is obtained based on a long short-term memory network (LSTM).
14. An event detection method combining a dynamic perception network and a target feedback network, executed by a computer, the method comprising: Obtaining a text to be detected containing multiple words and initial feature vectors corresponding to the multiple words; For any word in the text to be detected, the first several computing layers are gradually selected from the dynamic perception network, and the intermediate feature vector of the word is determined by the first several computing layers and the initial feature vector of the word, and the feature probability of the word is determined based on the intermediate feature vector of the word, and when the feature probability meets the preset probability condition, the intermediate feature vector of the word is used as the first feature vector of the word output by the dynamic perception network; the dynamic perception network is trained by the method of claim 1; the feature probability represents the probability of the intermediate feature vector being the first feature vector; Based on the first feature vectors corresponding to the multiple words respectively, according to a preset feature processing mechanism, determine the second feature vectors corresponding to the multiple words respectively; According to the arrangement order of the multiple words in the text to be detected, based on the second feature vectors of the multiple words, through the target feedback network, the latent vectors corresponding to the multiple words are determined in turn in the following recursive manner: for any one of the multiple words, the feature information of the previous word of the word and the second feature vector of the word are input into the target feedback network to obtain the latent vector of the word; the latent vector of the word is input into the second classifier to obtain the third predicted label of the word; the target feedback network is trained by the method of claim 9; Based on the third predicted labels of the plurality of words in the text to be detected, the event type included in the text to be detected is determined.
15. A dynamic perception network training device for event detection, wherein the dynamic perception network comprises a plurality of candidate computing layers arranged in sequence; The device is deployed in a processing platform and includes: A first acquisition module is configured to acquire a sample text containing a plurality of words, initial feature vectors corresponding to the plurality of words, and annotated labels, wherein the annotated labels include a first type of label related to an event type and a second type of label unrelated to the event type; A first prediction module is configured to, for any word in the sample text, gradually select the first several computing layers from the dynamic perception network, and determine the intermediate feature vector of the word through the first several computing layers and the initial feature vector of the word, and determine the first predicted label based on the first classifier and the intermediate feature vector of the word, and when the first difference between the first predicted label and the corresponding annotation label is less than a first preset threshold, use the first several computing layers as the computing layers corresponding to the word, and use the intermediate feature vector of the word as the first feature vector of the word output by the dynamic perception network; the predicted label is the predicted label to which the word belongs in the first category of labels or the second category of labels; The first adjustment module is configured to determine a first prediction loss based on the first difference, and adjust the model parameters in the calculation layer corresponding to the word in a direction of reducing the first prediction loss.
16. The apparatus according to claim 15, wherein the first prediction module, when determining the intermediate feature vector of the word through the first several calculation layers and the initial feature vector of the word, comprises: Through the first several calculation layers, the intermediate feature vector of the word is determined based on the initial feature vector of the word and the word information before the word in the sample text.
17. The apparatus according to claim 16, wherein the first prediction module, when determining the intermediate feature vector of the word, comprises: The initial feature vector of the word and the word information before the word are input into the first calculation layer of the first several calculation layers, and the calculation result of at least each calculation layer is input into the next calculation layer, and the calculation result of the last calculation layer of the first several calculation layers is used as the intermediate feature vector of the word.
18. The apparatus according to claim 15, wherein the first prediction module, when determining the first prediction label based on the first classifier and the intermediate feature vector of the word, comprises: Determining a feature probability of the word based on the intermediate feature vector of the word, wherein the feature probability represents a probability that the intermediate feature vector is a first feature vector; Input the intermediate feature vector of the word into the first classifier to obtain the initial predicted label of the word; Based on the feature probability of the word and the initial predicted label of the word, the first predicted label of the word is determined.
19. The apparatus according to claim 15, wherein the first prediction module further comprises: When the first difference is not less than the first preset threshold, continue to add a first number of computing layers to the first plurality of computing layers; At least the intermediate feature vector of the word is input into the first number of computing layers to obtain an updated intermediate feature vector of the word, and the determination of the first predicted label based on the first classifier and the intermediate feature vector of the word is continued.
20. A target feedback network training device for event detection, the device being deployed in a processing platform, comprising: A second acquisition module is configured to acquire a sample text containing a plurality of words, first feature vectors corresponding to the plurality of words, and annotation labels, wherein the first feature vector is determined by using the dynamic perception network trained according to claim 1; A first determination module is configured to determine, based on the first feature vectors corresponding to the plurality of words respectively, the second feature vectors corresponding to the plurality of words respectively according to a preset feature processing mechanism; The second prediction module is configured to, according to the arrangement order of the multiple words in the sample text, based on the second feature vectors of the multiple words, through the target feedback network, sequentially determine the latent vectors corresponding to the multiple words in the following recursive manner: for any one of the multiple words, input the feature information of the previous word of the word and the second feature vector of the word into the target feedback network to obtain the latent vector of the word; input the latent vector of the word into the second classifier to obtain the second predicted label of the word; wherein the feature information of the previous word includes the second predicted label of the previous word and the latent vector of the previous word; The second adjustment module is configured to determine a second prediction loss based on a second difference between a second predicted label of each word and a corresponding marked label, and adjust the target feedback network in a direction of reducing the second prediction loss.
21. The device according to claim 20, wherein: For a first word among the multiple words, feature information of a word preceding the first word includes a preset label and a preset latent vector.
22. The apparatus according to claim 20, wherein the second prediction module, when determining latent vectors corresponding to a plurality of words, comprises: According to the arrangement order of the multiple words in the sample text from front to back, based on the second feature vectors of the multiple words, the latent vectors corresponding to the multiple words are determined in sequence by the recursive method, and the latent vectors are respectively used as the corresponding first latent vectors; According to the order of the plurality of words in the sample text from back to front, based on the second feature vectors of the plurality of words, the latent vectors corresponding to the plurality of words are sequentially determined in the recursive manner as the corresponding second latent vectors; For any one of the multiple words, the first latent vector and the second latent vector of the word are concatenated to obtain the latent vector of the word.
23. According to the device according to claim 20, the target feedback network is obtained based on a long short-term memory network (LSTM).
24. An event detection device combining a dynamic perception network and a target feedback network, the device being deployed in a computer, comprising: A third acquisition module is configured to acquire a text to be detected containing multiple words and initial feature vectors corresponding to the multiple words; The feature extraction module is configured to, for any word in the text to be detected, gradually select the first several computing layers from the dynamic perception network, and determine the intermediate feature vector of the word through the first several computing layers and the initial feature vector of the word, and determine the feature probability of the word based on the intermediate feature vector of the word, and when the feature probability meets the preset probability condition, use the intermediate feature vector of the word as the first feature vector of the word output by the dynamic perception network; the dynamic perception network is trained by the method of claim 1; the feature probability represents the probability of the intermediate feature vector being the first feature vector; A first determination module is configured to determine, based on the first feature vectors corresponding to the plurality of words respectively, the second feature vectors corresponding to the plurality of words respectively according to a preset feature processing mechanism; The third prediction module is configured to, according to the arrangement order of the multiple words in the text to be detected, based on the second feature vectors of the multiple words, through the target feedback network, sequentially determine the latent vectors corresponding to the multiple words in the following recursive manner: for any one of the multiple words, input the feature information of the previous word of the word and the second feature vector of the word into the target feedback network to obtain the latent vector of the word; input the latent vector of the word into the second classifier to obtain the third predicted label of the word; The target feedback network is trained by the method of claim 9; The second determination module is configured to determine the event type contained in the text to be detected based on the third predicted labels of multiple words in the text to be detected.
25. A computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to execute the method according to any one of claims 1 to 14.
26. A computing device comprising a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, the method according to any one of claims 1 to 14 is implemented.
Citation Information
Patent Citations
Construction and utilization method for context-aware dynamic word or character vector on the basis of deep learning
CN106547735A
Scene recognition method based on convolutional neural network and recursive automatic encoder model
CN110188827A