Text processing method and apparatus, electronic device, and storage medium

By combining the three models, accurate identification of the causal relationship of events in the text is achieved, which solves the problem of insufficient accuracy in the existing technology and improves the accuracy of information extraction.

CN114579698BActive Publication Date: 2025-10-10BEIJING XIAOMI MOBILE SOFTWARE CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210147311.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-17
Publication Date
2025-10-10
Estimated Expiration
2042-02-17

AI Technical Summary

Technical Problem

Existing technologies have difficulty in accurately identifying the causal relationship of events in text in event extraction tasks, resulting in insufficient accuracy in information extraction.

Method used

A method combining three models is adopted: the first model classifies the causal relationship of events, the second model calculates similarity, and the third model comprehensively determines the causal relationship of events based on semantic matching.

Benefits of technology

The accuracy of event causal relationship extraction is improved, and computing consumption and model training costs are reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114579698B_ABST
    Figure CN114579698B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a text processing method and device, an electronic device and a storage medium. The text processing method provided by the present disclosure can include: performing classification processing on a target text by using a first model to obtain a classification result of an event causal relationship of the target text; performing processing on the target text by using a second model to obtain a similarity of a candidate cause event type and a candidate result event type, and obtaining a prediction result of an event causal relationship of the target text output by the second model based on the similarity; obtaining an output result of the event causal relationship of the target text according to the semantics of the target text by using a third model; and determining a target event causal relationship of the target text according to the classification result, the prediction result and the output result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of information technology, and in particular to a text processing method and device, an electronic device, and a storage medium. Background Art

[0002] Information extraction is a challenging task within Natural Language Processing (NLP) technology and plays a crucial role in many downstream NLP tasks, such as knowledge graph completion, intelligent question answering, and document analysis. Event extraction is a typical information extraction task. In this task, researchers need to extract event types, event triggers, event roles, and event arguments from a given text. Summary of the Invention

[0003] Embodiments of the present disclosure provide a text processing method and apparatus, an electronic device, and a storage medium.

[0004] A first aspect of the present disclosure provides a text processing method, including:

[0005] Using the first model to classify the target text, and obtain a classification result of the event causal relationship of the target text;

[0006] Processing the target text using the second model to obtain similarities between candidate cause event types and candidate result event types, and obtaining a prediction result of the event causal relationship of the target text output by the second model based on the similarities;

[0007] Obtaining an output result of the event causal relationship of the target text using the third model according to the semantics of the target text;

[0008] The causal relationship of the target event of the target text is determined according to the classification result, the prediction result and the output result.

[0009] Based on the above solution, the target text is classified using the first model to obtain the classification result of the event causal relationship of the target text, including:

[0010] Inputting the target text into the encoding layer of the first model to obtain an encoding sequence of the target text;

[0011] Classifying the coding sequence to obtain classification labels of the coding data of each word in the coding sequence, wherein the classification labels include: cause event type labels and result event type labels;

[0012] The classification result is obtained according to the classification label.

[0013] Based on the above solution, obtaining the classification result according to the classification label and the classification probability includes:

[0014] When the coding sequence has one of the cause event type labels and one of the result event type labels, combining the cause event type label and the result event type label to obtain the classification result;

[0015] When the coding sequence has multiple cause event type labels and / or multiple result event type labels, the classification results with the highest one or more classification probabilities are obtained based on the classification probabilities of the cause event type labels and / or the classification probabilities of the result event type labels output by the first model.

[0016] Based on the above solution, the target text is processed using the second model to obtain similarities between candidate cause event types and candidate result event types, and a prediction result of the event causal relationship of the target text output by the second model is obtained based on the similarities, including:

[0017] Using the classification branch of the second model, classify the coding sequence of the target text to obtain labels of each candidate cause event type and candidate result event type;

[0018] Arbitrarily combining the candidate cause event types and the candidate result event types to obtain a candidate event causal relationship combination;

[0019] Determine any one of the candidate relationship combinations and the coding sequence of the target text to be input into the prediction branch of the second model, and obtain the similarity between the candidate cause event type and the candidate result event type in each of the candidate relationship combinations;

[0020] The prediction result is output according to the similarity.

[0021] Based on the above solution, the method further includes:

[0022] Determine any one of the candidate relationship combinations and the coding sequence of the target text and input it into the event element extraction branch of the second model to obtain the event element output by the event element extraction branch.

[0023] Based on the above solution, the method further includes:

[0024] The event elements to be output are determined according to the number of occurrences of each event element of the prediction result of the causal relationship of the target event.

[0025] Based on the above solution, the third model is used to obtain the output result of the event causal relationship of the target text according to the semantics of the target text, including:

[0026] The question sentence constructed based on the entities in the target text and the target text are input into the third model, and the output result of the event causal relationship of the target text is obtained through semantic matching between the question sentence and the target text.

[0027] Based on the above solution, determining the causal relationship of the target event of the target text according to the classification result, the prediction result and the output result includes:

[0028] Determining a causal relationship of a first candidate event based on the classification probability and the classification threshold of the classification result;

[0029] Determining a causal relationship of a second alternative event based on the similarity of the prediction results and a similarity threshold;

[0030] Determining a causal relationship of a third candidate event based on a matching degree between the question statement and the target text corresponding to the output result and a matching degree threshold;

[0031] An event causal relationship that belongs to the first candidate event causal relationship, the second candidate event causal relationship, and the third candidate event causal relationship is determined as the target event causal relationship.

[0032] A second aspect of an embodiment of the present disclosure provides a text processing device, the device comprising:

