A financial statement automatic analysis system based on large language models

Through an automatic financial statement analysis system based on large language model, DSL generation, filter and decoder are used to solve the problems of inefficient and insufficient accuracy of traditional financial statement analysis, and efficient and accurate generation of financial analysis results is achieved.

CN120124593BActive Publication Date: 2025-07-25ZHEJIANG UNIV

Patent Information

Application Number
CN202510595300.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-09
Publication Date
2025-07-25
Estimated Expiration
2045-05-09

AI Technical Summary

Technical Problem

Traditional financial statement analysis relies on manual expertise, is inefficient and error-prone, and existing automation systems are unable to effectively handle natural language financial needs, resulting in long analysis cycles and insufficient accuracy.

Method used

The financial statement automatic analysis system based on the large language model generates large models, filters and decoders through financial analysis DSL to realize automatic conversion of natural language to financial analysis results, including pre-training and fine-tuning models, combining DSL script format and system database for primary key matching and default value completion, and generating structured financial analysis results.

Benefits of technology

It significantly improves the efficiency and accuracy of financial statement analysis, ensures the accuracy of numerical calculations and the targetedness of report interpretation, and provides efficient and intelligent financial analysis support.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120124593B_ABST
    Figure CN120124593B_ABST
Patent Text Reader

Abstract

The present invention discloses a financial statement automatic analysis system based on a large language model, comprising: a financial analysis DSL generation large model, a financial analysis DSL filter, and a financial analysis DSL decoder; when the system receives at least one financial statement analysis request in the form of natural language, the financial analysis DSL generation large model automatically generates a primary financial analysis DSL script, inputs the primary script into the financial analysis DSL filter to obtain a complete financial analysis DSL script, and then inputs the complete script into the financial analysis DSL decoder for decoding to obtain a prompt text containing financial analysis results and knowledge text, and the inference model returns the financial analysis and explanatory notes in plain text form to the user interface. The financial statement automatic analysis system based on the large language model of the present invention realizes the automatic generation of financial analysis reports for natural language requests, significantly improving the efficiency and accuracy of financial statement analysis.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of financial data processing and relates to an automatic financial statement analysis system based on a large language model. Background Art

[0002] Financial statement analysis refers to the process of systematically and structurally examining and interpreting the information in a company's financial statements to evaluate the company's financial position, operating results, and cash flows. Its main purpose is to identify key financial indicators such as the company's financial health, profitability, liquidity, solvency, and operating efficiency by analyzing financial data, thereby providing valuable information support for internal management decision-making, investment evaluation, and external stakeholders. Financial statement analysis is not only a quantitative process but also requires a combination of qualitative evaluations, usually including five main steps: data collection, data collation, data analysis, result interpretation, and report writing.

[0003] Traditional financial statement analysis led by financial experts often faces many drawbacks. First, the interpretation of financial reports usually requires a deep understanding of financial knowledge and professional background, and it is often difficult for non-professionals to complete the analysis and interpretation conveniently and efficiently, which makes the acquisition and application of information complex and inefficient; second, traditional methods require a large amount of manual time to collect, collate, and analyze data, resulting in an extended analysis cycle and decision-making lag; third, human-led financial analysis is prone to calculation errors. Especially when dealing with a large amount of complex data, misunderstandings or incorrect calculations of financial data may occur due to negligence, having a negative impact on decision-making; finally, existing automated financial report analysis systems cannot effectively convert natural language information directly into financial analysis reports. Many financial needs and analysis requests exist in the form of unstructured natural language, and there is an urgent need for a more efficient and accurate way to perform automated financial analysis to overcome the limitations brought by expert-led financial statement analysis.

[0004] Based on this, the present invention is based on the existing large language model and combines originality to propose an automatic financial statement analysis system that can greatly improve the efficiency and accuracy of financial statement analysis. Summary of the Invention

[0005] In view of the deficiencies of the prior art, the present invention proposes an automatic financial statement analysis system based on a large language model, aiming to significantly improve the efficiency and accuracy of financial analysis. By pre-training and fine-tuning the existing general large language model, introducing a financial analysis DSL script to interpret the financial statement analysis requirements in natural language, and combining the functions of a DSL filter and a decoder, a financial analysis result and an explanatory note in pure text form are finally output. This innovative mechanism greatly improves the efficiency and accuracy of converting natural language into a financial analysis report, providing an intelligent and efficient analysis tool for the financial industry.

[0006] To solve the above technical problems, the present invention provides the following technical solutions:

[0007] A financial statement automatic analysis system based on a large language model, comprising:

[0008] A financial analysis DSL generation large model, configured to receive a financial statement analysis request in natural language form, perform automatic primary key identification and value extraction according to a preset DSL script format, and generate a primary financial analysis DSL script; the preset DSL script format is a hierarchical structure, composed of keys and values, and the keys contain primary keys;

