CloudScan - A Configuration-Free Invoice Analysis System Using Recurrent Neural Networks

Rasmus Berg Palm, Ole Winther, Florian Laws

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.

The CloudScan document processing pipeline from raw PDF to structured XML.
  1. Text Extraction: PDF or OCR text is converted into words with associated spatial coordinates.
  2. N-grammer: Words on the same line are grouped into sequences (n-grams) of up to length four.
  3. Feature Calculation: Each n-gram is represented by a feature vector capturing text patterns, normalized positions, and semantic flags (e.g., date-like patterns).
  4. 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.
  5. 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).
  6. 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.

Performance comparison between the Logistic Regression baseline and the LSTM model on unseen invoice 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

Abstract

We present CloudScan; an invoice analysis system that requires zero configuration or upfront annotation. In contrast to previous work, CloudScan does not rely on templates of invoice layout, instead it learns a single global model of invoices that naturally generalizes to unseen invoice layouts. The model is trained using data automatically extracted from end-user provided feedback. This automatic training data extraction removes the requirement for users to annotate the data precisely. We describe a recurrent neural network model that can capture long range context and compare it to a baseline logistic regression model corresponding to the current CloudScan production system. We train and evaluate the system on 8 important fields using a dataset of 326,471 invoices. The recurrent neural network and baseline model achieve 0.891 and 0.887 average F1 scores respectively on seen invoice layouts. For the harder task of unseen invoice layouts, the recurrent neural network model outperforms the baseline with 0.840 average F1 compared to 0.788.
BibTeX
@inproceedings{palm2017cloudscan,
  author = {Rasmus Berg Palm and Ole Winther and Florian Laws},
  title = {{CloudScan - A Configuration-Free Invoice Analysis System Using Recurrent Neural Networks}},
  booktitle = {ICDAR},
  year = {2017},
  url = {https://openreview.net/forum?id=PCFDaJ0ROaN},
}
Figure