[0033] A first model module is used to classify the target text using the first model to obtain a classification result of the event causal relationship of the target text;

[0034] a second model module, configured to process the target text using a second model to obtain similarities between candidate cause event types and candidate result event types, and obtain a prediction result of an event causal relationship of the target text output by the second model based on the similarities;

[0035] A third model module is used to obtain an output result of the event causal relationship of the target text based on the semantics of the target text using the third model;

[0036] A determination module is used to determine the causal relationship of the target event of the target text according to the classification result, the prediction result and the output result.

[0037] Based on the above scheme, the first model module is specifically used to input the target text into the encoding layer of the first model to obtain the encoding sequence of the target text; classify the encoding sequence to obtain the classification label of the encoding data of each word in the encoding sequence, wherein the classification label includes: cause event type label and result event type label; according to the classification label, the classification result is obtained.

[0038] Based on the above scheme, the first model module is also specifically used to, when the coding sequence has one cause event type label and one result event type label, combine the cause event type label and the result event type label to obtain the classification result; when the coding sequence has multiple cause event type labels and / or multiple result event type labels, obtain one or more classification results with the highest classification probability based on the classification probability of the cause event type label and / or the classification probability of the result event type label output by the first model.

[0039] Based on the above scheme, the second model module is specifically used to use the classification branch of the second model to classify the coding sequence of the target text to obtain labels of each alternative cause event type and alternative result event type; arbitrarily combine the alternative cause event type and the alternative result event type to obtain an alternative event causal relationship combination; determine any one of the alternative relationship combinations and the coding sequence of the target text to input into the prediction branch of the second model to obtain the similarity of the alternative cause event type and the alternative result event type in each of the alternative relationship combinations; and output the prediction result based on the similarity.

[0040] Based on the above solution, the device further includes:

[0041] The event element module is used to determine any one of the alternative relationship combinations and the coding sequence of the target text and input it into the event element extraction branch of the second model to obtain the event element output by the event element extraction branch.

[0042] Based on the above solution, the device further includes:

[0043] The output module is used to determine the output event elements according to the number of occurrences of each event element of the prediction result of the causal relationship of the target event.

[0044] Based on the above scheme, the third model module is used to input the question statement constructed based on the entities in the target text and the target text into the third model, and obtain the output result of the event causal relationship of the target text through semantic matching between the question statement and the target text.

[0045] Based on the above scheme, the determination module is specifically used to determine the first alternative event causal relationship based on the classification probability and classification threshold of the classification result; determine the second alternative event causal relationship based on the similarity and similarity threshold of the prediction result; determine the third alternative event causal relationship based on the matching degree and matching threshold of the question statement corresponding to the output result and the target text; and determine the event causal relationship that belongs to the first alternative event causal relationship, the second alternative event causal relationship and the third alternative event causal relationship at the same time as the target event causal relationship.

[0046] A third aspect of the present disclosure provides an electronic device, including:

[0047] a memory for storing processor-executable instructions;

[0048] a processor connected to the memory;

[0049] The processor is configured to execute the text processing method provided by any technical solution of the first aspect mentioned above.

[0050] A fourth aspect of an embodiment of the present disclosure provides a non-temporary computer-readable storage medium, which, when the instructions in the storage medium are executed by a processor of a computer, enables the computer to execute the text processing method provided by any technical solution of the first aspect above.

[0051] The technical solutions provided by the embodiments of the present disclosure may have the following beneficial effects:

[0052] In the disclosed embodiment, the first model uses classification to determine the event causal relationships of the target text. The second model uses similarity calculation to obtain predictions representing the event causal relationships of the target text. The third model uses text semantics to output results representing the event causal relationships of the target text. These three models use different text processing methods to produce their own outputs regarding the event causal relationships of the target text. This allows for the precise determination of the event causal relationships of the target text based on these results, improving the accuracy of text processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0054] Figure 1 is a flowchart illustrating a text processing method according to an exemplary embodiment;

[0055] Figure 2 is a structural diagram of a first model according to an exemplary embodiment;

[0056] Figure 3 is a schematic diagram showing a flow chart of processing text using a first model according to an exemplary embodiment;

[0057] Figure 4 A schematic structural diagram of a second model according to an exemplary embodiment;

[0058] Figure 5 is a schematic diagram showing a flow chart of text processing using a second model according to an exemplary embodiment;

[0059] Figure 6 is a structural diagram of a second model according to an exemplary embodiment;

[0060] Figure 7 This is a flow chart illustrating a method for obtaining a target event causal relationship of a target text based on a classification result, a prediction result, and an output result according to an exemplary embodiment;

[0061] Figure 8 is a schematic structural diagram of a third model according to an exemplary embodiment;

[0062] Figure 9 is a flowchart illustrating a text processing method according to an exemplary embodiment;

[0063] Figure 10 is a structural diagram of a text processing device according to an exemplary embodiment;

[0064] Figure 11 The figure is a schematic structural diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0065] Exemplary embodiments will be described in detail herein, examples of which are illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present disclosure. Rather, they are merely examples of devices consistent with certain aspects of the present disclosure, as detailed in the appended claims.

[0066] like Figure 1 As shown, an embodiment of the present disclosure provides a text processing method, the method comprising:

[0067] S110: Classifying the target text using the first model to obtain a classification result of the event causal relationship of the target text;

[0068] S120: Processing the target text using the second model to obtain similarities between candidate cause event types and candidate result event types, and obtaining a prediction result of the event causal relationship of the target text output by the second model based on the similarities;

[0069] S130: Obtaining an output result of the event causal relationship of the target text according to the semantics of the target text using the third model;