[0009] A financial analysis DSL filter, configured to match the primary keys in the primary financial analysis DSL script with the system database through fuzzy matching of financial named entities, further identify the pattern of the financial analysis DSL script, and actively complete the default values, to obtain a complete financial analysis DSL script;

[0010] A financial analysis DSL decoder, configured to perform structured identification and storage on the content of the complete financial analysis DSL script, calculate financial analysis indicators and corresponding knowledge texts based on the identified command group hierarchical structure, and finally generate the required financial analysis results and knowledge texts for output presentation.

[0011] In the above technical solution, further, the financial analysis DSL generation large model is obtained by pre-training and fine-tuning with financial texts and high-quality financial analysis Q&A pair data; the pre-training uses the general large model qwen2.5-7B as the base model, based on the Hugging Face Transformers framework, and the training data consists of annual reports of listed companies and analyst reports; the fine-tuning is based on the Hugging Face Transformers framework on the basis of the pre-trained model, and the training data is high-quality "natural language - DSL script key-value pair" Q&A pair data.

[0012] Further, the DSL script format consists of keys and values. Among them, the key is composed of a percentage symbol "%" and an English word indicating the key category, including: %task (task), %cmd (command group), %describe (explanation), %stkcd (object), %date (time period), %industry (industry), %metric (indicator), %basedon (dependent indicator), %layer (indicator calculation level), %formula (calculation formula), %value (calculation result), %cmdend (end of command group), %taskend (end of task), which are used to clearly mark the nature of the value that appears after the key in the DSL script; the value is a number, word, short sentence or functional form, aiming to represent the actual meaning of each key in the financial analysis DSL script to describe the object, specific content and requirements of financial analysis; among the keys of the financial analysis DSL script, %stckd, %date, %industry, and %metric are the main keys, which are used to match the specific financial data to be processed in the system database.

[0013] Further, the hierarchical structure includes:

[0014] 1) Script layer: A complete financial analysis DSL script contains all necessary information related to the current financial analysis request. The key %task represents the start of the entire financial analysis DSL script. When and only when all the content of the command group ends, the key %taskend appears, indicating the end of the entire financial analysis DSL script;

[0015] 2) Command group layer: The financial analysis DSL script consists of one or more command groups. The key %cmd represents the start of the command group until the next key %cmdend appears, indicating the end of the current command group; a single command group corresponds to the complete information required to analyze a single financial indicator; the key %describe appears after the key %cmd and is used to store the calculation process and knowledge text of this financial indicator;

[0016] 3) Command layer: The command group consists of one or more commands. The key %stkcd corresponds to the stock code of the analysis object, the key %date corresponds to the value as the analysis time period, the key %industry corresponds to the value as the industry where the analysis object is located, the key %metric corresponds to the value as the specific financial indicator, the key %basedon corresponds to the value as the other financial indicators on which the calculation of this financial indicator depends, the key %layer corresponds to the value as the financial indicator calculation level, the key %formula corresponds to the value as the calculation formula composed of other financial indicators in %basedon, which is used to calculate the current financial indicator, and %value corresponds to the value as the indicator value or indicator calculation result; the complete content of a command will be included in the same line, and the end of a command is represented by a line break.

[0017] Further, the financial analysis DSL primary script is obtained by the large model generated by the financial analysis DSL automatically identifying the primary key and extracting the value from the input financial analysis requirements in natural language form. In the financial analysis DSL primary script, the corresponding values of the primary keys %stckd, %date, %industry, and %metric are in natural language;

[0018] The financial analysis DSL filter sequentially inputs the primary key values in the command layer of the financial analysis DSL primary script into the FNE-BERT financial named entity fuzzy matching model, matches the corresponding value of the primary key with the value under the primary key category in the system database, performs DSL pattern recognition and automatic default value completion on the script where the primary key matches the system database, and outputs the complete financial analysis DSL script.

[0019] Further, the FNE-BERT financial named entity fuzzy matching model is obtained through pre-training and fine-tuning with financial domain named entity data and the paired data of financial analysis requirements and specific indicators; the pre-training uses the general large model Google BERT-base as the base model, is based on the Hugging Face Transformers framework, and the training data is the "natural language - named entity" paired corpus in the financial domain; the fine-tuning is based on the pre-trained model and the Hugging Face Transformers framework, and the training data is the "natural language - financial indicator" paired corpus.

[0020] Further, the DSL pattern recognition is to regularly judge the financial analysis pattern of each command group according to the missing situation of the primary key value output by the FNE-BERT financial named entity fuzzy matching model; the automatic default value completion of the DSL is to determine the necessary DSL key values based on the recognized financial analysis pattern of the command group, traverse the missing situation of the necessary key values of each command, where: for the missing primary key in the command, it is supplemented according to the financial analysis rule library in the system database; for the missing non-primary key value in the command, there are:

[0021] The corresponding value of the key %basedon is automatically matched and obtained according to the corresponding values of the keys %stckd, %date, %industry, and the corresponding value of %metric and the financial analysis knowledge base in the system database;

[0022] The corresponding value of %formula is automatically matched and obtained according to the corresponding value of the key %metric and the financial analysis knowledge base, and at the same time, the financial indicators in the key %basedon are supplemented as the primary keys in the new command into the current command group;

[0023] The corresponding value of the key %value is automatically matched with the basic financial database according to the corresponding values of the primary keys %stckd, %date, and %metric;

[0024] Traverse all command groups in the DSL script in a loop. The initial value of the key %layer is 1. In each new traversal, if a new financial indicator is added, the value of the key %layer is incremented by 1 until all commands %value are not null or %basedon is not null, obtaining the complete DSL script for financial analysis.

[0025] Furthermore, the system database includes a basic financial database, a financial analysis rule library, and a financial analysis knowledge library:

[0026] The basic financial database contains the structured historical financial data of listed companies on the stock exchange in the past 30 years, and all accounting subject data in the structured balance sheet (ACCT_BS), income statement (ACCT_IS), and cash flow statement (ACCT_CF) are stored.

[0027] The financial analysis rule library refers to the default processing rules for the primary key value pairs in the DSL script. Specifically, when traversing the default state of the primary key value pairs in the primary DSL script, corresponding missing value supplements are made according to the missing conditions of various primary keys in the command, including the target default rule: when %stkcd is missing, supplement the top 3 listed companies with the largest asset scale in the same industry; industry default rule: when %industry is missing, match and supplement according to the "Statistical Classification and Codes of Listed Company Industries" issued by the China Securities Regulatory Commission; time period default rule: when %date is missing, default to supplement the financial report years in the past 3 years; and indicator default rule: when %metric is missing, default to supplement the financial indicators related to profitability.

[0028] The financial analysis knowledge library contains the basic indicator dependencies required for calculating various financial indicators and their corresponding calculation formulas.

[0029] Furthermore, in the complete DSL script for financial analysis, the value of the key %stckd is a string composed of numbers or letters; the value of the key %date is in the format of YYYY-MM-DD; the value of the key %metric is the category of financial indicators specified in the financial analysis knowledge library, and its format is a string; the key %industry is the industry category in the system database, and its format is a string composed of numbers or letters; the value of the key %basedon is a list containing one or more groups of other financial indicator primary key values; the key %layer is an integer; the value of the key %formula is an expression containing the label values in %basedon, and the key %value is in the format of a floating point number.

[0030] Further, the financial analysis DSL decoder performs structured recognition and storage on the complete financial analysis DSL script content, loops through to calculate the numerical values of financial indicators in each command group, and stores the main calculation process and knowledge text in the value corresponding to the key %describe. The structured recognition and storage include the following:

[0031] 1) Review of the complete financial analysis DSL script format and storage of command groups: For the input complete financial analysis DSL script, identify the key %task as the start of the analysis task and the key %taskend as the end of the analysis task. Extract the content between the two as the financial analysis DSL script content and save it. If the above keys are not detected, return an error message. For the saved financial analysis DSL script content, identify the key %cmd as the start of the command group and the key %cmdend as the end of the command group. Identify the financial analysis DSL script content as one or more command groups and store them separately;

[0032] 2) Sorting of financial indicator calculation commands: For each command group, identify the key %stkcd as the start of the command and the line break as the end of the command; identify the key %layer as the calculation level of the financial indicator. Sort all the commands in the command group in reverse order according to the value of the key %layer; save the financial indicators calculated by each command group as different objects, and store the key and its corresponding value in each command as variables under the object;

[0033] 3) Calculation of financial indicators and storage of knowledge text: For each command group, loop through all the commands in the command group in descending order of %layer; if the value of the key %value in the current command is known, continue looping; if the value of the key %value in the current command is unknown, read the calculation formula and other financial indicators on which it depends recorded in %formula and %basedon in the command, calculate the corresponding value of %value in the command, save it in the object, and store the relevant calculation formula and knowledge text in %describe to form a prompt text; after the calculation of this financial indicator is completed, continue looping through other commands until the values of the key %value in all commands in this command group are not empty; after the calculation of the current command group is completed, continue to execute the calculation process for the next command group until all command groups in the script are executed.

[0034] Further, after the calculation of the financial indicators in all command groups in the complete financial analysis DSL script is completed, the financial analysis result and knowledge text are the text output obtained by the financial analysis DSL decoder integrating the financial indicator calculation results stored in %value of all command groups and the calculation process and knowledge text stored in %describe;

[0035] The financial analysis results and knowledge text can be re - input into the existing reasoning model as needed for further induction and collation, and the financial analysis results and explanatory notes are output.

