A method and device for extracting financial events
By performing sentence-partitioning, word-partitioning and sequence annotation on financial event texts, combined with sentence vector accumulation technology, the misjudgment or misjudgment problems caused by misuse or misuse of trigger words in the existing technology are solved, and the accuracy of event extraction is improved.
Patent Information
- Application Number
- CN202210475459.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-29
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2042-04-29
AI Technical Summary
Existing machine learning-based event extraction methods are prone to misjudgment or misjudgment due to misuse or misuse of trigger words, especially in financial event descriptions.
By processing sentence and word segmentation for the extracted text, obtain word vectors and position vectors, and accumulate them to obtain the output vector; then sequence annotation is performed based on the predefined element annotation sequence, and the event elements are marked; the output vectors of the event elements and the sentence vector are accumulated to determine whether the clause belongs to the preset type financial event.
By analyzing the overall information of the sentence, the misjudgment and misjudgment are reduced, and the accuracy of text event type detection is improved, thereby improving the effect of event extraction tasks.
Smart Images

Figure CN115062615B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and in particular to a method and device for extracting events in the financial field. Background Art
[0002] Event extraction is an important research direction in the field of natural language processing, and has important applications in intelligent question answering, knowledge graphs, information retrieval, automatic summarization, and other fields. Event extraction aims to automatically extract events of interest to users from unstructured text data and represent them in a structured form. A structured event usually consists of event trigger words, event types, event elements, and element roles.
[0003] At present, event extraction methods can be roughly divided into two categories: pattern matching-based methods and machine learning-based methods. Most of the early event extractions were based on pattern matching methods, which used a large number of rules or patterns manually formulated based on syntax trees or regular expressions. Machine learning-based methods are roughly divided into pipeline extraction and joint extraction. The pipeline extraction method converts event extraction into a multi-stage classification problem, sequentially performing event type detection tasks and event element recognition tasks; the joint extraction method takes into account the mutual influence between event trigger words and event elements, optimizes each classification model as a whole, and adds global features to jointly extract event types and event elements. Summary of the invention
[0004] The inventors have found that, at present, most of the event extraction methods based on machine learning only judge the event type by the type of trigger words, but in the actual event description, the trigger words of the corresponding event may not be used, or the trigger words of other events may be used, which is easy to cause misjudgment or missed judgment. In order to at least partially solve the technical problems existing in the prior art, the inventors have made the present invention, and through specific implementation methods, the technical solutions provided are as follows:
[0005] In a first aspect, an embodiment of the present invention provides a method, the method comprising the following steps:
[0006] Segment the text to be extracted and perform word segmentation processing to obtain a sentence set of the text to be extracted and a word segmentation set of each sentence;
[0007] For each sentence in the sentence set, obtain the word vector and position vector of each word in the sentence, and accumulate the word vector and the corresponding position vector to obtain the output vector of the corresponding word;
[0008] According to the predefined element annotation sequence, sequence annotation is performed on each sentence to annotate the participles in the sentence that belong to the event element; the event element is an entity corresponding to the corresponding type of event role in the financial event;
[0009] Obtaining a sentence vector of a clause, and accumulating an output vector of a word belonging to an event element in the clause with the sentence vector of the clause to obtain an accumulation result;
[0010] According to the accumulated result, determining whether the sentence belongs to an event sentence of a preset type of financial event in a preset event classification model; the preset event classification model is obtained by training based on pre-annotated training text;
[0011] If so, the structured event corresponding to the clause is output.
[0012] Furthermore, the acquiring of the sentence vector of the sentence, accumulating the output vector of the word belonging to the event element in the sentence with the sentence vector of the sentence to obtain the accumulation result, includes:
[0013] According to the attention mechanism, the output vectors of all the words in the sentence are weighted summed to obtain the sentence vector of the sentence;
[0014] The output vector of the word belonging to the event element in the sentence is added to the sentence vector of the sentence to obtain an accumulation result.
[0015] Furthermore, the preset event classification model includes a feedforward neural network and a normalized classifier;
[0016] Determining whether the sentence belongs to an event sentence of a preset type of financial event in a preset event classification model according to the accumulation result includes:
[0017] Analyzing the accumulated result in a feedforward neural network to obtain a feature vector with a dimension of 2;
[0018] The feature vector with a dimension of 2 is normalized in a normalized classifier to obtain a classification result of a corresponding sentence, and based on the classification result, it is determined whether the sentence belongs to an event sentence of a preset type of financial event.
[0019] Furthermore, the performing sequence labeling on each sentence according to the predefined element labeling sequence to label the participles in the sentence belonging to the event element includes:
[0020] According to the predefined element annotation sequence, use the preset event element extraction model to perform sequence annotation on each sentence and annotate the participles in the sentence that belong to the event element;
[0021] The preset event element extraction model includes a fully connected layer neural network and a conditional random field, and is trained based on the pre-labeled training text.
[0022] Furthermore, the pre-annotated training text is obtained by:
[0023] Generate index information of each original text in the original text set;
[0024] For each original text, entities that meet the corresponding type of event roles in the original text are classified and extracted according to each event role in a predefined financial event structure to obtain a candidate entity set; the predefined financial event structure includes event roles constituting the corresponding financial event and attributes of the event roles, and the attributes of the event roles include whether it is a core event role;
[0025] According to the predefined financial event structure, various entities in the candidate entity set are arranged and combined to form a first candidate event set;
[0026] According to the text features and position features of each candidate event in the first candidate event set in the corresponding original text, in a preset classifier, screen out the real events in the first candidate event set;
[0027] Writing the real event and the index information of the original text corresponding to the real event into the financial event knowledge base;
[0028] According to the index information of the original text in the financial event knowledge base, each event role of the real event in the financial event knowledge base is respectively annotated to the corresponding entity in the corresponding original text to obtain the event element annotated text;
[0029] Sentences in the event element annotation text that contain core event role annotations and whose number of event role annotations is greater than a preset number are annotated as event sentences to obtain a pre-annotated training text.
[0030] Furthermore, the method of screening out real events in the first candidate event set in a preset classifier according to text features and position features of each candidate event in the first candidate event set in the corresponding original text includes:
[0031] Filter the candidate events in the first candidate event set according to a preset filtering condition to obtain a second candidate event set;
[0032] According to the text features and position features of each candidate event in the second candidate event set in the corresponding original text, the real events in the second candidate event set are screened in a preset classifier.
[0033] Furthermore, the method of screening out real events in the second candidate event set in a preset classifier according to text features and position features of each candidate event in the second candidate event set in the corresponding original text includes:
[0034] For each candidate event in the second candidate event set, construct a feature vector of the corresponding candidate event according to the part of speech, word frequency, word length, and position of each entity in the candidate event in the corresponding original text;
[0035] The feature vector of the candidate event is input into a preset classifier to determine whether the corresponding candidate event belongs to a preset type of financial event, and obtain the real event in the second candidate event set.
[0036] Furthermore, the sentence and word segmentation processing is performed on the text to be extracted to obtain a sentence set of the text to be extracted and a word segmentation set of each sentence, including:
[0037] Set standard sentence length;
[0038] Sentence the extracted text according to the punctuation marks with sentence meaning;
[0039] If the length of the sentence after the clause is greater than the standard clause length, the clause is divided using the punctuation mark whose clause length is less than and closest to the standard clause length;
[0040] Filling the sentences whose length after the sentence is less than the standard sentence length to the standard sentence length with a filling symbol, so as to obtain the sentence set of the text to be extracted;
[0041] The word segmentation tool is used to segment each sentence in the sentence set to obtain a word segmentation set for each sentence.
[0042] Furthermore, the sentence and word segmentation processing of the text to be extracted is performed to obtain a sentence set of the text to be extracted and a word segmentation set of each sentence, and further includes:
[0043] Set the standard number of sentences. When the number of sentences segmented from the text to be extracted reaches the standard number of sentences, the remaining text is truncated; when the number of sentences segmented from the text to be extracted is less than the standard number of sentences, fill symbols are used to supplement it to the standard number of sentences.
[0044] In a second aspect, an embodiment of the present invention provides a financial field event extraction device, characterized in that it includes a text preprocessing module, a word vector generation module, an event element extraction module, a sentence vector accumulation module, an event classification module and an event output module, wherein:
[0045] The text preprocessing module is used to perform sentence and word segmentation processing on the text to be extracted, and obtain a sentence set of the text to be extracted and a word segmentation set of each sentence;
[0046] The word vector generation module is used to obtain the word vector and position vector of each word in each sentence in the sentence set, and accumulate the word vector and the corresponding position vector to obtain the output vector of the corresponding word;
[0047] The event element extraction module is used to perform sequence annotation on each sentence according to a predefined element annotation sequence, and annotate the participles in the sentence that belong to the event element; the event element is an entity corresponding to the corresponding type of event role in the financial event;
[0048] The sentence vector accumulation module is used to obtain the sentence vector of the sentence, and accumulate the output vector of the word belonging to the event element in the sentence with the sentence vector of the sentence to obtain an accumulation result;
[0049] The event classification module is used to determine whether the sentence belongs to an event sentence of a preset type of financial event in a preset event classification model according to the accumulation result; the preset event classification model is trained based on pre-annotated training text;
[0050] The event output module is used to output the structured event corresponding to the sentence when the sentence belongs to an event sentence of a preset type of financial event.
[0051] The beneficial effects of the above technical solution provided by the embodiment of the present invention include at least:
[0052] After the text to be extracted is segmented into sentences and words, the embodiment of the present invention accumulates the word vectors and position vectors of the word segmentation to obtain the output vector of the corresponding word segmentation; then, according to the predefined element annotation sequence, sequence annotation is performed on each sentence to obtain the event element annotation result of the corresponding sentence; and according to the event element annotation result, the output vector of the word segmentation belonging to the event element in the sentence is accumulated with the sentence vector of the sentence, and it is judged whether the sentence belongs to the event sentence of the preset type of financial event according to the accumulation result, and if so, the structured event corresponding to the sentence is output. The embodiment of the present invention judges whether the corresponding sentence belongs to the event sentence of the preset type of event according to the event elements contained in each sentence in the text, thereby judging the event type in the text. Compared with the prior art of judging the event type in the text by trigger words, by analyzing the overall information of the sentence, the elements of judgment are increased, which can reduce the situation of misjudgment and missed judgment, improve the accuracy of text event type detection, and thus improve the extraction effect of the event extraction task.
[0053] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings.
[0054] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0056] Figure 1 This is a flow chart of a method for extracting financial events in an embodiment of the present invention;
[0057] Figure 2 This is a flow chart of another method for extracting financial events in an embodiment of the present invention;
[0058] Figure 3 This is a schematic diagram of the structure of a financial field event extraction model in an embodiment of the present invention;
[0059] Figure 4 A schematic diagram of a flow chart of a method for obtaining pre-labeled training text in an embodiment of the present invention;
[0060] Figure 5 A flowchart of another method for obtaining pre-labeled training text in an embodiment of the present invention;
[0061] Figure 6 This is a schematic diagram of the structure of a financial field event extraction device in an embodiment of the present invention. DETAILED DESCRIPTION
[0062] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0063] In order to better understand the present invention, some special terms are introduced below.
[0064] Entity: An object or collection of objects in a semantic category, such as a company name, date, and price.
[0065] Event: Something that has happened / may happen / will happen in the real world, generally including time, place, and characters, such as company listing, company bankruptcy, financing, investment, etc.
[0066] Role: The participants and attributes of an event, usually filled with entities. For example, the listed company, listing date and opening price are the roles of the "company listing" event.
[0067] The embodiment of the present invention provides a method for extracting financial events. Figure 1 As shown, the following steps are included:
[0068] S11, performing sentence and word segmentation processing on the text to be extracted to obtain a sentence set of the text to be extracted and a word segmentation set of each sentence.
[0069] Specifically, the text to be extracted is first segmented using a preset sentence segmentation tool, and then each sentence is segmented using an open source word segmentation tool such as hanlp, jieba, etc.
[0070] In one embodiment, the sentence length output by the preset sentence segmentation tool is a fixed value, so that the word segmentation tool can segment the sentence.
[0071] Specifically, in the preset sentence segmentation tool, a standard sentence length is set. When a text to be extracted is input, the preset sentence segmentation tool segments the text to be extracted according to punctuation marks with sentence meaning. If the length of the sentence after segmentation is greater than the standard sentence length, the punctuation mark whose sentence length is less than and closest to the standard sentence length is used for sentence segmentation. Then, the sentence whose length after segmentation is less than the standard sentence length is filled to the standard sentence length with a filling symbol to obtain a sentence set of the text to be extracted. The obtained sentence set is input into the word segmentation tool for word segmentation, that is, a word segmentation set of each sentence is obtained.
[0072] For example, the standard sentence length is set to 64 characters. After segmenting the original text in Table 1 using the preset sentence segmentation tool, the sentence set in Table 2 is obtained, in which the filler symbols are omitted.
[0073]
[0074] Table 1
[0075]
[0076]
[0077] Table 2
[0078] In one embodiment, the number of sentences output by the preset sentence segmentation tool is a fixed value, so that the word segmentation tool can segment the sentences.
[0079] Specifically, in the preset sentence segmentation tool, a standard number of sentences is also set, for example, set to 5 sentences. On the basis of the above sentence segmentation method, when the number of sentences segmented by the preset sentence segmentation tool for the extracted text reaches the standard number of sentences, the remaining text is truncated; when the number of sentences segmented by the preset sentence segmentation tool for the extracted text is less than the standard number of sentences, fill symbols are used to supplement the number of sentences to the standard number. According to this sentence segmentation method, a sentence set consisting of the standard number of sentences is obtained. The obtained sentence set is input into the word segmentation tool for word segmentation, that is, a word segmentation set for each sentence is obtained.
[0080] S12, for each sentence in the sentence set, obtain the word vector and position vector of each word in the sentence, and accumulate the word vector and the corresponding position vector to obtain the output vector of the corresponding word.
[0081] Specifically, the preset BERT layer (Bidirectional Encoder Representations from Transformers) can be used to convert each word segment into a corresponding word vector, and the word vector has a fixed dimension, for example, 64 dimensions. In addition, a position vector is added to each word segment in the BERT layer to indicate the position of each word segment in the corresponding sentence. The word vector and position vector of the word segment are accumulated in each dimension to obtain the output vector of the corresponding word segment in each sentence.
[0082] The preset BERT layer is obtained by training the training text. During model training, the specific method for determining the position vector of a word segmentation can be: randomly initialize a parameter matrix P = [max_sentence_len, width], wherein each row of the parameter matrix P represents the position vector of each word segmentation in the corresponding sentence, and width represents the dimension of the position vector, which is consistent with the dimension of the word vector. Then, the elements in P are continuously updated during the model training process to obtain the position vector of each word segmentation in the corresponding sentence.
[0083] S13, performing sequence labeling on each sentence according to a predefined element labeling sequence, and labeling the participles in the sentence that belong to the event element.
[0084] It should be noted that the event element is an entity corresponding to a corresponding type of event role in a financial event.
[0085] Specifically, according to the event roles contained in the target type event to be extracted, a predefined element annotation sequence is defined, wherein the element annotation sequence includes labels of each event role and labels of non-event roles; according to the predefined element annotation sequence, sequence annotation is performed on each sentence, and a label is labeled for each word in the sentence, wherein a word labeled with a certain event role label is an event element or a part of an event element, and considering that some entities may be split into multiple words, these words are combined and regarded as an event element. When the target type event to be extracted includes multiple categories, the element annotation sequence includes labels of all event roles in these types of events.
[0086] Among them, the sequence labeling step can adopt the BIO (begin-inside-outside) labeling format, that is, each participle is marked as one of BX, IX or O, where BX means that the segment where the corresponding participle belongs to the X type event role and the participle is at the beginning of this segment, IX means that the segment where the corresponding participle belongs to the X type event role and the participle is in the middle or end of this segment, and O means that the corresponding participle does not belong to any event role. After completing the BIO labeling, the participles belonging to the event elements in the sentence can be identified.
[0087] In one embodiment, Figure 2 As shown, step S13 includes:
[0088] S131, according to the predefined element annotation sequence, using the preset event element extraction model, performing sequence annotation on each sentence, and annotating the participles belonging to the event element in the sentence.
[0089] Specifically, the event element extraction submodel includes a fully connected layer neural network and a CRF (conditional random field) layer. When working, the event element extraction submodel receives the output vector of the word segmentation in each sentence obtained by step S12, learns the state characteristics of the output vector of the word segmentation in the predefined element labeling sequence through the fully connected layer neural network, obtains the state score of each word segmentation, inputs the state score of each word segmentation into the CRF layer, and learns a transfer score matrix by the CRF layer. Each column in the matrix represents the probability value of the corresponding word segmentation for various labels, and the label with the largest probability value is marked on the corresponding word segmentation. Among them, the word segmentation marked as a certain event role label is the event element or a part of the event element.
[0090] It should be noted that the event element extraction model is trained based on the pre-annotated training text. The pre-annotated training text includes annotations of event elements and event sentences, which can be obtained by manual annotation or automatic annotation based on machine learning methods.
[0091] S14, obtaining a sentence vector of a sentence, and accumulating an output vector of a word belonging to an event element in the sentence with the sentence vector of the sentence to obtain an accumulation result.
[0092] Specifically, through step S13, the words in the sentence that belong to the event element have been marked, and the output vectors of these words can be directly obtained. The sentence vector of the sentence is obtained by summing the word vectors of each word in the sentence, which can be directly accumulated or averaged.
[0093] Preferably, in one embodiment, Figure 2 As shown, step S14 specifically includes:
[0094] S141, according to the attention mechanism, weighted sum is performed on the output vectors of all the words in the sentence to obtain the sentence vector of the sentence.
[0095] S142, accumulating the output vector of the word belonging to the event element in the sentence with the sentence vector of the sentence to obtain an accumulation result.
[0096] For example, in the framework of the attention mechanism, we can use the key vector i ) and the value vector (value i ) represents the word vector of the word segmentation, and then randomly initializes a query vector (Query Vector), performs a dot product operation on the query vector and the key vector of the word segmentation, and obtains the output value s i , the output value s for all the words in the sentence i After normalization, the weight value α of each word is obtained i , the weight values α corresponding to all the participles in the sentence i and value vector value i Multiply and accumulate to get the sentence vector representation of the sentence. This preferred solution adopts a weighted summation method to obtain a better sentence vector representation according to the importance of each word.
[0097] It is easy to know that since the dimensions of each word segmentation vector are consistent, the dimension of the sentence segmentation vector obtained by summing up is the same as the dimension of the word segmentation vector, which can be easily accumulated.
[0098] S15, determining whether the sentence belongs to an event sentence of a preset type of financial event in a preset event classification model according to the accumulation result.
[0099] In the preset event classification model, event type detection is treated as a binary classification task. According to the event type to be detected, corresponding discriminant sub-models are provided, and each discriminant sub-model is composed of a simple feedforward neural network.
[0100] It should be noted that the preset event classification model is trained based on pre-annotated training text; the pre-annotated training text can be the text used to train the event element extraction model. During actual training, the event classification model and the event element extraction model can be trained simultaneously based on the same training text and share a loss function to avoid error transmission, so that the event classification model and the event element extraction model are more closely related, and the classification and extraction effects are better.
[0101] When applied, the accumulated results of the sentence vector of the sentence and the word vector of the word in the sentence belonging to the event element are input into the preset event classification model, and the accumulated results are analyzed by each discriminant sub-model respectively. Each discriminant sub-model outputs a feature vector with a dimension of 2, and then each feature vector is normalized by a softmax (normalized) classifier to obtain a 0 / 1 output. If the output is 1, it means that the corresponding sentence belongs to the event sentence of the event type corresponding to the corresponding discriminant sub-model.
[0102] S16: If the sentence belongs to an event sentence of a preset type of financial event, output a structured event corresponding to the sentence.
[0103] According to step S13 and step S15, the participles belonging to the event elements in the sentence have been marked, and it has been determined whether the sentence belongs to an event sentence of a preset type of financial event. Based on this information, the specific event content can be output.
[0104] In this embodiment, the specific event content is output in the form of a structured event, and the structured event may be composed of an event type and an event element; preferably, the structured event also includes an event sentence; preferably, it also includes a text ID or a text name. Table 3 is an output structured event.
[0105]
[0106] Table 3
[0107] It is understandable that in the output structured events, the categories of event roles are predefined according to different event types. For example, the defined "company listing" event includes six event roles: "company name", "listing date", "exchange", "sector", "stock code" and "opening price". If the event elements that meet these event roles are marked in the event sentence, these event elements will be output and displayed in the corresponding event role column. The specific structure of each type of event can be defined based on the corresponding domain knowledge and domain experience.
[0108] In this embodiment, after the extracted text is segmented into sentences and words, the word vectors and position vectors of the word segments are accumulated to obtain the output vectors of the corresponding word segments; then, according to the predefined element labeling sequence, sequence labeling is performed on each sentence to obtain the event element labeling results of the corresponding sentence; and according to the event element labeling results, the output vectors of the word segments belonging to the event elements in the sentence are accumulated with the sentence vectors of the sentence, and it is determined according to the accumulated results whether the sentence belongs to an event sentence of a preset type of financial event, and if so, the structured event corresponding to the sentence is output.
[0109] The embodiment of the present invention determines whether the corresponding sentence belongs to an event sentence of a preset type of event based on the event elements contained in each sentence in the text, thereby determining the event type in the text. Compared with the prior art of determining the event type in the text only by trigger words, the embodiment of the present invention increases the elements of determination by analyzing the overall information of the sentence, which can reduce misjudgments and missed judgments, improve the accuracy of text event type detection, and thus improve the extraction effect of the event extraction task.
[0110] In order to better understand the present invention, in this embodiment, Figure 3 As shown, the event element extraction model and event classification model are also explained below.
[0111] The event element extraction model and the event classification model are components of the entire financial field event extraction model, which also includes an input layer, a BERT layer, and an output layer, where:
[0112] The input layer is used to execute step S11;
[0113] The BERT layer is used to perform step S12;
[0114] The event element extraction model includes a fully connected neural network layer and a CRF layer, which is used to perform step S13;
[0115] The event classification model includes an attention layer, a feedforward neural network layer and a softmax layer, wherein the attention layer is used to execute step S14, and the feedforward neural network layer and the softmax layer are used to execute step S15;
[0116] The output layer is used to execute step S16.
[0117] Both the event element extraction model and the event classification model are trained based on pre-annotated training texts. The specific training process is similar to the extraction process for the extracted texts mentioned above. The main difference is that during training, the annotation results of the event element extraction model on the event elements in the training text and the annotation results of the event classification model on the event sentences in the training text need to be compared with the pre-annotated event elements and event sentences in the training text, and the loss value is calculated. According to the loss function, the Adam algorithm is used to continuously update and optimize the model.
[0118] In this embodiment, the event element extraction model and the event classification model analyze the training text simultaneously and share the same loss function. The overall loss value is composed of the losses of the event element extraction model and the event classification model, and the hyperparameter λ is used to adjust the proportion of the losses generated by the two models in the overall loss.
[0119] The event element extraction model calculates the loss value of the CRF layer in the event element extraction model in units of sentences. It is assumed that there are N possible labeling results for the words in the sentence after passing through the CRF layer, and each result corresponds to a score P i , which contains a correct result, and its corresponding score is P RealPath By adding up the loss values of all sentences in the training text, we can get the event element extraction loss value of the entire training text. c , as shown below.
[0120]
[0121] The event classification model uses cross entropy to calculate the classification loss value loss for each event type e , as shown below.
[0122]
[0123] Among them, y represents the event type pre-annotated in the training text, Indicates the event type predicted by the model.
[0124] The overall loss function loss of the event element extraction model and the event classification model is shown in the following formula.
[0125]
[0126] Among them, n represents the number of sentences segmented from the training text, k represents the number of event types, and λ is a hyperparameter used to adjust the loss ratio of the event element extraction model and the event type detection model.
[0127] In this embodiment, if Figure 4 As shown, the pre-annotated training text can be obtained in the following way:
[0128] S21, generating index information of each original text in the original text set.
[0129] Specifically, original texts related to the events to be extracted are collected to form an original text set, and index information of these original texts is generated. The index information may be a text ID or the like.
[0130] S22, for each original text, according to each event role in the predefined financial event structure, classify and extract the entities in the original text that meet the corresponding type of event role to obtain a candidate entity set; the predefined financial event structure includes the event roles that constitute the corresponding financial event and the attributes of the event roles, and the attributes of the event roles include whether it is a core event role.
[0131] For example, the predefined financial event structure of the "company listing" event is shown in Table 4.
[0132]
[0133] Table 4
[0134] The original text may be preprocessed, and the preprocessing may include format conversion, data cleaning, etc. For example, financial data in formats such as XML, JSON, and PDF are first parsed and converted into text format, and then the converted text is filtered for garbled characters and special symbols; the garbled characters and special symbols include {*? ! ! / |\&^#@~`<>}, etc.
[0135] When extracting entities from the original text, various types of entities are extracted from the text data using open source named entity recognition tools such as jieba and hanlp, as well as regular expressions, dictionaries, and manually constructed rules. For example, based on the text shown in Table 1, the candidate entity set shown in Table 5 is extracted.
[0136]
[0137]
[0138] Table 5
[0139] S23, according to the predefined financial event structure, various entities in the candidate entity set are arranged and combined to form a first candidate event set.
[0140] As shown in Table 4, the predefined financial event structure includes the roles required for the corresponding type of events and the constraints of these event roles on entity attributes. According to this constraint, different types of entities in the candidate entity set are combined to form a first candidate event set, and each element in the first candidate event set represents a possible structured event. For example, according to the candidate entity set shown in Table 5, the first candidate event set shown in Table 6 can be obtained.
[0141]
[0142] Table 6
[0143] S24, based on the text features and position features of each candidate event in the first candidate event set in the corresponding original text, screen out the real events in the first candidate event set in a preset classifier.
[0144] In this embodiment, the text features and position features include the part of speech, word frequency, length, and position of each entity in the text. The text features and position features of each entity are extracted and concatenated into a feature vector, which is sent to a binary classifier composed of a fully connected layer neural network to determine whether each candidate event belongs to a certain type of financial event. If so, it is screened as a real event.
[0145] In an original text, usually only one main event is described, that is, only one real event is included. Of course, there are also cases where multiple events are described in a text. In this case, multiple real events can also be screened out according to different screening conditions. Take the first candidate event set shown in Table 6 as an example, which only contains one real event, as shown in Table 7.
[0146]
[0147] Table 7
[0148] In one embodiment, Figure 5 As shown, step S24 specifically includes:
[0149] S241, screening candidate events in the first candidate event set according to a preset filtering condition to obtain a second candidate event set;
[0150] S242: According to the text features and position features of each candidate event in the second candidate event set in the corresponding original text, in a preset classifier, filter out the real events in the second candidate event set.
[0151] In step S241, each candidate event in the first candidate event set is passed to the event filter, and the event filter further filters out the second candidate event set through custom rules, such as what types of entities a certain type of event must contain, the order in which entities appear, etc. For example, when filtering the "company listing" event, the following rules can be followed:
[0152] Rule 1: When multiple company names appear, only the one with the highest frequency is used;
[0153] Rule 2: The listing date should be either XX / XX / XXXX or XX / XX / XX;
[0154] Rule 3: Stock codes should be 6 digits long;
[0155] Rule 4: The opening price shall not contain words such as "ten thousand" or "billion";
[0156] Rule 5: The sector should be one of the following: "Main Board", "Small and Medium Enterprise Board", "Science and Technology Innovation Board" or "Growth Enterprise Board".
[0157] According to these screening rules, the second candidate event set can be screened out from the first candidate event set shown in Table 6, as shown in Table 6.1.
[0158]
[0159] Table 6.1
[0160] After the second candidate event set is obtained, the real events in the second candidate event set are screened out in step S242.
[0161] This embodiment first filters the candidate events in the first candidate event set through user-defined rules, and then filters out real events based on the second candidate event set. Compared with directly filtering out real events based on the first candidate event set, this can improve the efficiency of filtering real events and reduce the judgment error of real events.
[0162] S25, writing the real event and the index information of the original text corresponding to the real event into the financial event knowledge base.
[0163] Specifically, a table structure corresponding to each type of financial event is provided in the financial event knowledge base. The table structure includes an event role column and an index information column corresponding to the type of financial event. The index information may be a text ID. For example, the table structure corresponding to the "company listing" event is shown in Table 8.
[0164]
[0165] Table 8
[0166] The real events screened out in step S24 and the index information of the original text of the real events are gradually written into the table structure of the corresponding type of events, thereby forming a financial event knowledge base.
[0167] S26, according to the index information of the original text in the financial event knowledge base, each event role of the real event in the financial event knowledge base is respectively annotated to the corresponding entity in the corresponding original text to obtain the event element annotated text.
[0168] Specifically, for each text in the original text set, a search is performed in the financial knowledge base based on the index information of the text to confirm whether there is a structured event in the text. If so, it is filtered as a training text, and then based on the real events recorded in the financial event knowledge base, the event roles in the real events are annotated to the corresponding entities in the corresponding training text.
[0169] For example, after annotating the training text shown in Table 1, the event element annotated text shown in Table 9 is obtained.
[0170]
[0171] Table 9
[0172] S27, marking sentences in the event element annotation text that contain core event role annotations and whose number of event role annotations is greater than a preset number as event sentences, to obtain a pre-annotated training text.
[0173] In this embodiment, a sentence is a grammatical unit separated by a period or a semicolon, that is, a sentence in the usual sense. To determine whether a sentence is an event sentence, the following two conditions must be met:
[0174] Condition 1: the event sentence contains at least one core event role defined by the predefined financial event structure. For example, in the "company listing" event, the company name is the core event role.
[0175] Condition 2: The number of event roles contained in the event sentence must not be less than K. The value range of K is generally [3,5], and can be selected according to different event types.
[0176] When a sentence satisfies both the first and second conditions, it is marked as an event sentence.
[0177] In the event element annotated text shown in Table 9, "On January 5, China Mobile (600941) officially landed on the main board of the Shanghai Stock Exchange, with an opening price of 63 yuan, up 9.41% from the IPO issue price of 57.58 yuan." It not only contains the core event role of the company name, but also contains 6 event roles, which meets the above conditions. Therefore, it can be annotated as an event sentence to obtain a pre-annotated training text.
[0178] When implementing training, the pre-annotated training text is divided into a training set, a validation set, and a test set according to a certain ratio to train and optimize the event element extraction model and the event classification model. For example, the training set, the validation set, and the test set are obtained by dividing the training text into 80%, 10%, and 10% ratios, respectively.
[0179] The method for obtaining pre-annotated training text provided by the embodiment of the present invention is based on the idea of remote supervision, realizes automatic annotation of event elements and event sentences in the text, saves the cost of manual annotation, and can facilitate the acquisition of large-scale pre-annotated training text.
[0180] Based on the same inventive concept as the above-mentioned financial field event extraction method, the embodiment of the present invention also provides a financial field event extraction device, such as Figure 6 As shown, it includes a text preprocessing module 301, a word vector generation module 302, an event element extraction module 303, a sentence vector accumulation module 304, an event classification module 305 and an event output module 306, wherein:
[0181] The text preprocessing module 301 is used to perform sentence and word segmentation processing on the text to be extracted, and obtain a sentence set of the text to be extracted and a word segmentation set of each sentence;
[0182] A word vector generation module 302 is used to obtain a word vector and a position vector of each word in each sentence in the sentence set, and accumulate the word vector and the corresponding position vector to obtain an output vector of the corresponding word;
[0183] The event element extraction module 303 is used to perform sequence annotation on each sentence according to a predefined element annotation sequence, and annotate the participles in the sentence that belong to the event element; the event element is an entity corresponding to the corresponding type of event role in the financial event;
[0184] The sentence vector accumulation module 304 is used to obtain the sentence vector of the sentence, and accumulate the output vector of the word belonging to the event element in the sentence with the sentence vector of the sentence to obtain an accumulation result;
[0185] An event classification module 305 is used to determine whether the sentence belongs to an event sentence of a preset type of financial event in a preset event classification model according to the accumulation result; the preset event classification model is obtained by training based on pre-annotated training texts;
[0186] The event output module 306 is configured to output a structured event corresponding to the sentence when the sentence belongs to an event sentence of a preset type of financial event.
[0187] Since the principle of solving the problem by the financial field event extraction device is similar to that of the above-mentioned financial field event extraction method, the implementation of the financial field event extraction device can refer to the implementation of the above-mentioned method, and the repeated parts will not be repeated.
[0188] According to an embodiment of the present invention, a non-temporary computer-readable storage medium is also provided, on which a computer program is stored. When the program is executed by a processor, any of the above-mentioned financial field event extraction methods is implemented.
[0189] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer-usable program code.
[0190] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0191] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0192] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0193] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A method for extracting financial events, characterized in that: include: Segment the text to be extracted and perform word segmentation processing to obtain a sentence set of the text to be extracted and a word segmentation set of each sentence; For each sentence in the sentence set, obtain the word vector and position vector of each word in the sentence, and accumulate the word vector and the corresponding position vector to obtain the output vector of the corresponding word; According to the predefined element annotation sequence, sequence annotation is performed on each sentence to annotate the participles in the sentence that belong to the event element; the event element is an entity corresponding to the corresponding type of event role in the financial event; Obtaining a sentence vector of a clause, and accumulating an output vector of a word belonging to an event element in the clause with the sentence vector of the clause to obtain an accumulation result; According to the accumulated result, determining whether the sentence belongs to an event sentence of a preset type of financial event in a preset event classification model; the preset event classification model is obtained by training based on pre-annotated training text; If so, output the structured event corresponding to the clause; The acquiring of the sentence vector of the sentence, accumulating the output vector of the word belonging to the event element in the sentence with the sentence vector of the sentence to obtain an accumulation result, includes: According to the attention mechanism, the output vectors of all the words in the sentence are weighted summed to obtain the sentence vector of the sentence; Accumulate the output vector of the word belonging to the event element in the sentence with the sentence vector of the sentence to obtain an accumulation result; The preset event classification model includes a feedforward neural network and a normalized classifier; the step of determining, based on the accumulation result, in the preset event classification model whether the sentence belongs to an event sentence of a preset type of financial event includes: Analyzing the accumulated result in a feedforward neural network to obtain a feature vector with a dimension of 2; Normalizing the feature vector with a dimension of 2 in a normalized classifier to obtain a classification result of a corresponding sentence, and determining whether the sentence belongs to an event sentence of a preset type of financial event according to the classification result; The step of performing sequence labeling on each sentence according to the predefined element labeling sequence to label the participles in the sentence belonging to the event element includes: According to the predefined element annotation sequence, use the preset event element extraction model to perform sequence annotation on each sentence and annotate the participles in the sentence that belong to the event element; The preset event element extraction model includes a fully connected layer neural network and a conditional random field, and is trained based on the pre-labeled training text.
2. The financial field event extraction method according to claim 1, characterized in that: The pre-annotated training text is obtained in the following manner: Generate index information of each original text in the original text set; For each original text, entities that meet the corresponding type of event roles in the original text are classified and extracted according to each event role in a predefined financial event structure to obtain a candidate entity set; the predefined financial event structure includes event roles constituting the corresponding financial event and attributes of the event roles, and the attributes of the event roles include whether it is a core event role; According to the predefined financial event structure, various entities in the candidate entity set are arranged and combined to form a first candidate event set; According to the text features and position features of each candidate event in the first candidate event set in the corresponding original text, in a preset classifier, screen out the real events in the first candidate event set; Writing the real event and the index information of the original text corresponding to the real event into the financial event knowledge base; According to the index information of the original text in the financial event knowledge base, each event role of the real event in the financial event knowledge base is respectively annotated to the corresponding entity in the corresponding original text to obtain the event element annotated text; Sentences in the event element annotation text that contain core event role annotations and whose number of event role annotations is greater than a preset number are annotated as event sentences to obtain a pre-annotated training text.
3. The financial field event extraction method according to claim 2, characterized in that: The method of screening out real events in the first candidate event set in a preset classifier according to text features and position features of each candidate event in the first candidate event set in the corresponding original text includes: Filter the candidate events in the first candidate event set according to a preset filtering condition to obtain a second candidate event set; According to the text features and position features of each candidate event in the second candidate event set in the corresponding original text, the real events in the second candidate event set are screened in a preset classifier.
4. The financial field event extraction method according to claim 3, characterized in that: The method of screening out real events in the second candidate event set in a preset classifier according to text features and position features of each candidate event in the second candidate event set in the corresponding original text includes: For each candidate event in the second candidate event set, construct a feature vector of the corresponding candidate event according to the part of speech, word frequency, word length, and position of each entity in the candidate event in the corresponding original text; The feature vector of the candidate event is input into a preset classifier to determine whether the corresponding candidate event belongs to a preset type of financial event, and obtain the real event in the second candidate event set.
5. The financial field event extraction method according to claim 1, characterized in that: The sentence and word segmentation processing of the text to be extracted is performed to obtain a sentence set of the text to be extracted and a word segmentation set of each sentence, including: Set standard sentence length; Sentence the extracted text according to the punctuation marks with sentence meaning; If the length of the sentence after the clause is greater than the standard clause length, the clause is divided using the punctuation mark whose clause length is less than and closest to the standard clause length; Filling the sentences whose length after the sentence is less than the standard sentence length to the standard sentence length with a filling symbol, so as to obtain the sentence set of the text to be extracted; The word segmentation tool is used to segment each sentence in the sentence set to obtain a word segmentation set for each sentence.
6. The financial field event extraction method according to claim 5, characterized in that: The sentence and word segmentation processing of the text to be extracted is performed to obtain a sentence set of the text to be extracted and a word segmentation set of each sentence, and further includes: Set the standard number of sentences. When the number of sentences segmented from the text to be extracted reaches the standard number of sentences, the remaining text is truncated; when the number of sentences segmented from the text to be extracted is less than the standard number of sentences, fill symbols are used to supplement it to the standard number of sentences.
7. A financial field event extraction device, characterized in that: It includes text preprocessing module, word vector generation module, event element extraction module, sentence vector accumulation module, event classification module and event output module, among which: The text preprocessing module is used to perform sentence and word segmentation processing on the text to be extracted, and obtain a sentence set of the text to be extracted and a word segmentation set of each sentence; The word vector generation module is used to obtain the word vector and position vector of each word in each sentence in the sentence set, and accumulate the word vector and the corresponding position vector to obtain the output vector of the corresponding word; The event element extraction module is used to perform sequence labeling on each sentence according to a predefined element labeling sequence, and label the participles in the sentence that belong to the event element; the event element is an entity corresponding to the corresponding type of event role in the financial event; the performing sequence labeling on each sentence according to the predefined element labeling sequence and labeling the participles in the sentence that belong to the event element includes: performing sequence labeling on each sentence according to the predefined element labeling sequence and labeling the participles in the sentence that belong to the event element using a preset event element extraction model; the preset event element extraction model includes a fully connected layer neural network and a conditional random field, which is trained based on pre-labeled training text; The sentence vector accumulation module is used to obtain the sentence vector of the sentence, and accumulate the output vector of the word belonging to the event element in the sentence with the sentence vector of the sentence to obtain the accumulation result; the sentence vector of the sentence is obtained, and the output vector of the word belonging to the event element in the sentence is accumulated with the sentence vector of the sentence to obtain the accumulation result, including: according to the attention mechanism, the output vectors of all the words in the sentence are weighted summed to obtain the sentence vector of the sentence; the output vector of the word belonging to the event element in the sentence is accumulated with the sentence vector of the sentence to obtain the accumulation result; The event classification module is used to determine whether the sentence belongs to an event sentence of a preset type of financial event in a preset event classification model according to the accumulated result; the preset event classification model is obtained by training based on pre-annotated training text; the preset event classification model includes a feedforward neural network and a normalized classifier; the determining whether the sentence belongs to an event sentence of a preset type of financial event in the preset event classification model according to the accumulated result includes: analyzing the accumulated result in a feedforward neural network to obtain a feature vector with a dimension of 2; normalizing the feature vector with a dimension of 2 in a normalized classifier to obtain a classification result of the corresponding sentence, and determining whether the sentence belongs to an event sentence of a preset type of financial event according to the classification result; The event output module is used to output the structured event corresponding to the sentence when the sentence belongs to an event sentence of a preset type of financial event.
Citation Information
Patent Citations
Computer-executed event extraction method and device by using neural network
CN110032641A
Event extraction method and related device
CN114385793A