[0070] S140: Determine the causal relationship of the target event of the target text according to the classification result, the prediction result and the output result.

[0071] The text processing method can be applied to various electronic devices, including but not limited to servers and / or various terminal devices, including but not limited to mobile phones, tablet computers, or wearable devices.

[0072] The first model may be a Bidirectional Encoder Representation from Transformers (BERT)-Conditional Random Fields (CRF). The first model encodes the input target text to obtain an encoded sequence. The encoded sequence may include at least: word vectors (token embeddings). In other embodiments, the encoded sequence may also include: segment embeddings (segment embeddings) and position embeddings. Figure 2 An example of a first model is shown.

[0073] The first model is used to separate the target text into words through the sentences in the target text, and obtain the word vectors of the words, so as to obtain the cause event type and the result event type for event causal relationship classification.

[0074] The first model classifies the word segments of each sentence in the target text to obtain classification labels, which can be labels of result event type and cause event type.

[0075] In this way, it is equivalent to achieving the classification of the causal relationship of the target text through the first model.

[0076] At the same time, the second model can also be used to process the target text to obtain the meaning or semantic similarity (or relevance) of the candidate cause event type and the candidate result event type, and obtain the prediction result of the event causal relationship of the target text.

[0077] The model structure of the second model is different from that of the first model; or the second model and the first model have the same model structure but different model parameters. The model parameters here may at least include: weights and / or thresholds of network nodes in the first model and the second model.

[0078] The second model also processes the target text and obtains a prediction result indicating the causal relationship of events contained in the target text. The prediction result also gives the causal relationship events contained in the target text.

[0079] The third model has a different model structure from the first model and the second model. The third model can combine the semantics of the input target text to obtain an output result of the event causal relationship of the target text, and the output result also points out the event causal relationship in the target text.

[0080] In the disclosed embodiment, the classification results of the first model, the prediction results of the second model, and the output results of the third model are combined to derive the event causal relationships contained in the target text (i.e., the target event causal relationships). In this way, the three models can complement each other in processing the target text, thereby improving the accuracy of extracting the event causal relationships in the target text and reducing the computational cost of extracting the event causal relationships from the target text and the cost of model training.

[0081] It is worth noting that the target text in the embodiment of the present disclosure is obtained in the following manner:

[0082] Get the original text;

[0083] Perform text preprocessing on the original text to obtain the target text.

[0084] The pre-processing of the original text may include at least one of the following:

[0085] Truncating or segmenting excessively long original text; for example, if the original text is larger than the maximum input text acceptable to the first, second, and third models, the original text needs to be truncated or segmented;

[0086] Performing synonymous conversion on the text so that the converted version is a text that can be processed by the first model, the second model, and the third model, for example, converting a traditional Chinese text to obtain a simplified Chinese text; or converting a simplified Chinese text to obtain a traditional Chinese text;

[0087] Convert text with a capital letter to uppercase, such as English text.

[0088] Of course, the above is only an example of preprocessing the original text, and in the specific implementation process, it can also include removing redundant words, or removing meaningless punctuation marks or function words, etc.

[0089] Through the above processing, the original text can be converted into the target text.

[0090] Reference Figure 10 As shown, after text preprocessing of the original text, the target text is obtained; and then the event extraction model composed of three models is used to realize the extraction of the result. In some other scenarios, the event extraction model can include a reading comprehension model belonging to the third model, a one-stage model belonging to the first model, and a two-stage model belonging to the second model.

[0091] In some embodiments, as Figure 3 As shown, the S110 can include:

[0092] S111: inputting the target text into the encoding layer of the first model to obtain an encoding sequence of the target text;

[0093] S112: performing classification processing on the encoding sequence to obtain classification labels of encoding data of each word in the encoding sequence, wherein the classification labels include a cause event type label and a result event type label;

[0094] S113: obtaining the classification result according to the classification labels.

[0095] The encoding layer of the first model can be a bidirectional encoder representation from transformers (BERT), which encodes the input target text to obtain the encoding sequence.

[0096] After obtaining the encoding sequence, the encoding sequence is further processed, and the classification result is obtained by performing conditional random field processing as an example. Each classification result will indicate whether each word in the target text belongs to the cause event type or the result event type.

[0097] In one embodiment, the S113 can include:

[0098] When the encoding sequence has one cause event type label and one result event type label, the cause event type label and the result event type label are combined to obtain the classification result;

[0099] When the coding sequence has multiple cause event type labels and / or multiple result event type labels, the classification results with the highest one or more classification probabilities are obtained based on the classification probabilities of the cause event type labels and / or the classification probabilities of the result event type labels output by the first model.

[0100] If after a target text is input, the first model outputs a cause event type label and a result event type label, then it is considered that the cause event corresponding to the cause event label and the result event corresponding to the result event type label are combined to form a causal event relationship.

[0101] If, after a text input, the first model outputs multiple cause event type labels or multiple result event type labels, then a cause event type label and a result event type label are combined to obtain multiple combinations. Each cause event type label and each result event type has a classification probability. The classification probability can be understood as the confidence level of the corresponding cause event type label and result event type label.

[0102] One or more combinations with the highest classification probability are obtained as the output of the classification result.

[0103] In this way, the causal relationship of events contained in the target text can be extracted with as little omission as possible.

[0104] In one embodiment, Figure 5 As shown, the S120 may include:

[0105] S121: using the classification branch of the second model, classifying the coding sequence of the target text to obtain labels of various candidate cause event types and candidate result event types;

[0106] S122: arbitrarily combining the candidate cause event types and the candidate result event types to obtain a candidate event causal relationship combination;