[0036] The beneficial effects of the present invention are:

[0037] The present invention constructs an automatic financial statement analysis system based on a large - language model. By innovatively designing a DSL script in the field of financial analysis and combining financial analysis knowledge, the system introduces a filter and a decoder, giving full play to the potential of natural language processing technology in financial analysis. This system can accurately convert natural language into specific financial analysis tasks, thereby effectively processing financial data and generating analysis reports. This mechanism not only ensures the accuracy of numerical calculations in financial statements but also improves the pertinence of report interpretation, making the analysis results more practical. Through this integration, the system can provide users with efficient and accurate financial analysis support. Brief Description of the Drawings

[0038] Figure 1 is a schematic diagram of the reasoning process of the automatic financial statement analysis system based on the large - language model of the present invention.

[0039] Figure 2 is a schematic diagram of the training process of the large model for generating financial analysis DSL in an embodiment of the present invention.

[0040] Figure 3 is a schematic diagram of the training process of the FNE - BERT financial named - entity fuzzy matching model in an embodiment of the present invention.

[0041] Figure 4 is a schematic diagram of the working process of the financial analysis DSL filter in an embodiment of the present invention.

[0042] Figure 5 is a schematic diagram of the working process of the financial analysis DSL decoder in an embodiment of the present invention. Detailed Embodiments

[0043] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. It should be noted that the current embodiments are only partial embodiments of the present invention, not all embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts fall within the scope of protection of the present invention.

[0044] According to an embodiment of the present invention, the present invention discloses an automatic financial statement analysis system based on a large - language model, as Figure 1 shown, including:

[0045] A financial analysis DSL generation large model is used to receive financial statement analysis requests in natural language form, and perform automatic primary key identification and value extraction according to a preset DSL script format to generate a primary financial analysis DSL script; the preset DSL script format is a hierarchical structure, consisting of keys and values, and the keys contain primary keys.

[0046] A financial analysis DSL filter is used to match the primary keys in the primary financial analysis DSL script with the system database through fuzzy matching of financial named entities, and further identify the pattern of the financial analysis DSL script and actively complete the default values to obtain a complete financial analysis DSL script.

[0047] A financial analysis DSL decoder is used to perform structured identification and storage on the content of the complete financial analysis DSL script, calculate financial analysis indicators and corresponding knowledge texts based on the identified command group hierarchical structure, and finally generate the required financial analysis results and knowledge texts for output and presentation.

[0048] This section will specifically introduce the financial analysis DSL script mentioned in the above technical solution.

[0049] Financial analysis DSL (Domain-Specific Language) is a concise and structured scripting language specifically designed for financial analysis tasks. Its purpose is to express operations such as index calculation, data screening, and analysis text generation in complex financial analysis requests through an easy-to-read, easy-to-write, and efficient syntax, reducing the technical threshold of financial analysis and improving the automation level and analysis accuracy.

[0050] The present invention designs a financial analysis DSL script in an original format, which contains information such as specific financial analysis objects, analysis periods, financial index categories, numerical calculation methods, etc. corresponding to financial analysis requests in natural language form. The financial analysis DSL script designed by the present invention consists of keys and values. Among them, the keys are composed of a percentage symbol % and an English word indicating the key category, including: %task task, %cmd command group, %describe description, %stkcd object, %date time period, %industry industry, %metric index, %basedon dependent index, %layer index calculation level, %formula calculation formula, %value calculation result, %cmdend command group end, %taskend task end, which are used to clearly mark the nature of the values that appear after the keys in the DSL script; the values are numbers, words, short sentences, or functional expressions, aiming to represent the actual meanings of each key in the financial analysis DSL script to describe the objects, specific contents, and requirements of financial analysis.

[0051] The financial analysis DSL script designed by the present invention includes two state stages: the primary DSL script and the complete DSL script. The primary DSL script includes the primary keys required for financial analysis, including four types of primary keys: %stkcd, %industry, %date, and %metric. The values are composed of text information directly extracted from the financial analysis request in natural language form; the complete DSL script includes all types of keys and is in a hierarchical structure in terms of format, specifically including:

[0052] 1) Script layer: It contains all the necessary information related to the current financial analysis request. The key %task represents the start of the entire financial analysis DSL script. When and only when all the content of the command group ends, the key %taskend appears, indicating the end of the entire financial analysis DSL script;

[0053] 2) Command group layer: The financial analysis DSL script consists of one or more command groups. The key %cmd represents the start of a command group until the next key %cmdend appears, indicating the end of the current command group; a single command group corresponds to the complete information required to analyze a single financial metric; the key %describe appears after the key %cmd and is used to store the calculation process and knowledge text of this financial metric;

