Introduction
Extracting structured data from invoices is a persistent challenge in document processing. Traditional systems rely on layout-specific templates, which fail to scale in global trade networks where millions of unique invoice designs exist. Researchers from DTU and Tradeshift propose CloudScan, a system that replaces brittle templates with a global Recurrent Neural Network (RNN) capable of generalizing to previously unseen invoice layouts.
System Architecture
The CloudScan pipeline transforms raw PDF documents into structured XML (UBL) through a six-stage process.
- Text Extraction: PDF or OCR text is converted into words with associated spatial coordinates.
- N-grammer: Words on the same line are grouped into sequences (n-grams) of up to length four.
- Feature Calculation: Each n-gram is represented by a feature vector capturing text patterns, normalized positions, and semantic flags (e.g., date-like patterns).
- The Classifier: The core of the system is a Bidirectional Long Short-Term Memory (LSTM) network. Unlike traditional models that only consider local context, the LSTM processes the entire document as a sequence, capturing long-range dependencies between labels and values.
- Post-Processor: The system employs the Hungarian algorithm to resolve assignment conflicts, ensuring that extracted fields are logically consistent (e.g., ensuring line items sum to the total).
- Document Builder: The final structured data is output in a standard format.
A significant innovation in the training process is the use of distant supervision. Training labels are automatically generated by mapping historical user-entered data back to the original document text, enabling the use of massive, real-world datasets without manual annotation.
Experimental Evaluation
The system was trained and tested on a proprietary dataset of over 326,000 invoices from nearly 9,000 different senders. To test generalization, the researchers conducted experiments on "Unseen Layouts," where the test set contained only senders not present in the training data.
Results
The LSTM model demonstrated superior performance, particularly on the challenging task of processing unseen layouts.
On unseen layouts, the LSTM achieved a micro-averaged F1 score of 0.840, significantly outperforming the logistic regression baseline of 0.788. This performance is remarkably close to the results on seen layouts (0.891 F1), indicating that the model learns the underlying "language" of invoices rather than memorizing specific visual coordinates. Furthermore, ceiling analysis using an "Oracle" classifier suggests that the LSTM is approaching the theoretical performance limit (0.925 F1) imposed by OCR and parsing errors.
Conclusion and Future Work
CloudScan proves that a single, global RNN can effectively replace thousands of manual templates for invoice data extraction. By modeling documents as sequences, the system captures the necessary context to understand semi-structured data across diverse layouts. Future improvements may include incorporating visual features (lines, logos) to augment text-based features and addressing the current bottlenecks in OCR and complex table extraction.
Summary updated