[0107] S123: Determine any one of the candidate relationship combinations and the coding sequence of the target text and input it into the prediction branch of the second model to obtain the similarity between the candidate cause event type and the candidate result event type in each of the candidate relationship combinations;

[0108] S124: Output the prediction result according to the similarity.

[0109] The second model first includes a classification branch and a prediction branch. The classification branch directly classifies the target text encoding sequence to obtain the alternative cause event type and the label of the alternative cause event type. Figure 4As shown, the branch on the left that outputs the classification score may be the classification branch of the first model; and the branch on the right that outputs the similarity score is an example of a prediction branch.

[0110] The classification branch includes BERT, a pooling layer, and a linear layer. BERT processes the target text and obtains labels for each word in the target text. Table 1 shows an example of a label.

[0111] Table 1. Complete set of output tags for sequence annotation

[0112]

[0113]

[0114] Through the pooling processing of the pooling layer and the connection processing of the linear layer, the classification score will be obtained.

[0115] All outputs of the classification branch are input into the prediction branch of the second model, which performs further processing to calculate the similarity between each alternative cause event type and the alternative result event type, thereby obtaining the prediction result.

[0116] Exemplarily, the prediction branch may include: BERT and a linear layer. The linear layer further processes the output of BERT to obtain a similarity score, which reflects the degree of similarity.

[0117] Finally, the second model will output the prediction results based on the similarity score of the similarity.

[0118] In one embodiment, the method further comprises:

[0119] Determine any one of the candidate relationship combinations and the coding sequence of the target text and input it into the event element extraction branch of the second model to obtain the event element output by the event element extraction branch.

[0120] The event element extraction branch of the second model can also include BERT and CRF. CRF is located at the back end of BERT and can be processed through cause event type and result event type to realize the processing through the event element extraction branch, and can extract event elements with causal relationship in the target text.

[0121] Event elements may include at least one of the following:

[0122] An event is a period of time or a point in time during which the state of a subject changes actively or passively.

[0123] Entity: a class or group of objects in a semantic category, for example, named entities, financial products, time or numerical values;

[0124] Event elements, entities that have a specific role in an event;

[0125] Element role, the role played by the event element.

[0126] In some embodiments, obtaining an output result of the event causal relationship of the target text using the third model according to the semantics of the target text includes:

[0127] The question sentence constructed based on the entities in the target text and the target text are input into the third model, and the output result of the event causal relationship of the target text is obtained through semantic matching between the question sentence and the target text.

[0128] The third model can also be a BERT-based model, which can construct a question statement based on the entity to determine the cause event type and / or result event type, and then input the question statement and the target text into the third model. The output result of the event causal relationship based on semantic processing is obtained by semantic matching of the question statement and the target text. Figure 6 An example of a third model is shown.

[0129] In some embodiments, as Figure 7 As shown, the S140 may include:

[0130] S141: Determine a causal relationship of a first candidate event based on the classification probability and the classification threshold of the classification result;

[0131] S142: Determine a causal relationship of a second candidate event based on the similarity of the prediction results and the similarity threshold;

[0132] S143: Determine a causal relationship of a third candidate event based on a matching degree between the question statement and the target text corresponding to the output result and a matching degree threshold;

[0133] S144: Determine an event causal relationship that belongs to the first candidate event causal relationship, the second candidate event causal relationship, and the third candidate event causal relationship as the target event causal relationship.

[0134] Exemplarily, the alternative event causal relationship with a classification probability higher than or equal to a classification threshold is determined as the first alternative event causal relationship, the alternative event causal relationship with a similarity higher than or equal to a similarity threshold is determined as a second alternative event causal relationship, and the alternative event causal relationship with a matching degree between the question sentence and the target text higher than a matching degree threshold is determined as a third alternative event causal relationship. The question sentence can be constructed according to the entity extracted from the target text.

[0135] In the embodiments of the present disclosure, the alternative event causal relationship that belongs to the first alternative event causal relationship, the second alternative event causal relationship and the third alternative event causal relationship at the same time is determined as a target event causal relationship that finally belongs to the target text.

[0136] The three models are used to extract the event causal relationship from the same target text at the same time, so that the correctness and accuracy of the extracted event causal relationship can be ensured.

[0137] In some other embodiments, if there is no event causal relationship that belongs to the first alternative event causal relationship, the second alternative event causal relationship and the third alternative event causal relationship at the same time, it can be determined whether there is an event causal relationship that belongs to the first alternative event causal relationship and the second alternative event causal relationship, and if there is, the question sentence and the target text are re-constructed for the target text, and the third alternative event causal relationship is obtained through the processing of the third model.

[0138] To solve the problem of low extraction accuracy when constructing an event graph, three technical solutions are adopted, and finally the model combination of the three solutions is used.

[0139] The three models are as follows:

[0140] Stage one: the event type and the event element are combined as a tag, and the sequence labeling model is used to judge the event type and the event element at the same time.

[0141] Two stages: first, the cause event type and the result event type are judged, and then the event elements defined in advance are extracted in combination with the causal type.

[0142] Reading comprehension (MRC): first, the cause event type and the result event type are judged, and then the question is constructed in combination with the causal type, and the MRC model is used to extract the segment where the element is located from the given text.

[0143] The event is defined as follows:

[0144] Event (event): at a certain time point or time period, the state of a subject has been changed actively or passively.

[0145] Entity: A class or group of objects in a semantic category. The entities discussed in this article include named entities, financial products, time, and numerical values.

[0146] Event argument: An entity that plays a specific role in an event.