[0054] 3) Command layer: The command group consists of one or more commands. The key %stkcd corresponds to the stock code of the analysis object, the key %date corresponds to the value of the analysis period, the key %industry corresponds to the value of the industry where the analysis object is located, the key %metric corresponds to the value of the specific financial metric, the key %basedon corresponds to the value of other financial metrics on which the calculation of this financial metric depends, the key %layer corresponds to the value of the financial metric calculation level, the key %formula corresponds to the calculation formula composed of other financial metrics in %basedon and is used to calculate the current financial metric, and %value corresponds to the value of the metric or the result of the metric calculation; the complete content of a command is included in the same line, and a line break represents the end of a command.

[0055] This part will specifically introduce the financial analysis DSL generation large model, which is used to receive financial statement analysis requests in natural language form and perform automatic primary key recognition and value extraction according to the pre-set DSL script format to generate the primary financial analysis DSL script, as Figure 2 shown. The training process of this model includes:

[0056] 1) Collecting domain-specific corpora in the financial field, including annual reports of listed companies and analyst reports in pure text form;

[0057] 2) Collect the Q&A pair data of "natural language - DSL script key - value pairs". Among them, the natural language is the text of the financial analysis request naturally expressed by human users, and the corresponding DSL script key - value pair is the primary key and corresponding value of the financial analysis DSL script extracted by financial practitioners from the financial analysis request in natural language form (as shown in Table 1);

[0058] Table 1 Example of the content of the Q&A pair of "natural language - DSL script key - value pairs"

[0059]

[0060] 3) For the obtained financial - domain proprietary corpus and the Q&A pair data of "natural language - DSL script key - value pairs", use them for the pre - training and fine - tuning of the general large - language model to obtain a financial analysis DSL generation large - model that can receive financial analysis requests in natural language form and output the corresponding financial analysis primary DSL script. Specifically, for pre - training, use the open - source general large - language model qwen2.5 - 7B and the training framework based on Hugging Face Transformers, with the training data being the financial - domain proprietary corpus to obtain a financial - domain large - language model. On this basis, perform model instruction fine - tuning, with the training data being the Q&A pair data of "natural language - DSL script key - value pairs" and the training framework being Hugging Face Transformers.

[0061] This part will specifically introduce the financial analysis DSL script filter. This part is used to match the primary key in the financial analysis DSL primary script with the system database through fuzzy matching of financial named entities, further identify the pattern of the financial analysis DSL script, and actively complete the default values to obtain the complete financial analysis DSL script. The specific steps are as follows:

[0062] 1) Collect the paired corpus of "natural language - named entity" and "natural language - financial indicator" in the financial field. In the "natural language - named entity" pairing, the natural language is the common value of the three primary keys of %stkcd, %industry, and %date in the user's financial analysis request, and the named entity refers to the specific thing name with a clear meaning and unique identification in the financial analysis context, including categories such as institution names, dates, industries, etc. For example, in the natural language, "Vanke" and "Vanke Group" correspond to "%stkcd = 000002SZ" in the financial analysis context. In the "natural language - financial indicator" pairing, the natural language is the common value of the %metri primary key in the user's financial analysis request, and the financial indicator is the specific financial indicator related to this %metri in the financial analysis knowledge base of the system database. For example, in the natural language, "solvency" corresponds to multiple indicators such as "current_ratio", "quick_ratio", "debt_to_asset", and "interest_coverage_ratio" in the financial analysis knowledge base.

[0063] 2) Train the FNE - BERT financial named entity fuzzy matching model. As Figure 3 shown, for the obtained paired corpus of "natural language - named entity" and "natural language - financial indicator" in the financial field, use it for the pre - training and fine - tuning of the general large - language model to obtain a large model that can receive the financial analysis key values in natural language form and automatically match the data key values in the basic financial database of the system database (as shown in Table 2). In the FNE - BERT financial named entity fuzzy matching model of the present invention, it is used to match the four primary keys of %stkcd, %industry, %date, and %metric. Specifically, for pre - training, use the open - source general large - language model Google BERT - base and the training framework based on Hugging Face Transformers. The training data is the paired corpus of "natural language - named entity" in the financial field to obtain the large - language model of named entities in the financial field. On this basis, perform model instruction fine - tuning, the training data is the paired corpus of "natural language - financial indicator", and the training framework is Hugging Face Transformers.

[0064] Table 2 FNE - BERT financial named entity fuzzy matching example

[0065]

