A method for generating analytical review text based on financial data
By building a financial corpus and building a neural network text generation model, the problems of automatic financial text generation in flexibility, maintenance cost and generation quality are solved, and efficient and informative financial comment text generation is achieved.
Patent Information
- Application Number
- CN202111151555.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-29
- Publication Date
- 2025-02-21
- Estimated Expiration
- 2041-09-29
AI Technical Summary
The existing technology has problems such as insufficient flexibility in the automatic generation of financial texts, high maintenance costs and poor quality of generated texts, especially in the application of financial fields, which lack effective reasoning capabilities and slow training speed.
A method of analytical comment text generation based on financial data is proposed. By constructing a financial corpus, constructing sample vocabulary list, extracting keywords, creating text-table mapping vectors, and building a neural network text generation model to generate financial comment texts.
It significantly improves the efficiency of analytical comment text generation in the financial field, and the generated text information is rich, the sentences are smooth, and readable, which can effectively help investors understand the main content of the financial report.
Smart Images

Figure CN113779940B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of financial data processing, and in particular to a method for generating analysis and comment text based on financial data. Background Art
[0002] Listed companies are obliged to publish their financial statements on time and accurately, and report their financial status to regulators and investors. However, financial statements are highly professional, making them difficult for non-professionals to read. To solve this pain point, professional organizations will summarize the main information of listed companies' financial statements, write relevant financial reviews and publish them to investors. This method is inefficient and expensive.
[0003] The automatic generation of financial text has great potential for development, but there is no mature automatic generation system for financial text. The core technology of such automatic generation systems for financial text is data-to-text, which mainly includes three methods: the first is the template-based method, where professionals design a set of processes and rules for commenting on financial tables, and then fill in the corresponding data into the template according to the rules to generate text; the second is the method based on machine learning and templates, where a machine learning model is trained to generate templates, and then data is filled into the templates; the third is the method based on neural network models, where an end-to-end neural language model is trained to directly generate text.
[0004] The most commonly used method is the template-based method, which has the advantages of stable performance and speed, but is not flexible enough, and with the increase of template complexity, the cost of maintenance and migration is very high; the most advanced method is the method based on the neural network model, which has the advantages of being very flexible and generating texts with good readability and diversity. However, there are still relatively few studies and applications of neural network text generation methods in the financial field. The public text models do not take into account the particularity of the financial field, have slow training speeds and generally lack reasoning capabilities, and the generated texts are of poor quality and costly.
[0005] In response to the problems existing in the prior art, the present application provides a method for generating analytical commentary text based on financial data, which can automatically generate financial commentary based on financial statements, and the generated text is rich in information, fluent in sentences, and highly readable. Summary of the invention
[0006] The purpose of the present invention is to provide a method for generating analysis and commentary text based on financial data, which can automatically generate financial commentary according to financial statements, and the generated text has rich information, smooth sentences and strong readability.
[0007] The present invention provides a method for generating analysis and comment text based on financial data, comprising the following steps:
[0008] Obtain enterprise financial tables and financial commentary texts corresponding to the enterprise financial tables to build a financial corpus;
[0009] A sample vocabulary is constructed based on the inference paradigm terms used in the financial commentary text in the financial corpus to indicate how to generate new data based on the original data, the position terms used to indicate the cell position of the text in the table, and the numerical unified terms used to distinguish between numerical values and text texts;
[0010] Extract data information of corporate financial tables in the financial corpus, and extract keywords from financial commentary texts in the financial corpus according to the sample vocabulary;
[0011] Create a text-table mapping vector based on the relationship between the data information of the enterprise financial table and the corresponding financial commentary text keywords;
[0012] Create reference texts for financial commentary texts based on sample word lists;
[0013] Based on the reference text and text-table mapping vector of financial commentary text, a neural network text generation model is built;
[0014] Input financial data into the neural network text generation model to generate corresponding financial commentary text.
[0015] Furthermore, the step of obtaining the enterprise financial table and the financial commentary text corresponding to the enterprise financial table is:
[0016] Use web crawler technology to download corporate financial tables and financial commentary text corresponding to corporate financial tables;
[0017] Use the value 0 to fill in the missing values in the company's financial tables;
[0018] Link corporate financial tables with financial commentary texts.
[0019] Furthermore, the method further includes: preprocessing the enterprise financial tables in the financial corpus and the financial commentary texts corresponding to the enterprise financial tables, wherein the preprocessing steps are:
[0020] Unify the format of corporate financial tables and financial commentary texts in the financial corpus;
[0021] Split the enterprise financial table data into financial data and financial attributes, with each set of financial data and financial attributes occupying one cell;
[0022] Clear invalid sentences from financial commentary text.
[0023] Furthermore, the step of creating a text-table mapping vector is:
[0024] Traverse the tabular data in the enterprise financial tables and standardize the tabular data using the inference paradigm;
[0025] Set the error threshold for table data;
[0026] If the normalized table data is within the error threshold, a reference text and a text-table mapping vector of the financial commentary text are constructed, the financial commentary text corresponding to the inference paradigm table data is recorded in the reference text, and the index of the inference paradigm table data in the sample vocabulary is recorded in the text-table mapping vector;
[0027] If the normalized table data is not within the error threshold, the text content of the financial commentary text is recorded in the reference text of the financial commentary text, and 0 is filled in the text-table mapping vector.
[0028] Furthermore, the financial tables include a balance sheet, a cash flow table and a profit table.
[0029] Furthermore, the method further includes: training the neural network text generation model, the steps of:
[0030] Set the hyperparameters of the neural network text generation model to fine-tune the neural network text generation model;
[0031] Use training set samples to train the neural network text generation model;
[0032] Use the validation set samples to validate the neural network text generation model. When the validation results show that the error rate of the neural network text generation model remains stable, stop training the neural network text generation model and save the current neural network text generation model.
[0033] Compared with the prior art, the present invention has the following significant advantages:
[0034] The present invention proposes a method for generating analysis and commentary text based on financial data. According to the mathematical characteristics of the enterprise financial table and the word segmentation results of the financial commentary text, the reference text and text-table mapping vector of the financial commentary text are constructed, a neural network text generation model is built, the neural network text generation model is trained and the neural network text generation model is used for text generation, which significantly improves the generation efficiency of analysis and commentary text in the financial field, helps investors understand the main content of financial reports, expands the scope of the traditional copying mechanism, defines a variety of reasoning paradigms in the neural network text generation model, and has better information reasoning ability. The present invention proposes a method for generating analysis and commentary text based on financial data. It can automatically generate financial comments according to financial statements, and the generated text is rich in information, fluent in sentences, and highly readable. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1A schematic diagram of a process flow provided by an embodiment of the present invention;
[0036] Figure 2 A schematic diagram of encoding and decoding provided by an embodiment of the present invention;
[0037] Figure 3 A schematic diagram of the implementation process and principle of the reasoning mechanism provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0038] The following is a clear and complete description of the technical solutions of the embodiments of the present invention in conjunction with the drawings in the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0039] The financial tables and financial comments are in a one-to-one or one-to-many correspondence mode.
[0040] Reference Figure 1-3 The present invention provides a method for generating analysis and comment text based on financial data, comprising the following steps:
[0041] Use web crawler technology to download corporate financial tables and financial commentary text corresponding to corporate financial tables;
[0042] Use the value 0 to fill in the missing values in the company's financial tables;
[0043] Link corporate financial tables with financial commentary texts to build a financial corpus;
[0044] A sample vocabulary is constructed based on the inference paradigm terms used in the financial commentary text in the financial corpus to indicate how to generate new data based on the original data, the position terms used to indicate the cell position of the text in the table, and the numerical unified terms used to distinguish between numerical values and text texts;
[0045] Extract data information of corporate financial tables in the financial corpus, and extract keywords from financial commentary texts in the financial corpus according to the sample vocabulary;
[0046] Create a text-table mapping vector based on the relationship between the data information of the enterprise financial table and the corresponding financial commentary text keywords;
[0047] Create reference texts for financial commentary texts based on sample word lists;
[0048] Based on the reference text and text-table mapping vector of financial commentary text, a neural network text generation model is built;
[0049] Input financial data into the neural network text generation model to generate corresponding financial commentary text.
[0050] Among them, financial statements include balance sheet, cash flow statement and profit statement.
[0051] Example 1
[0052] The steps for generating financial commentary text using the neural network text generation model are as follows:
[0053] Set the hyperparameters of the neural network text generation model to fine-tune the neural network text generation model;
[0054] Use training set samples to train the neural network text generation model;
[0055] Use the validation set samples to validate the neural network text generation model. When the validation results show that the error rate of the neural network text generation model remains stable, stop training the neural network text generation model and save the current neural network text generation model.
[0056] Input the test set samples into the currently saved neural network text generation model to generate financial commentary text.
[0057] Example 2
[0058] The data preprocessing steps also include: defining inference paradigm terms, position terms, numerical unified terms, and dividing the data into training sets, validation sets, and test sets.
[0059] The steps to create a text-table mapping vector are:
[0060] Traverse the tabular data in the enterprise financial tables and standardize the tabular data using the inference paradigm;
[0061] Set the error threshold for table data;
[0062] If the normalized table data is within the error threshold, a reference text and a text-table mapping vector of the financial commentary text are constructed, the financial commentary text corresponding to the inference paradigm table data is recorded in the reference text, and the index of the inference paradigm table data in the sample vocabulary is recorded in the text-table mapping vector;
[0063] If the normalized table data is not within the error threshold, the text content of the financial commentary text is recorded in the reference text of the financial commentary text, and 0 is filled in the text-table mapping vector.
[0064] The reasoning paradigm terms, position terms, and unified numerical terms are terms with special meanings, which are stored in the sample vocabulary and the overall vocabulary; the reasoning paradigm terms are function names, which define the method of mapping the data to be inferred to new data; the position terms indicate the position of the cell in the table; the unified numerical terms are used to indicate all numerical values; the reference text is a word sequence, which consists of two types of words, one is general words, and the other is the reasoning paradigm terms. When the reasoning paradigm supports financial commentary, the corresponding ones are reasoning paradigm terms, otherwise they are general words; the text-table mapping vector is an index vector, The text-table mapping vector represents the correspondence between the reference text and the financial table. When a special entry appears at a certain position in the reference text, the corresponding element of the text-table mapping vector is the index of a certain financial data in the sample vocabulary, otherwise the text-table mapping vector is 0; the lengths of the reference text and the text-table mapping vector are both related to the length of the financial commentary; the overall vocabulary is the union of the sample vocabulary, but all numerical values are removed; the training set samples and the validation set samples both include two parts of data, one is the data table and the other is the reference text; the test set samples only have data from the data table part.
[0065] The corporate financial tables in the financial corpus and the financial commentary texts corresponding to the corporate financial tables are preprocessed. The preprocessing steps are as follows:
[0066] Unify the format of corporate financial tables and financial commentary texts in the financial corpus;
[0067] Split the enterprise financial table data into financial data and financial attributes, with each set of financial data and financial attributes occupying one cell;
[0068] Invalid sentences are removed from the financial commentary text, and a sample vocabulary is constructed based on the removal results.
[0069] The steps of establishing a sample vocabulary include:
[0070] Get the financial review text after removing invalid statements;
[0071] Determine the inference paradigm term, the position term and the numerical unified term according to the financial review text after removing invalid sentences, wherein the inference paradigm term is used to indicate how to generate new data according to the original data, the position term is used to indicate the cell position of the text in the table, and the numerical unified term is used to distinguish the numerical value from the text numerical unified term;
[0072] According to the determined inference paradigm terms, position terms and numerical unified terms, the financial review text is processed to construct a sample vocabulary.
[0073] Example 3
[0074] The neural network text generation model includes an embedding module, an encoding module, a decoding module, a generation module, a reasoning module, and a semantic consistency checking module;
[0075] The embedding module uses the sample vocabulary to establish a vocabulary index embedding matrix, and the embedding module has different embedding representation strategies for numerical values and texts;
[0076] The encoding module is composed of two layers of encoders, the bottom layer encoder is used to maintain the dimensional shape of the input data, and the high layer encoder is used to reduce the data dimension;
[0077] The decoding module is a recurrent neural network structure, which is used to calculate the attention distribution and context vector according to the time step;
[0078] The generation module includes a fully connected network and a softmax logistic regression model network;
[0079] The inference module locates the inference word according to the attention distribution of the decoding module, selects the inference paradigm according to the softmax result of the corresponding generation module, and adjusts the inference word according to the definition of the inference paradigm;
[0080] The semantic consistency checking module is used to define semantic consistency rules by using a regular expression method.
[0081] The neural network text generation model is trained in the following steps:
[0082] Set the hyperparameters of the neural network text generation model to fine-tune the neural network text generation model;
[0083] Use training set samples to train the neural network text generation model;
[0084] Use the validation set samples to validate the neural network text generation model. When the validation results show that the error rate of the neural network text generation model remains stable, stop training the neural network text generation model and save the current neural network text generation model.
[0085] Example 3
[0086] Building a financial corpus includes the following steps:
[0087] Obtain financial statements of listed companies from public data platforms such as Guotai An;
[0088] Use web crawler technology to download research institutions' comments on listed companies' financial reports from financial portals such as NetEase Finance, Sohu Finance, and Eastmoney.com;
[0089] Clean, organize and annotate the acquired data.
[0090] Furthermore, the steps of cleaning, organizing and labeling data specifically include:
[0091] Zero-fill missing values in financial statements;
[0092] According to the title and content of the financial commentary, the financial disclosure period corresponding to the commentary is determined and marked, thereby connecting the financial statements with the financial commentary, which is called a sample; the samples are classified according to different reporting intervals and industry standards; the financial reports of the current period of the financial commentary are traced back, and a maximum of 9 financial reports are taken to connect with the financial commentary of that period to enrich the information in the sample data table.
[0093] Example 4
[0094] The corpus samples are preprocessed and divided into training set, validation set and test set. The preprocessing steps are as follows:
[0095] Step 1: Organize the sample into a standard format and establish a sample vocabulary; represent the data of the financial table part in the sample as a sequence of <financial data|financial attribute>, where each <financial data|financial attribute> is equivalent to a cell in the original table, and cells are separated by spaces; perform word segmentation on the data of the comment text part in the sample, and record the word segmentation results in the sample vocabulary;
[0096] Step 2: Calculate the mathematical fluctuation information of the financial attributes in the sample data table;
[0097] Step 3: Define the inference paradigm terms; such as definition <dateyear>Get the year in the date, <datemonth>Get the month in the date, <dateday>Get the "day" in the date and <copy>Perform pure copying;
[0098] Step 4: Define location terms; define terms<numeric_x> Represents the xth cell;
[0099] Step 5: Define numerical unified terms; define terms <numeric>Indicates a numeric value.
[0100] Step 6: Based on the original financial commentary text of the sample, further consider the financial table information and reasoning paradigm, and construct the reference text and text-table mapping vector. The specific steps include:
[0101] The first step is to take the words of the financial review text in order;
[0102] The second step is to set an error threshold; traverse the table data of the sample and expand its information using the reasoning paradigm; if a certain table data is found to be within the error threshold after passing the reasoning paradigm, then record the reasoning paradigm term in the reference text and record the index of the table data in the sample vocabulary in the text-table mapping vector; otherwise, record the word of the comment text in the reference text and fill 0 in the text-table mapping vector;
[0103] Step 3: Repeat steps 1 and 2 until the traversal is complete.
[0104] Step 7: Combine all sample word lists, delete the values and dates, and obtain the overall word list.
[0105] Step 8: Divide the training, validation, and test sets into three sets in a ratio of 8:1:1, and delete the reference text and text-table mapping vectors in the test set samples.
[0106] Example 5
[0107] Build a neural network text generation model based on financial data. The embedding module uses the pre-trained embedding vocabulary as the initialization parameter. First, find the embedding vectors of the financial attribute field and the financial data value respectively, and then use a fully connected layer to fuse the embedding information of the two. Since there is no financial data (numerical value) entry in the overall vocabulary, it is replaced by the position entry and the mathematical fluctuation information obtained by preprocessing.
[0108] The encoding module is a two-layer structure. When generating text, it first calculates the attention distribution of the financial attribute, and then calculates the probability distribution of the candidate cells within this attribute. The bottom encoder is a Transformer encoder. The present invention uses the bottom encoder to embed the input sequence Encoding for the first time:
[0109] E B = Transformer_encoder(E |V| ) (1)
[0110] After one underlying encoding, each encoding result incorporates the contextual information of all embedded vectors in the input sequence.
[0111] The basic structure of the high-level encoder is also the Transformer encoder. The present invention firstly obtains the bottom-level encoding result E B Take the encoding result for the same attribute and input it into the fully connected layer to get the preliminary encoding of each attribute. Then use a layer of Transformer encoder to encode each attribute again to get the final high-level encoding:
[0112]
[0113] E T = Transformer_encoder(E P ) (3)
[0114] in
[0115] The low-level and high-level codes are saved at the same time, and the effects of both are comprehensively considered in the decoding stage to determine the best solution for generating words.
[0116] The decoding module is a two-layer LSTM network. The basic decoding idea is to calculate two different attention distributions based on the decoder hidden state of the current time step and the bottom and top codes of the encoding layer, and then combine the two to obtain the final context vector.
[0117] LSTM neural network can save the long-term dependency of text sequence. The difference between it and ordinary RNN network is that the network will perform three operations of memory gate, input gate and output gate at each LSTM time step, so as to achieve the ability of "forgetting" unimportant information and memorizing long-term dependency. Multi-layer LSTM uses the hidden state of the bottom LSTM as the input of the upper LSTM on the basis of single-layer LSTM, but the calculation logic remains unchanged. In the present invention, the calculation method of the multi-layer attention mechanism is to calculate the attention distribution of the decoder hidden state and the bottom coding and high-level coding respectively, and then combine the two to obtain the final attention vector.
[0118] The generation module is a combination of a simple fully connected layer and a softmax logistic regression model network layer. The principle is to upgrade the context vector of the decoding module to a certain dimension (this dimension is generally the sum of the sample vocabulary and the overall vocabulary capacity), and then perform softmax processing on the high-dimensional vector to obtain a probability distribution.
[0119] The reasoning module is Figure 3 As shown, the principle is to first calculate the probability of generating a word directly from the vocabulary based on the hidden state of the decoder without using the inference module technology.
[0120] prob = softmax(W·h t ) (4)
[0121] The dimension of prob is equal to the length of the total vocabulary, and each element represents the probability of the corresponding word being generated. We also define a vector prob sp Represents the probability of the inference pattern entry being generated. Since the inference pattern is saved in the overall vocabulary, prob sp The value of can be obtained from the prob vector.
[0122] Then, the current context, the hidden state at the previous moment, and the output word are used to calculate whether reasoning is needed at the current moment. The formula is:
[0123] p gen =W·[c t-1 ,y t-1 ,x t ]+b (5)
[0124] p gen is a scalar that represents the probability of generating a word directly from the vocabulary at the current moment, 1-p gen is the probability of selecting data from the input data table for inference. We directly regard the attention score of each cell at the current moment as its probability of being located. Considering prob, prob sp and p loc , determines which word to generate at the current moment or what kind of inference to make on which data in the financial table, as shown in the following formula.
[0125] p t =p gen ·prob+(1-p gen )·p copy ·prob sp (6)
[0126] The semantic consistency check module is an a posteriori semantic check module implemented using regular expression technology. This module establishes a grammatical rule. Once a positive word such as "growth" or "increase" is identified as being followed by a negative number, "growth" is replaced by "decrease" and the sign of the subsequent numerical value is removed to ensure the correctness of the grammar.
[0127] Example 6
[0128] training the model and making predictions;
[0129] The neural network model is equipped with an embedding module, 2 encoding modules, 2 decoding modules, and uses a multi-head attention mechanism with 2 heads. During training, each batch of data has 8 examples, and the network parameters are updated every 6 batches of data. The optimizer is the Adam optimizer, and the maximum gradient norm is set to 5, and the dropout retention parameter is 0.5. The initial value of the learning rate is 0.01, which decays by half every 5,000 iterations. The generalization performance is verified by using the validation set data for 30,000 training iterations per iteration. Finally, the test set data is used for prediction.
[0130] The above disclosures are only several specific embodiments of the present invention. However, the embodiments of the present invention are not limited thereto. Any changes that can be conceived by those skilled in the art should fall within the protection scope of the present invention.< / numeric> < / copy> < / dateday> < / datemonth> < / dateyear>
Claims
1. A method for generating analysis and comment text based on financial data, characterized in that: The following steps are involved: Obtain enterprise financial tables and financial commentary texts corresponding to the enterprise financial tables to build a financial corpus; Determine the inference paradigm term, the position term and the numerical unified term according to the financial review text after removing invalid sentences, wherein the inference paradigm term is used to indicate how to generate new data according to the original data, the position term is used to indicate the cell position of the text in the table, and the numerical unified term is used to distinguish the numerical value from the text numerical unified term; According to the determined inference paradigm terms, position terms and numerical unified terms, the financial review text is processed to construct a sample word list; Extract data information of corporate financial tables in the financial corpus, and extract keywords from financial commentary texts in the financial corpus according to the sample vocabulary; Create a text-table mapping vector based on the relationship between the data information of the enterprise financial table and the corresponding financial commentary text keywords; Create reference texts for financial commentary texts based on sample word lists; Based on the reference text and text-table mapping vector of financial commentary text, a neural network text generation model is built; Input financial data into the neural network text generation model to generate corresponding financial commentary text; The step of creating a text-table mapping vector is as follows: Traverse the tabular data in the enterprise financial tables and standardize the tabular data using the inference paradigm; Set the error threshold for table data; If the normalized table data is within the error threshold, a reference text and a text-table mapping vector of the financial commentary text are constructed, the financial commentary text corresponding to the inference paradigm table data is recorded in the reference text, and the index of the inference paradigm table data in the sample vocabulary is recorded in the text-table mapping vector; If the normalized table data is not within the error threshold, the text content of the financial commentary text is recorded in the reference text of the financial commentary text, and 0 is filled in the text-table mapping vector.
2. A method for generating analysis and comment text based on financial data as claimed in claim 1, characterized in that: The steps of obtaining the enterprise financial table and the financial commentary text corresponding to the enterprise financial table are: Use web crawler technology to download corporate financial tables and financial commentary text corresponding to corporate financial tables; Use the value 0 to fill in the missing values in the company's financial tables; Link corporate financial tables with financial commentary texts.
3. The method for generating analysis and comment text based on financial data according to claim 1, characterized in that: Also includes: Preprocessing is performed on the enterprise financial tables in the financial corpus and the financial commentary texts corresponding to the enterprise financial tables. The preprocessing steps are as follows: Unify the format of corporate financial tables and financial commentary texts in the financial corpus; Split the enterprise financial table data into financial data and financial attributes, with each set of financial data and financial attributes occupying one cell; Clear invalid sentences from financial commentary text.
4. The method for generating analysis and comment text based on financial data according to claim 1, characterized in that: The financial statements include a balance sheet, a cash flow sheet and an income sheet.
5. The method for generating analysis and comment text based on financial data according to claim 1, characterized in that: The step further includes: training the neural network text generation model, the steps being: Set the hyperparameters of the neural network text generation model to fine-tune the neural network text generation model; Use training set samples to train the neural network text generation model; Use the validation set samples to validate the neural network text generation model. When the validation results show that the error rate of the neural network text generation model remains stable, stop training the neural network text generation model and save the current neural network text generation model.
Citation Information
Patent Citations
Comment generation method and device, server and storage medium
CN110287278A
Method and apparatus of machine learning using network with software agents at network nodes and then ranking network nodes
CN110462612A