[0147] Argument role: The role that an event element plays in the event.

[0148] The event extraction results are obtained through the one-stage model, and the prediction model of cause event type and result event type is used to obtain the top ten candidate results with the highest classification probability of cause and result event type.

[0149] MRC obtains the event extraction results based on the cause-result event type in step B through the reading comprehension model

[0150] The two stages obtain the event extraction results based on the cause and effect event types in step B.

[0151] After obtaining the results of the one-stage model, the two-stage model, and the MRC model, the results are voted and fused.

[0152] The one-stage model, also known as the first model mentioned above, uses BERT-CRF as the extraction framework and a combination of event type and event elements as labels to directly extract entities.

[0153] For example, in the sentence, "The sharp decline in profitability in the freight industry is the main reason for the weak demand for trucks", the cause event type is the decline in product profits, the cause industry is the freight industry, the result event type is the decrease in demand, and the result product is trucks.

[0154] The causal relationship extraction task has two event types: event cause and event result. Each event type has multiple event elements. The event cause and corresponding event elements are concatenated, as are the event elements corresponding to the event result. These are used as labels for the BERT-CRF sequence annotation model to extract related entities.

[0155] For example, a product entity whose cause event type is export decline is represented as export decline_reason_type_product.

[0156] Then use BERT-CRF to extract entities, such as Figure 2 As shown, R1-PB represents the starting position of the product whose cause event type is export decline.

[0157] The sentence with the extracted entity is input into the BERT-CRF model, and the input is input into the encoding layer, and each sentence is composed of a series of tokens {token1, j... tokenL, j}, where toki, j is the i-th token in the j-th sentence, and L is the sequence length of the j-th sentence. The token vector sequence obtained after each sentence is encoded by BERT is Htoken = {h1, j, h2, j,..., hL, j}, where hi, j is the vector corresponding to the i-th token in the j-th sentence, and the dimension is d. The sentence vector sequence is {h0, h1,..., hL}, h0 is the title sentence vector representation, hj is the vector representation of the j-th sentence in the document, and the dimension is d.

[0158] The desired causal event label is output after the CRF layer, and the desired extracted event is obtained through the label.

[0159] After obtaining the extracted entity, the event type needs to be combined. If there is only one event cause and event result, then directly combine the two cause and result pairs. If there are multiple event cause and result pairs, select the most frequent cause and result event pair as the final result.

[0160] The two-stage model is the second model described above. The two stages mainly include event type prediction and event element extraction. First, the cause event type and result event type corresponding to the given text are predicted, and then the event elements are predicted in combination with the event type.

[0161] In order to reflect the relationship between the cause event and the result event, the matching pair composed of the cause event type and the result event type is taken as the smallest granularity, rather than predicting the cause event type and the result event type separately.

[0162] As Figure 4 shown is a framework diagram for event type prediction, two models are used to predict the matching pair between the cause event type and the result event type. The first branch as shown in the left dashed box is a multi-classification model, the input is the given text, and the output is the classification of the causal relationship. The second branch as shown in the right dashed box is a text matching model, the input includes two parts, the first part is the matching pair between the selected cause event type and the result event type, connected by '#', and the second part is the given text, and the output is the similarity score of the matching pair between the selected cause event type and the result event type.

[0163] The classification score and the similarity score are combined to sort the matching pair of the candidate cause event type and the result event type, so as to predict the matching pair of (cause event type, result event type).

[0164] As Figure 5The following figure shows the framework for event feature extraction. Sequence labeling is performed using BERT and CRF as sequence feature extraction models. The full set of tags included in sequence labeling is shown in Table 1, with a total of 13 tags defined. The input for sequence labeling consists of two parts: the first part is the cause event type and the result event type predicted in the previous step, connected by a '#', and the second part is the given text. Sequence labeling models are trained for the event elements of the cause event and the event elements of the result event, respectively, to predict the cause event elements and the result event elements.

[0165] Through experiments, it is found that this method is more effective than using a single model to predict both the cause event elements and the result event elements. After predicting the cause event elements and the result event elements, they are combined as the final event element extraction result.

[0166] Table 2. Full set of output labels for sequence annotation

[0167]

[0168] The three-stage model, the third model mentioned above, is an event extraction model based on reading comprehension. After determining the event type, it uses reading comprehension to extract entities. Because both cause and effect event types have three fixed entity types to be extracted, a question can be constructed for each entity type as input to the MRC model. For example, for the product that is the cause of the export decline event, the question "Find the cause of the ##product## in the ##export decline## event" can be constructed as input to the MRC model. Figure 8 This is an example of the third model. The third model can also be based on BERT. A dense connection layer is connected to the output of BERT. This dense connection layer outputs the argument through dense connections. This argument indicates the argument of the causal event relationship extracted from the target text.

[0169] Using BERT-like models for span extraction-type machine reading comprehension (MRC) tasks often achieves impressive results. Spans are used to annotate the locations of entities in the text, and each location is considered as two binary classification tasks: predicting whether the location is the start position of the span and whether the location is the end position of the span.

[0170] Because some entities do not exist in some sentences, the three words "no answer" are added to each input sentence. In this way, some negative samples can be constructed, that is, those entities that have no answers in the text, and no answers can be used as entities.

[0171] The MRC model uses entity category information as input for training. This effectively uses enhanced information during extraction and indirectly increases the amount of data. Assuming a document contains n different event types, and each event type contains an average of m extractable arguments, the document can be expanded by a factor of n*m, effectively performing data augmentation.