[0066] 3) As Figure 4As shown, after fuzzy matching of the primary keys in the DSL script, for the primary DSL scripts that cannot be successfully matched, the matching error report is returned to the Deepseek R1 inference model. The inference model sorts out the content and outputs the reasons for the parsing failure to the user. For the DSL scripts that can be successfully matched, the DSL pattern recognition and default value automatic filling process are executed. The DSL pattern recognition is output according to the FNE-BERT financial named entity fuzzy matching model. Among them, for the missing situation of one or more primary key values, the financial analysis patterns of each command group are judged by regular expressions. For example, among the four primary keys of %stkcd, %industry, %date, and %metric, if %stkcd is missing and %industry is known, it is judged as the industry analysis mode; if %stkcd is known and %metric is missing, it is judged as the company profile analysis mode, and so on. The automatic filling of DSL default values is based on the recognized financial analysis mode, determines the necessary DSL key values, and traverses the missing situation of the necessary key values of each command. Among them: for the missing primary keys in the command, they are supplemented according to the financial analysis rule library in the system database; for the missing non-primary key values in the command, there are:

[0067] The corresponding value of the key %basedon is automatically matched and obtained according to the corresponding values of the keys %stckd, %date, %industry, and the corresponding value of %metric and the financial analysis knowledge base in the system database;

[0068] The corresponding value of %formula is automatically matched and obtained according to the corresponding value of the key %metric and the financial analysis knowledge base. The form is a function expression composed of the labels ("tag") of each financial indicator in %basedon. At the same time, the financial indicators in %basedon are supplemented as the primary keys in the new command to the current command group;

[0069] The corresponding value of the key %value is automatically matched and obtained according to the corresponding values of the primary keys %stckd, %date, and %metric and the basic financial database;

[0070] Loop through all command groups in the DSL script. The initial value of the key %layer is 1. In each new traversal, if a new financial indicator is added, the value of the key %layer increases by 1 until the value of %value is not null or the value of %basedon is not null in all command lines. Finally, the complete DSL script for financial analysis is obtained, as shown in Table 3.

[0071] Table 3 Generation process of the financial analysis DSL script

[0072]

[0073]

[0074]

[0075] This section will specifically introduce the financial analysis DSL decoder.

[0076] As Figure 5 , the financial analysis DSL decoder performs structured recognition and storage on the complete script content of the financial analysis DSL, loops through and calculates the numerical values of financial indicators in each command group, and stores the main calculation process and knowledge text in the value corresponding to the key %describe. The structured recognition and storage include the following:

[0077] 1) Financial analysis DSL complete script format review and command group storage: For the input complete script of the financial analysis DSL, identify the key %task as the start of the analysis task and the key %taskend as the end of the analysis task. Extract the content between the two as the financial analysis DSL script content and save it. If the above keys are not detected, return an error message; for the saved financial analysis DSL script content, identify the key %cmd as the start of the command group and the key %cmdend as the end of the command group. Identify the financial analysis DSL script content as one or more command groups and store them separately;

[0078] 2) Financial indicator calculation command sorting: For each command group, identify the key %stkcd as the start of the command and the line break as the end of the command; identify the key %layer as the calculation level of the financial indicator. Sort all the commands in the command group in reverse order according to the value of the key %layer; save the financial indicators calculated by each command group as different objects, and store the key and its corresponding value in each command as a variable under this object;

[0079] 3) Financial indicator calculation and knowledge text storage: For each command group, traverse all the commands in the command group in descending order of %layer; if the value of the key %value in the current command is known, continue traversing; if the value of the key %value in the current command is unknown, read the calculation formula and other financial indicators on which it depends recorded in %formula and %basedon in this command, calculate the value corresponding to %value in this command, save it in this object, and store the relevant calculation formula and knowledge text in %describe to form a prompt text (as shown in Table 4); after the calculation of this financial indicator is completed, continue traversing other commands until the values of the key %value of all commands in this command group are not empty; after the calculation of the current command group is completed, continue to execute the calculation process for the next command group until all command groups in the script are executed.

[0080] Table 4 Example of the %describe prompt text in the DSL script

[0081]

[0082]

[0083] The financial analysis results and knowledge text are the text outputs obtained by integrating the financial indicator calculation results stored in %value of all command groups and the calculation process stored in %describe with the knowledge text after the financial indicator calculations of all command groups in the complete script of the financial analysis DSL are completed by the financial analysis DSL decoder;

[0084] The financial analysis results and knowledge text can be further input into the Deepseek R1 inference model as needed for further induction and organization, and the financial analysis results and explanatory notes are output (as shown in Table 5).

[0085] Table 5 Example of Financial Analysis Results and Explanatory Notes

[0086]

[0087] To detect the effectiveness of the present invention, 1000 financial statement analysis requests were randomly input, and the large model system obtained by the method of the present invention and common general large models were tested. The test criteria and results are shown in Table 6 and Table 7.

[0088] Table 6 Evaluation Criteria for Accounting Entry Preparation Tasks

[0089]

[0090] Table 7 Evaluation Results

[0091]

Claims

