Financial flow table optimization-oriented financial data extraction method
By constructing CNN and BiLSTM-CRF models based on the PyTorch framework and combining them with OCR technology, the problem of low accuracy in financial table recognition was solved, and automated financial data extraction and structured processing were achieved, improving data processing efficiency and accuracy.
Patent Information
- Application Number
- CN202410891189.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-04
- Publication Date
- 2024-11-01
AI Technical Summary
Existing OCR technology has low recognition accuracy when processing financial tables with diverse formats and complex structures, making it difficult to meet the data processing needs of enterprises.
We construct a convolutional neural network (CNN) model and a bidirectional long short-term memory (BiLSTM-CRF) model based on the PyTorch framework, and combine them with an OCR model to identify financial entities in financial table structures and text. We extract financial data through image preprocessing, structural feature extraction, row and column recognition, OCR recognition, named entity recognition, and regular expressions.
It enables automated structure recognition and information extraction from financial forms, improving processing efficiency and accuracy, reducing manual processing time and errors, and providing structured data for financial analysis and decision support.
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a financial data extraction method for optimizing financial process tables. Background Art
[0002] Currently, with the advancement of digital transformation, enterprises have a growing demand for automated processing of financial documents. However, existing OCR technology performs well in standard document recognition, but still faces challenges when processing financial forms with diverse formats and complex structures. These forms usually contain key financial data, such as balance sheets, income statements, etc., and their accurate recognition is crucial for further analysis and decision-making of the data.
[0003] Existing OCR technologies are mainly designed for general scenarios, lacking in-depth understanding and optimization of the specific structure of financial tables. As a result, in actual applications, the recognition accuracy of key information such as the row and column structure, title and data cells of the table is not high, and the processing efficiency cannot meet the needs of enterprises. Summary of the invention
[0004] In view of the deficiencies in the prior art, the present invention aims to provide a financial data extraction method optimized for financial process tables.
[0005] In order to achieve the above object, the present invention adopts the following technical solution:
[0006] A financial data extraction method for optimizing financial process tables comprises the following steps:
[0007] S101, data set construction: collect and organize financial table images to construct a diverse financial table data set;
[0008] S102, constructing a convolutional neural network (CNN) model based on the PyTorch framework for identifying structural features in financial tables, constructing an OCR model based on the PyTorch framework for text recognition, and constructing a BiLSTM-CRF model based on a bidirectional long short-term memory network (BiLSTM) combined with a conditional random field (CRF) for identifying and classifying financial-related entities in text; training the CNN model, the OCR model, and the BiLSTM-CRF model on the PyTorch platform using the financial table dataset constructed in step S101; the CNN model learns the structural features in the financial table image through training;
[0009] S103, financial table structure identification:
[0010] S1031, image preprocessing: firstly, preprocess the image of the financial table to be processed;
[0011] S1032, structural feature extraction: using the CNN model trained in step S102 to extract structural features in the financial table image;
[0012] S1033, row and column recognition: using the CNN model to analyze the line and text alignment patterns in the financial table image, detect the row and column boundaries in the financial table image, and recognize the title row, table header, and data cells in the financial table image;
[0013] S104, key information extraction:
[0014] S1041, OCR recognition: for the pre-processed cell image, use the OCR model trained in step S102 to perform text recognition on the cell image and convert it into editable text;
[0015] S1042, named entity recognition: using the BiLSTM-CRF model trained in step S102 to identify and classify the financial-related entities in the text recognized by OCR in step S1041;
[0016] S1043, key information extraction:
[0017] Keyword matching: Create a keyword dictionary specifically for financial terms, which includes common financial indicators and terms, and then identify and extract the keywords and their related financial information by performing string matching on the OCR-recognized text;
[0018] Regular expression: Use the set regular expression to extract financial data in a specified format from the text recognized by OCR;
[0019] Contextual relevance analysis: After extracting keywords and financial data in a specified format, contextual relevance analysis is performed on the entities extracted by the BiLSTM-CRF model to ensure the accuracy and completeness of the information.
[0020] Furthermore, in step S101, after preprocessing the collected financial table images, the images are converted into a uniform resolution and format, and then the key information of each financial table image is annotated by financial experts, and an annotation guide is created to ensure the consistency and accuracy of the annotation; the annotated financial table images are divided into a training set, a validation set, and a test set to ensure that the data is evenly distributed and covers a variety of table formats and layouts.
[0021] Furthermore, the preprocessing in step S101 and step S1031 includes graying, binarization, noise removal and contrast enhancement.
[0022] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program implements the above method when executed by a processor.
[0023] The present invention also provides a computer device, comprising a processor and a memory, wherein the memory is used to store a computer program; and when the processor is used to execute the computer program, the above method is implemented.
[0024] The beneficial effects of the present invention are as follows: the method of the present invention realizes automated financial table structure recognition and information extraction, can effectively reduce manual processing time, improve processing efficiency, and improve the accuracy of financial table content extraction, reduce the need for manual input and correction, and reduce operational errors. The structured data extracted by the method of the present invention can be directly used for financial analysis and decision support. DETAILED DESCRIPTION
[0025] The present invention will be further described below. It should be noted that this embodiment is based on the technical solution and provides a detailed implementation method and a specific operation process, but the protection scope of the present invention is not limited to this embodiment.
[0026] This embodiment provides a financial data extraction method for optimizing financial process tables, including the following steps:
[0027] S101. Dataset construction: Collect and organize financial table images, such as balance sheets, income statements, etc., to construct a diverse financial table dataset.
[0028] Specifically, after preprocessing the collected financial table images, the images are converted to a uniform resolution and format, and then the key information of each financial table image is annotated by financial experts, including the position of the table in the image, title, financial indicators, etc., and an annotation guide is created to ensure the consistency and accuracy of the annotation; the annotated financial table images are divided into training sets, validation sets, and test sets to ensure that the data is evenly distributed and covers a variety of table formats and layouts. The preprocessing includes graying, binarization, noise removal, contrast enhancement, etc. to enhance the structural features of the financial table images.
[0029] S102. Construct a convolutional neural network (CNN) model based on the PyTorch framework for identifying structural features in financial tables, construct an OCR model based on the PyTorch framework for text recognition, and construct a BiLSTM-CRF model based on a bidirectional long short-term memory network (BiLSTM) combined with a conditional random field (CRF) for identifying and classifying financial-related entities in text; train the CNN model, OCR model, and BiLSTM-CRF model on the PyTorch platform using the financial table dataset constructed in step S101; the CNN model learns structural features such as border lines, intersections, and alignment patterns in financial table images through training.
[0030] S103, financial table structure identification:
[0031] S1031, image preprocessing: firstly, preprocess the image of the financial table to be processed, including grayscale, binarization, noise removal, contrast enhancement, etc.;
[0032] S1032, structural feature extraction: Use the CNN model trained in step S102 to extract structural features in the financial table image, such as border lines, intersections, and text blocks.
[0033] S1033, row and column recognition: using the CNN model to analyze the line and text alignment patterns in the financial table image, detect the row and column boundaries in the financial table image, and identify the title row, table header, and data cells in the financial table image.
[0034] S104, key information extraction: automatically extract key financial information from the financial table image, such as amount, date, company name, etc., and convert it into structured data. The specific process is:
[0035] S1041, OCR recognition: In step S103, the overall structural analysis of the financial table image has been achieved through image preprocessing, structural feature extraction and row and column recognition, including the recognition of title rows, headers and data cells. On this basis, the OCR recognition in this step focuses on recognizing the text content in these identified and located cell images. For the cells in the financial table image after the table structure recognition, the OCR model trained in step S102 is used to perform text recognition on the cell image and convert it into editable text. It provides a basis for subsequent named entity recognition (S1042) and key information extraction (S1043).
[0036] S1042, named entity recognition (NER): use the BiLSTM-CRF model trained in step S102 to identify and classify the financial-related entities in the text recognized by OCR in step S1041.
[0037] S1043, key information extraction: This step involves further processing and analysis of the text obtained by OCR recognition in step S1041 to extract key financial information. Specific methods include keyword matching, regular expressions and context relevance analysis, all of which are performed on the text after OCR recognition in step S1041.
[0038] Keyword matching: Create a keyword dictionary specifically for financial terms. These keywords may include common financial indicators and terms such as "assets", "liabilities", "profits", "cash flow", etc. By performing string matching on the OCR-recognized text, these keywords and their related financial information can be quickly identified and extracted.
[0039] Regular expressions: To extract financial data in a specific format from text, such as amounts (e.g., a number followed by a currency symbol) and dates (e.g., in the format of "YYYY-MM-DD"), the method of this embodiment uses set regular expression patterns. These patterns can identify and extract text fragments that conform to the specified financial data format, thereby converting the data into a structured format for further analysis and processing.
[0040] Contextual relevance analysis: After extracting keywords and data in a specified financial data format, the entities extracted by the BiLSTM-CRF model are subjected to contextual relevance analysis to ensure the accuracy and completeness of the information. This analysis uses prior knowledge in the financial field to evaluate whether the extracted entities are reasonable in the financial context. For example, if the model recognizes the entity "current assets", contextual relevance analysis will ensure that the surrounding text contains specific asset items associated with it, such as "cash and cash equivalents".
[0041] Example 2
[0042] This embodiment provides an application example of the method described in Embodiment 1.
[0043] A medium-sized enterprise needs to automatically extract balance sheet and income statement data from its annual financial report for digital management and analysis. A listed company also needs to automatically extract balance sheet data from its annual financial report and input this data into the company's financial analysis system.
[0044] The original data is the company's annual financial report, including scanned copies of the balance sheet and income statement. The PDF file of the company's annual financial report includes a balance sheet with multiple pages.
[0045] The goal is to accurately identify and extract key data from the balance sheet and income statement and convert it into a structured data format for further analysis. Automatically extract specific financial data from the balance sheet, such as current assets, fixed assets, current liabilities, etc.
[0046] Step 101: Dataset Construction:
[0047] Data collection: Scanned copies of annual financial reports for the past five years were collected to ensure sample diversity, including scanned copies of balance sheets and income statements in different formats and layouts.
[0048] Data preprocessing: Perform preprocessing operations such as denoising, binarization, and noise removal on the collected scanned images to improve image quality, and convert the preprocessed images into a uniform resolution and format.
[0049] Data annotation: Financial experts annotate key information of each financial table image, including the table’s location, title, financial indicators, etc., and create annotation guidelines to ensure consistency and accuracy of annotation.
[0050] Dataset partitioning: Divide the labeled dataset into training, validation, and test sets to ensure that the data is evenly distributed and covers a variety of table formats and layouts.
[0051] Step 102: Model training
[0052] Model design: Based on the PyTorch framework, a deep learning model is built, which includes a CNN model for feature extraction, a BiLSTM-CRF model for sequence modeling, and an OCR model for text recognition.
[0053] Training preparation: Set appropriate training parameters, including learning rate, batch size, etc., and define the cross entropy loss function and Adam optimizer.
[0054] Model training: On the PyTorch platform, the CNN model, BiLSTM-CRF model, and OCR model are trained using the training set data. The loss and performance indicators during the training process are monitored, and the model performance is regularly evaluated on the validation set. The hyperparameters are adjusted to optimize the model.
[0055] Model evaluation and adjustment: Use the test set to evaluate the trained model, obtain performance indicators such as recognition accuracy and recall rate, and adjust the model structure or training process based on the evaluation results to improve performance.
[0056] Model optimization: Use data augmentation, regularization and other techniques to improve the generalization and robustness of the model, and perform hyperparameter optimization, such as learning rate adjustment and batch normalization, to further improve model performance.
[0057] Step 103: Table structure identification
[0058] Image preprocessing: convert the balance sheet page in the scanned document to be processed into an image format (such as PNG or JPEG), and grayscale, binarize, remove noise, and enhance contrast on the image to highlight the borders and text of the table.
[0059] Structural feature extraction: The trained CNN model is used to identify table borders and intersections in the image, and the edge detection algorithm is used to further enhance the table lines.
[0060] Row and column recognition algorithm: Use the trained CNN model to analyze line and text alignment patterns in images to automatically detect row and column boundaries and identify title rows, headers, and data cells in the balance sheet.
[0061] Table structure analysis: Use the identified row and column information to build the logical structure of the table, including determining the location and range of each cell.
[0062] Step 104: Extract key information
[0063] OCR text recognition: For cells in the financial table image after table structure recognition, the OCR model is used to convert the text in the image into an editable text format.
[0064] Named Entity Recognition (NER): Use the trained BiLSTM-CRF model to process the OCR-recognized text to identify and classify financial-related entities (such as "current assets", "total liabilities", etc.).
[0065] Keyword matching and regular expressions: Create a keyword dictionary containing financial terms, use string matching techniques to identify and extract these keywords from OCR-recognized text, and design regular expressions to match financial data in specified formats, such as amounts (for example, matching a pattern of a number followed by a currency symbol) and dates (for example, matching a pattern of "YYYY-MM-DD" format).
[0066] Contextual relevance analysis: Combined with knowledge from the financial domain, the entities identified by the BiLSTM-CRF model are contextually analyzed to ensure that the extracted information is financially accurate and meaningful. For example, if "current assets" is identified, check whether its context contains specific asset items, such as "cash and cash equivalents."
[0067] Data conversion and output: Convert the extracted structured data into a data format suitable for input into the financial analysis system (such as CSV, JSON, or a format for direct input into the database), and output the final financial data for financial analysis and decision support.
[0068] Through the above process, key data can be automatically extracted from complex financial documents, greatly improving the efficiency and accuracy of data processing, reducing manual input errors, and accelerating the financial analysis process.
[0069] For those skilled in the art, various corresponding changes and modifications can be made according to the above technical solutions and concepts, and all of these changes and modifications should be included in the protection scope of the claims of the present invention.
Claims
1. A financial data extraction method for optimizing financial process tables, characterized in that: The steps include: S101, data set construction: collect and organize financial table images to construct a diverse financial table data set; S102, constructing a convolutional neural network (CNN) model based on the PyTorch framework for identifying structural features in financial tables, constructing an OCR model based on the PyTorch framework for text recognition, and constructing a BiLSTM-CRF model based on a bidirectional long short-term memory network (BiLSTM) combined with a conditional random field (CRF) for identifying and classifying financial-related entities in text; training the CNN model, the OCR model, and the BiLSTM-CRF model on the PyTorch platform using the financial table dataset constructed in step S101; the CNN model learns the structural features in the financial table image through training; S103, financial table structure identification: S1031, image preprocessing: firstly, preprocess the image of the financial table to be processed; S1032, structural feature extraction: using the CNN model trained in step S102 to extract structural features in the financial table image; S1033, row and column recognition: using the CNN model to analyze the line and text alignment patterns in the financial table image, detect the row and column boundaries in the financial table image, and recognize the title row, table header, and data cells in the financial table image; S104, key information extraction: S1041, OCR recognition: for the cells in the financial table image after the table structure recognition, the OCR model trained in step S102 is used to perform text recognition on the cell image and convert it into editable text; S1042, named entity recognition: using the BiLSTM-CRF model trained in step S102 to identify and classify the financial-related entities in the text recognized by OCR in step S1041; S1043, key information extraction: Keyword matching: Create a keyword dictionary specifically for financial terms, which includes common financial indicators and terms, and then identify and extract the keywords and their related financial information by performing string matching on the OCR-recognized text; Regular expression: Use the set regular expression to extract financial data in a specified format from the text recognized by OCR; Contextual relevance analysis: After extracting keywords and financial data in a specified format, contextual relevance analysis is performed on the entities extracted by the BiLSTM-CRF model to ensure the accuracy and completeness of the information.
2. The method according to claim 1, characterized in that In step S101, after preprocessing the collected financial table images, the images are converted to a uniform resolution and format, and then financial experts annotate the key information of each financial table image and create an annotation guide to ensure the consistency and accuracy of the annotation; the annotated financial table images are divided into a training set, a validation set, and a test set to ensure that the data is evenly distributed and covers a variety of table formats and layouts.
3. The method according to claim 2, characterized in that The preprocessing in step S101 and step S1031 includes gray-scaling, binarization, noise removal and contrast enhancement.
4. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.
5. A computer device, characterized in that: The method comprises a processor and a memory, wherein the memory is used to store a computer program; when the processor is used to execute the computer program, the method described in any one of claims 1 to 3 is implemented.