[0172] The final result is obtained by processing the results of multiple models. After obtaining the results of the three models mentioned above, the three sets of results are combined. Ten one-stage models and ten two-stage models are trained through cross-validation. These two models are then combined using voting. During the combination, if a (cause event type, result event type) pair appears once for the next event element, it receives one vote. A threshold is set, and event elements with a number of votes above the threshold are retained. A total of 20 models are used, with a threshold set to 6. The result is recorded as WITHOUT_MRC.

[0173] Similarly, 20 extraction models based on reading comprehension were trained through cross-validation, with a threshold of 18. The resulting results were recorded as MRC. Finally, the WITHOUT_MRC results and the MRC results were merged. During the merging process, if both WITHOUT_MRC and MRC had results, the MRC results were overwritten with the WITHOUT_MRC results. This resulted in the final event causal relationship extraction results, recorded as FINAL.

[0174] To verify the effectiveness of the model, 1,000 data points were constructed offline. This task used precision (P), recall (R), and F1-measure (F1-measure) to evaluate the effectiveness of event element recognition. The F-measure was calculated using micro-averaging, meaning that P and R were calculated for all sample elements. The two event types, cause event and result event, and their corresponding elements constituted a single statistical item. Recognizing only the cause and result event types without correctly identifying the event elements was not considered correct. A combination of the same cause event and result event types can have at most one set of results.

[0175] We tested the model on the test set. As shown in Table 2, the combination of the one-stage and two-stage models achieved an F1 score of 0.5869. Furthermore, after combining the results of the reading comprehension test, the F1 score increased to 0.5986.

[0176]

[0177]

[0178] Table 2

[0179] like Figure 10 As shown, an embodiment of the present disclosure provides a text processing device, the device comprising:

[0180] The first model module 110 is used to classify the target text using the first model to obtain a classification result of the event causal relationship of the target text;

[0181] A second model module 120 is configured to process the target text using a second model to obtain similarities between candidate cause event types and candidate result event types, and obtain a prediction result of the event causal relationship of the target text output by the second model based on the similarities;

[0182] A third model module 130 is configured to obtain an output result of the event causal relationship of the target text based on the semantics of the target text using the third model;

[0183] The determination module 140 is configured to determine the causal relationship of the target event of the target text according to the classification result, the prediction result, and the output result.

[0184] The text processing device may be included in various electronic devices. The electronic devices include, but are not limited to, terminal devices and / or servers. The terminal devices include, but are not limited to, mobile phones, tablet computers, wearable devices, in-vehicle devices, smart home devices, or smart office devices.

[0185] In some embodiments, the first model module 110 , the second model module 120 , the third model module 130 and the determination module 140 may be program modules; after being executed by a processor, the program modules can realize the functions of the above modules.

[0186] In other embodiments, the first model module 110, the second model module 120, the third model module 130 and the determination module 140 may be a software and hardware combination module; the software and hardware combination module may include various programmable arrays, including but not limited to: field programmable arrays and / or complex programmable arrays.

[0187] In some other embodiments, the first model module 110 , the second model module 120 , the third model module 130 and the determination module 140 may be pure hardware modules; the pure hardware modules include but are not limited to application-specific integrated circuits.

[0188] In some embodiments, the first model module 110 is specifically used to input the target text into the encoding layer of the first model to obtain an encoding sequence of the target text; classify the encoding sequence to obtain classification labels of the encoding data of each word in the encoding sequence, wherein the classification labels include: cause event type labels and result event type labels; and obtain the classification results based on the classification labels.

[0189] In some embodiments, the first model module 110 is further specifically used to, when the coding sequence has one cause event type label and one result event type label, combine the cause event type label and the result event type label to obtain the classification result; when the coding sequence has multiple cause event type labels and / or multiple result event type labels, obtain one or more classification results with the highest classification probability based on the classification probability of the cause event type label and / or the classification probability of the result event type label output by the first model.

[0190] In some embodiments, the second model module 120 is specifically used to use the classification branch of the second model to classify the coding sequence of the target text to obtain labels of each alternative cause event type and alternative result event type; arbitrarily combine the alternative cause event type and the alternative result event type to obtain an alternative event causal relationship combination; determine any one of the alternative relationship combinations and the coding sequence of the target text to input into the prediction branch of the second model to obtain the similarity of the alternative cause event type and the alternative result event type in each of the alternative relationship combinations; and output the prediction result based on the similarity.

[0191] In some embodiments, the apparatus further comprises:

[0192] The event element module is used to determine any one of the alternative relationship combinations and the coding sequence of the target text and input it into the event element extraction branch of the second model to obtain the event element output by the event element extraction branch.

[0193] In some embodiments, the apparatus further comprises:

[0194] The output module is used to determine the output event elements according to the number of occurrences of each event element of the prediction result of the causal relationship of the target event.

[0195] In some embodiments, the third model module 130 is used to input the question statement constructed based on the entities in the target text and the target text into the third model, and obtain the output result of the event causal relationship of the target text through semantic matching between the question statement and the target text.

[0196] In some embodiments, the determination module 140 is specifically used to determine the first alternative event causal relationship based on the classification probability and classification threshold of the classification result; determine the second alternative event causal relationship based on the similarity and similarity threshold of the prediction result; determine the third alternative event causal relationship based on the matching degree and matching threshold of the question statement corresponding to the output result and the target text; and determine the event causal relationship that belongs to the first alternative event causal relationship, the second alternative event causal relationship and the third alternative event causal relationship as the target event causal relationship.

[0197] Figure 11 FIG1 is a block diagram of an electronic device 800 according to an exemplary embodiment. For example, the electronic device 800 may be included in a terminal device such as a mobile phone, a mobile computer, or a device such as a server.