1. An automatic financial statement analysis system based on large language models, characterized in that, Including: A financial analysis DSL generation large model, which is used to receive a financial statement analysis request in the form of natural language, automatically identify the primary key and extract values according to the pre-set DSL script format, and generate a primary financial analysis DSL script; the pre-set DSL script format is a hierarchical structure, consisting of keys and values, and the keys contain primary keys; among them, the key is composed of a percentage symbol % and an English word indicating the key category, including: %task (task), %cmd (command group), %describe (description), %stkcd (object), %date (time period), %industry (industry), %metric (indicator), %basedon (dependency indicator), %layer (indicator calculation level), %formula (calculation formula), %value (calculation result), %cmdend (end of command group), %taskend (end of task), which are used to clearly mark the nature of the value that appears after the key in the DSL script; the value is a number, word, short sentence or functional expression, aiming to represent the actual meaning of each key in the financial analysis DSL script to describe the object, specific content and requirements of the financial analysis; the hierarchical structure includes: 1) Script layer: A complete financial analysis DSL script contains all necessary information related to the current financial analysis request. The key %task represents the start of the entire financial analysis DSL script. When and only when all the content of the command group ends, the key %taskend appears, indicating the end of the entire financial analysis DSL script; 2) Command group layer: The financial analysis DSL script consists of one or more command groups. The key %cmd represents the start of the command group until the next key %cmdend appears, indicating the end of the current command group; a single command group corresponds to the complete information required to analyze a single financial indicator; the key %describe appears after the key %cmd and is used to store the calculation process and knowledge text of the financial indicator; 3) Command layer: The command group consists of one or more commands. The key %stkcd corresponds to the stock code of the analysis object, the key %date corresponds to the value as the analysis time period, the key %industry corresponds to the value as the industry where the analysis object is located, the key %metric corresponds to the value as the specific financial indicator, the key %basedon corresponds to the value as the other financial indicators on which the calculation of this financial indicator depends, the key %layer corresponds to the value as the financial indicator calculation level, the key %formula corresponds to the value as the calculation formula composed of other financial indicators in %basedon, which is used to calculate the current financial indicator, and %value corresponds to the value as the indicator value or the indicator calculation result; the complete content of a command will be included in the same line, and the end of a command is represented by a line break; A financial analysis DSL filter, which is used to match the primary key in the primary financial analysis DSL script with the pre-built system database through fuzzy matching of financial named entities, further identify the pattern of the financial analysis DSL script and actively complete the default value, so as to obtain a complete financial analysis DSL script; A financial analysis DSL decoder structures and stores the complete script content of the financial analysis DSL, calculates financial analysis indicators and corresponding knowledge texts based on the identified command group hierarchical structure, and finally generates the required financial analysis results and knowledge texts for output presentation.

2. The financial statement automatic analysis system based on a large language model according to claim 1, wherein The financial analysis DSL generation large model is obtained through pre-training and fine-tuning on financial texts and high-quality financial analysis Q&A pair data; for pre-training, the general large model qwen2.5-7B is used as the base model, which is based on the Hugging Face Transformers framework, and the training data consists of annual reports of listed companies and analyst reports; for fine-tuning, it is based on the Hugging Face Transformers framework on the basis of the pre-trained model, and the training data is high-quality "natural language - DSL script key-value pair" Q&A pair data.

3. The financial statement automatic analysis system based on the large language model according to claim 1, characterized in that, Among the keys of the financial analysis DSL script, %stckd, %date, %industry, and %metric are the main keys used to match specific financial data to be processed in the system database.

4. The financial statement automatic analysis system based on a large language model according to claim 1, characterized in that, The financial analysis DSL primary script is obtained by the financial analysis DSL generation large model automatically identifying the main keys and extracting values from the input natural language-form financial analysis requirements. In the financial analysis DSL primary script, the corresponding values of the main keys %stckd, %date, %industry, and %metric are natural languages. The financial analysis DSL filter sequentially inputs the main key values of the command layer in the financial analysis DSL primary script into the FNE-BERT financial named entity fuzzy matching model, matches the corresponding values of the main keys with the values under the main key categories in the system database, performs DSL pattern recognition and automatic default value completion on the scripts with the main keys matching the system database, and outputs the complete financial analysis DSL script.

5. The financial statement automatic analysis system based on a large language model according to claim 4, wherein, The FNE-BERT financial named entity fuzzy matching model is obtained through pre-training and fine-tuning on financial domain named entity data and financial analysis requirement and specific indicator pairing data; for pre-training, the general large model Google BERT-base is used as the base model, which is based on the Hugging Face Transformers framework, and the training data is financial domain "natural language - named entity" paired corpus; for fine-tuning, it is based on the Hugging Face Transformers framework on the basis of the pre-trained model, and the training data is "natural language - financial indicator" paired corpus.

