TL;DR
This paper presents an end-to-end pipeline for extracting structured data from financial tables embedded in image documents. By combining deep learning for segmentation and OCR with classical algorithms, they achieve high-fidelity extraction, addressing the challenge of pixelated, unstructured financial data.
What Problem Does This Paper Address?
Automating data extraction from financial documents is crucial, but a significant hurdle arises when these documents are in image format. Unlike text-based documents where content can be easily copied and pasted, images present data as pixels, making direct extraction difficult. Financial documents, in particular, are notorious for their varied layouts, inconsistent formatting, and lack of standardization, further complicating the task of accurately identifying, extracting, and structuring tabular information. This paper tackles the challenge of converting these visually rich but computationally opaque tables into usable, structured data.
Methods
The authors propose a three-step pipeline:
- Table Identification (Segmentation): They frame table detection as a semantic segmentation problem, classifying each pixel as either belonging to a table or not. To handle cases where tables are close together, they introduce a "separator" class, effectively turning it into a 3-class segmentation task. This approach leverages U-Net, a popular architecture for image segmentation, with a DenseNet-169 backbone. A binary classification model is used first to quickly filter out pages without tables, improving efficiency.
- Content Recovery (OCR): Once table regions are identified, Tesseract OCR is employed to extract the text content. The authors detail a preprocessing pipeline for OCR that includes Otsu thresholding, automatic orientation correction, and morphological kernel filtering to clean up the image and improve OCR accuracy.
- Alignment into Tabular Format: This is the most complex step, involving organizing the extracted text and its positional metadata into a structured table. They use a union-find data structure inspired by Knight's work on unification to group text segments into columns. This algorithm uses Intersection Over Union (IOU) to trigger merges and path compression with union by rank for efficiency. A variety of models, including feedforward, LSTM, and Transformer architectures, are explored for column segmentation, with LSTM: Local Table performing best.
Datasets
The authors created a dataset by sampling 10,000 pages from a collection of financial documents (annual reports, prospectus documents, shareholder meeting notes).
- For table detection (classification and segmentation), 8,000 pages were used for training and 2,000 for validation.
- For segmentation model training, a subset of 749 pages with 160 for validation was used.
- A separate test set of 1,000 random pages was used for evaluation.
- For the alignment stage, a dataset of 3,640 suspected tables was sampled, and 3,038 of these were hand-labeled for cell boundaries after lines were removed.
Key Insights and Ideas
- Semantic Segmentation for Table Detection: Framing table detection as a semantic segmentation problem, rather than traditional object detection, proves effective for pixel-level classification and handling complex layouts.
- The "Separator" Trick: Introducing a dedicated "separator" class in the segmentation model is crucial for distinguishing adjacent tables, significantly improving performance in such challenging cases.
- Leveraging Tesseract's Metadata: Tesseract OCR provides not just text but also valuable positional and layout metadata (bounding boxes, line/word identifiers) that are essential for the subsequent alignment step.
- Union-Find for Column Grouping: The use of a union-find data structure provides an efficient and robust way to group text segments into columns, forming the backbone of the alignment process.
- LSTM Outperforms Transformers for Local Table Modeling: Surprisingly, for the task of segmenting columns within a table, LSTM models, particularly those that consider local table context, outperformed Transformer-based models, suggesting that a more constrained attention mechanism might be beneficial for this specific task.
Key Results
- Table Detection: The classification model achieved a recall of 0.995 and precision of 0.871 on the validation set. For the end-to-end pipeline, page-level evaluation showed 83% of pages were completely correct, with another 9.5% considered partially correct.
- Alignment Performance: Table 2 shows a comprehensive comparison of alignment models. The best performing model, LSTM: Local Table, achieved a median SMAPE of 41.28% and a high percentage of perfect alignments (10.50%). This significantly outperforms the unsupervised baseline.
- Qualitative Examples: The paper includes figures showcasing successful extraction of tables with borders, without borders, inline tables, and stacked tables, as well as examples of partial successes and common error types.
Limitations and Future Work
- Limitations:
- The paper acknowledges that the segmentation model can struggle with very wide but short tables, potentially missing columns if spacing is large.
- Accidental merger of multiple tables, especially when they lack borders and are close together, is a common error.
- The alignment model can sometimes predict extra blank surrounding areas or miss table headers, leading to partially correct detections.
- Future Work: The authors suggest that the extracted tabular data can be directly used for various downstream applications, such as correcting rendered Excel sheets, embedding into financial projections, and directly integrating into financial analysis tools. Further improvements could focus on handling more complex table structures and reducing the types of errors observed in the partially correct cases.
Summary updated