[0198] Reference Figure 11 , the electronic device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , a multimedia data component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 816 .

[0199] The processing component 802 generally controls the overall operation of the electronic device 800, such as operations associated with display, phone calls, data communications, camera operation, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to perform all or part of the steps of the above-described method. In addition, the processing component 802 may include one or more modules to facilitate interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.

[0200] The memory 804 is configured to store various types of data to support operations on the device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device, or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk.

[0201] The power component 806 provides power to the various components of the electronic device 800. The power component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 800.

[0202] The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, slides, and gestures on the touch panel. The touch sensor can not only sense the boundaries of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the device 800 is in an operating state, such as a shooting state or a video state, the front camera and / or the rear camera can receive external multimedia data. Each front camera and rear camera can be a fixed optical lens system or have focal length and optical zoom capabilities.

[0203] The multimedia data component 810 is configured to output and / or input multimedia data signals. For example, the multimedia data component 810 includes a microphone (MIC) that is configured to receive external multimedia data signals when the electronic device 800 is in an operating state, such as a call state, a recording state, and a voice recognition state. The received multimedia data signals can be further stored in the memory 804 or transmitted via the communication component 816.

[0204] In some embodiments, the multimedia data component 810 further includes a speaker for outputting multimedia data signals.

[0205] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as a keyboard, click wheel, operation buttons, etc. These operation buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.

[0206] The sensor assembly 814 includes one or more sensors for providing various aspects of status assessment for the electronic device 800. For example, the sensor assembly 814 can detect the open / closed state of the device 800, the relative positioning of components, such as the display and keypad of the electronic device 800. The sensor assembly 814 can also detect changes in the position of the electronic device 800 or a component of the electronic device 800, the presence or absence of user contact with the electronic device 800, the orientation or acceleration / deceleration of the electronic device 800, and temperature changes of the electronic device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0207] The communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 can access a wireless network based on a communication standard, such as Wi-Fi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0208] In an exemplary embodiment, the apparatus 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above-described method.

[0209] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, which can be executed by the processor 820 of the apparatus 800 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0210] After the processor 820 executes the above instructions, the following steps may be performed:

[0211] The first model is used to classify the target text to obtain a classification result of the event causality of the target text.

[0212] The second model is used to process the target text to obtain a similarity of a candidate cause event type and a candidate result event type, and a prediction result of the event causality of the target text output by the second model is obtained based on the similarity.

[0213] A third model is used to obtain an output result of the event causality of the target text according to semantics of the target text.

[0214] According to the classification result, the prediction result, and the output result, a target event causality of the target text is determined.

[0215] It can be understood that the first model is used to classify the target text to obtain a classification result of the event causality of the target text, including:

[0216] The target text is input into an encoding layer of the first model to obtain an encoding sequence of the target text.

[0217] The encoding sequence is classified to obtain a classification label of encoding data of each word in the encoding sequence, wherein the classification label includes a cause event type label and a result event type label.

[0218] The classification result is obtained according to the classification label.

[0219] It can be understood that the classification result is obtained according to the classification label and the classification probability, including:

[0220] When the encoding sequence has one cause event type label and one result event type label, the cause event type label and the result event type label are combined to obtain the classification result.

[0221] When the encoding sequence has multiple cause event type labels and / or multiple result event type labels, the classification probability of the cause event type label and / or the classification probability of the result event type label output by the first model are used to obtain the classification result of one or more with the highest classification probability.

[0222] It can be understood that the second model is used to process the target text to obtain a similarity of a candidate cause event type and a candidate result event type, and a prediction result of the event causality of the target text output by the second model is obtained based on the similarity, including:

[0223] Using the classification branch of the second model, classify the coding sequence of the target text to obtain labels of each candidate cause event type and candidate result event type;

[0224] Arbitrarily combining the candidate cause event types and the candidate result event types to obtain a candidate event causal relationship combination;

[0225] Determine any one of the candidate relationship combinations and the coding sequence of the target text to be input into the prediction branch of the second model, and obtain the similarity between the candidate cause event type and the candidate result event type in each of the candidate relationship combinations;

[0226] The prediction result is output according to the similarity.

[0227] It is understood that the method further comprises:

[0228] Determine any one of the candidate relationship combinations and the coding sequence of the target text and input it into the event element extraction branch of the second model to obtain the event element output by the event element extraction branch.

[0229] It is understood that the method further comprises:

[0230] The event elements to be output are determined according to the number of occurrences of each event element of the prediction result of the causal relationship of the target event.

[0231] It can be understood that the output result of the event causal relationship of the target text obtained by using the third model according to the semantics of the target text includes:

[0232] The question sentence constructed based on the entities in the target text and the target text are input into the third model, and the output result of the event causal relationship of the target text is obtained through semantic matching between the question sentence and the target text.

[0233] It can be understood that determining the causal relationship of the target event of the target text according to the classification result, the prediction result and the output result includes:

[0234] Determining a causal relationship of a first candidate event based on the classification probability and the classification threshold of the classification result;

[0235] Determining a causal relationship of a second alternative event based on the similarity of the prediction results and a similarity threshold;

[0236] Determining a causal relationship of a third candidate event based on a matching degree between the question statement and the target text corresponding to the output result and a matching degree threshold;

[0237] An event causal relationship that belongs to the first candidate event causal relationship, the second candidate event causal relationship, and the third candidate event causal relationship is determined as the target event causal relationship.

[0238] Other embodiments of the present disclosure will readily occur to those skilled in the art after considering the specification and practicing the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the following claims.