6. The financial statement automatic analysis system based on a large language model according to claim 4, wherein The DSL pattern recognition determines the financial analysis patterns of each command group by regular expression based on the missing situation of the main key values output by the FNE-BERT financial named entity fuzzy matching model; the automatic DSL default value completion determines the necessary DSL key values based on the identified financial analysis patterns of the command groups, traverses the missing situations of the necessary key values of each command, where: for the missing main keys in the command, they are supplemented according to the financial analysis rule library in the system database; for the missing non-main key values in the command, there are: The value corresponding to the key %basedon is automatically matched with the financial analysis knowledge base in the system database based on the values corresponding to the keys %stckd, %date, %industry, and the value corresponding to the %metric; The value corresponding to the key %formula is automatically matched with the financial analysis knowledge base based on the value corresponding to the key %metric. At the same time, the financial indicators in the key %basedon are supplemented as the primary keys in the new command to the current command group; The value corresponding to the key %value is automatically matched with the basic financial database based on the values corresponding to the primary keys %stckd, %date, and %metric; Traverse all command groups in the DSL script. The initial value of the key %layer is 1. In each new traversal, when a new financial indicator is added, the value of the key %layer increases by 1 until all commands have non-null values for %value or non-null values for %basedon, obtaining the complete financial analysis DSL script.

7. The financial statement automatic analysis system based on a large language model according to claim 4, characterized in that The system database includes a basic financial database, a financial analysis rule base, and a financial analysis knowledge base: The basic financial database contains the structured historical financial data of listed companies on the stock exchange in the past 30 years, and structurally stores all accounting subject data in the balance sheet ACCT_BS, income statement ACCT_IS, and cash flow statement ACCT_CF; The financial analysis rule base refers to the default processing rules for the primary key value pairs in the DSL script. Specifically, when traversing the default state of the primary key value pairs in the primary DSL script, corresponding missing value supplements are made according to the missing conditions of various primary keys in the command, including the underlying default rule: when %stkcd is missing, supplement the top 3 listed companies with the largest asset scale in the same industry, the industry default rule: when %industry is missing, match and supplement according to the "Classification and Codes of Listed Company Industries" issued by the China Securities Regulatory Commission, the time period default rule: when %date is missing, default to supplement the financial report years in the past 3 years, and the indicator missing rule: when %metric is missing, default to supplement the financial indicators related to profitability; The financial analysis knowledge base contains the basic indicator dependencies required for calculating various financial indicators and their corresponding calculation formulas.

8. The financial statement automatic analysis system based on a large language model according to claim 4, wherein The financial analysis DSL decoder performs structured recognition and storage on the content of the complete financial analysis DSL script, traverses and calculates the numerical values of the financial indicators in each command group, and stores the main calculation process and knowledge text in the value corresponding to the key %describe. The structured recognition and storage include the following: 1) Format review and command group storage of the complete financial analysis DSL script: For the input complete financial analysis DSL script, identify the key %task as the start of the analysis task and the key %taskend as the end of the analysis task. Extract the content between the two as the content of the financial analysis DSL script and save it. If the above keys are not detected, an error message is returned; for the saved content of the financial analysis DSL script, identify the key %cmd as the start of the command group and the key %cmdend as the end of the command group. Identify the content of the financial analysis DSL script as one or more command groups and store them separately; 2) Sorting of financial indicator calculation commands: For each command group, identify the key %stkcd as the start of the command and the line break as the end of the command; identify the key %layer as the calculation level of the financial indicator, and sort all the commands in the command group in reverse order according to the value of the key %layer; save the financial indicators calculated by each command group as different objects, and store the keys and their corresponding values in each command as variables under the object; 3) Financial indicator calculation and knowledge text storage: For each command group, traverse all the commands in the command group in descending order of %layer; if the value of the key %value in the current command is known, continue traversing; if the value of the key %value in the current command is unknown, read the calculation formula and other financial indicators on which it depends recorded in %formula and %basedon in the command, calculate the corresponding value of %value in the command, save it in the object, and store the relevant calculation formula and knowledge text in %describe to form a prompt text; after the calculation of this financial indicator is completed, continue traversing other commands until the values of the key %value in all commands in the command group are not empty; after the calculation of the current command group is completed, continue to execute the calculation process for the next command group until all command groups in the script are executed.

9. The financial statement automatic analysis system based on a large language model according to claim 8, characterized in that The financial analysis results and knowledge text are the text outputs obtained by the financial analysis DSL decoder integrating the financial indicator calculation results stored in %value of all command groups and the calculation process and knowledge text stored in %describe after the calculation of all command groups in the complete script of the financial analysis DSL; The financial analysis results and knowledge text can be further input into the existing inference model for further induction and collation as needed, and the financial analysis results and explanatory notes are output.

Citation Information

Patent Citations

  • Automatic financial report question and answer method and device based on large model

    CN117235233A

  • Method and device for auditing based on large language model

    CN119938943A

Cited By

  • Financial statement automatic analysis system based on large language model

    CN122047453A