[0239] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A text processing method, characterized in that: The method comprises: Inputting the target text into the encoding layer of the first model to obtain an encoding sequence of the target text; Classifying the coding sequence to obtain classification labels of the coding data of each word in the coding sequence, wherein the classification labels include: cause event type labels and result event type labels; Obtaining a classification result of the event causal relationship of the target text according to the classification label; Using the classification branch of the second model, the coding sequence of the target text is classified to obtain labels of each candidate cause event type and candidate result event type; Arbitrarily combining the candidate cause event types and the candidate result event types to obtain a candidate event causal relationship combination; Determine any one of the candidate event causal relationship combinations and the coding sequence of the target text to be input into the prediction branch of the second model, and obtain the similarity between the candidate cause event type and the candidate result event type in each of the candidate event causal relationship combinations; Outputting a prediction result of the event causal relationship of the target text according to the similarity; Inputting a question sentence constructed from entities in the target text and the target text into a third model, and obtaining an output result of the event causal relationship of the target text through semantic matching between the question sentence and the target text; The target event causal relationship of the target text is determined according to the classification result, the prediction result and the output result.

2. The method according to claim 1, characterized in that Obtaining a classification result of the event causal relationship of the target text according to the classification label includes: When the coding sequence has one of the cause event type labels and one of the result event type labels, combining the cause event type label and the result event type label to obtain the classification result; When the coding sequence has multiple cause event type labels and / or multiple result event type labels, the classification results with the highest one or more classification probabilities are obtained based on the classification probabilities of the cause event type labels and / or the classification probabilities of the result event type labels output by the first model.

3. The method according to claim 1 or 2, characterized in that The method further comprises: Determine any one of the candidate event causal relationship combinations and the coding sequence of the target text and input it into the event element extraction branch of the second model to obtain the event element output by the event element extraction branch.

4. The method according to claim 3, characterized in that The method further comprises: The event elements to be output are determined according to the number of occurrences of each event element of the prediction result of the causal relationship of the target event.

5. The method according to claim 1 or 2, characterized in that Determining the target event causal relationship of the target text according to the classification result, the prediction result, and the output result includes: Determining a causal relationship of a first candidate event based on the classification probability and the classification threshold of the classification result; Determining a causal relationship of a second alternative event based on the similarity of the prediction results and a similarity threshold; Determining a causal relationship of a third candidate event based on a matching degree between the question statement and the target text corresponding to the output result and a matching degree threshold; An event causal relationship that belongs to the first candidate event causal relationship, the second candidate event causal relationship, and the third candidate event causal relationship is determined as the target event causal relationship.

6. A text processing device, characterized in that: The device comprises: The first model module is configured to input a target text into the encoding layer of the first model to obtain an encoding sequence of the target text; perform classification processing on the encoding sequence to obtain classification labels for the encoding data of each word in the encoding sequence, wherein the classification labels include: a cause event type label and a result event type label; and obtain a classification result of the event causal relationship of the target text based on the classification labels; The second model module is configured to classify the target text's coding sequence using the classification branch of the second model to obtain labels for each candidate cause event type and candidate result event type; arbitrarily combine the candidate cause event type and the candidate result event type to obtain a candidate event causal relationship combination; determine any one of the candidate event causal relationship combinations and the coding sequence of the target text and input them into the prediction branch of the second model to obtain similarities between the candidate cause event type and the candidate result event type in each candidate event causal relationship combination; and output a prediction result of the event causal relationship of the target text based on the similarities; A third model module is configured to input a question sentence constructed based on entities in the target text and the target text into a third model, and obtain an output result of the event causal relationship of the target text through semantic matching between the question sentence and the target text; A determination module is used to determine the causal relationship of the target event of the target text according to the classification result, the prediction result and the output result.

7. The device according to claim 6, characterized in that The first model module is further specifically configured to, when the coding sequence has one cause event type label and one result event type label, combine the cause event type label and the result event type label to obtain the classification result; When the coding sequence has multiple cause event type labels and / or multiple result event type labels, the classification results with the highest one or more classification probabilities are obtained based on the classification probabilities of the cause event type labels and / or the classification probabilities of the result event type labels output by the first model.

8. The device according to claim 6 or 7, characterized in that The device further comprises: An event element module is used to determine any one of the candidate event causal relationship combinations and the coding sequence of the target text and input it into the event element extraction branch of the second model to obtain the event element output by the event element extraction branch.

9. The device according to claim 8, characterized in that The device further comprises: The output module is used to determine the output event elements according to the number of occurrences of each event element of the prediction result of the causal relationship of the target event.

10. The device according to claim 6 or 7, characterized in that The determination module is specifically configured to determine the causal relationship of the first candidate event based on the classification probability and the classification threshold of the classification result; and determine the causal relationship of the second candidate event based on the similarity and the similarity threshold of the prediction result; Determining a causal relationship of a third candidate event based on a matching degree between the question statement and the target text corresponding to the output result and a matching degree threshold; An event causal relationship that belongs to the first candidate event causal relationship, the second candidate event causal relationship, and the third candidate event causal relationship is determined as the target event causal relationship.

11. An electronic device, characterized in that: include: a memory for storing processor-executable instructions; a processor connected to the memory; The processor is configured to execute the method provided in any one of claims 1 to 5.

12. A non-transitory computer-readable storage medium, which, when the instructions in the storage medium are executed by a processor of a computer, enables the computer to perform the method provided in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Event determination method, related equipment and readable storage medium

    CN111460831A

  • Question and answer response method and device, equipment and storage medium

    CN111506723A