TLDR: This paper compares two AI methods for extracting information from invoices: Docling (an OCR and layout-driven approach) and LlamaExtractor (an LLM-based system). LlamaExtractor achieved significantly higher accuracy (94% vs. 63%) and better consistency (93% vs. 80% pass rate) but was slower (30 seconds per document vs. 10 seconds). Docling was faster and more cost-efficient. The study highlights a trade-off between semantic accuracy and computational efficiency, suggesting LLM-based systems are better for high-precision enterprise needs, while OCR-based systems suit speed and cost-sensitive applications. Future work includes hybrid pipelines and domain-adaptive fine-tuning.
Invoices are fundamental documents for any organization, serving as proof of transactions and crucial for accounting and tax purposes. However, managing and analyzing these documents can be a costly and time-consuming endeavor. The process of extracting and automating information from invoices can significantly boost an organization’s productivity, leading to a high demand for automated invoice extraction systems. This paper delves into various methods for extracting structured information from invoice documents and proposes a robust set of evaluation metrics to assess the accuracy of the extracted data against a known ground truth.
Historically, invoice information extraction (IIE) has evolved from traditional template-based methods to advanced deep learning models. Early approaches relied heavily on Optical Character Recognition (OCR) combined with rule-based systems. These systems would convert invoice images into machine-readable text and then apply handcrafted rules or templates, often using regular expressions, to locate specific patterns like dates or invoice numbers. While effective for consistent layouts, these template-based methods were brittle and struggled to generalize to new or unseen invoice formats, which is a significant limitation given the vast diversity in invoice designs. Maintaining these systems also incurred substantial overhead, as each new invoice layout required a new template.
The limitations of rule-based systems paved the way for machine learning (ML) and deep learning (DL) approaches. These modern techniques can learn to extract information from diverse layouts without explicit rules, generalizing across different formats by learning patterns from annotated data. Deep learning, particularly transformer-based architectures like LayoutLM and its variants such as DocFormer, has shown superior results. These models incorporate 2D positional embeddings alongside text and visual embeddings, allowing them to understand the spatial arrangement of words on a page, which is vital for identifying fields like headers and line items.
Another innovative approach involves graph-based methods, where a document is represented as a graph. Text segments become nodes, and their spatial and logical relationships form edges. Graph Neural Networks (GNNs) analyze this structure to learn representations that encode relational context, proving particularly effective at capturing complex dependencies and modeling tabular structures, especially for critical line item extraction. This capability allows businesses to automate processes like three-way matching, preventing overpayments and enabling granular spending analytics.
The advent of Large Language Models (LLMs) has marked a significant shift, moving away from the conventional supervised learning approach that demands extensive task-specific fine-tuning. LLMs leverage vast pre-trained knowledge to perform complex reasoning and extraction tasks with minimal or no task-specific examples, a concept known as in-context learning. This involves conditioning the model at inference time with a natural language prompt that describes the task, allowing rapid adaptation to new tasks without dedicated training. Multimodal LLMs, also known as Vision-Language Models (VLMs) like GPT-4V and LLaVA, further enhance this by processing document images directly, integrating visual features with textual prompts to ground text in its visual context, capturing layout, font styles, and table structures often lost in plain text.
This research paper specifically compares two distinct methodologies for invoice information extraction: Docling and LlamaExtractor. The study utilized a curated dataset of 102 digitally born and scanned invoice documents in PDF and JPEG formats, varying in layout, language, and complexity. Each invoice was manually annotated to create a ground truth JSON schema for key fields like invoice number, date, seller details, total amount, and line items. The evaluation framework included field-level metrics (exact match, relaxed match, tolerance windows for numeric fields, F1 scores) and line item metrics (row-wise assignment accuracy, tolerance-based numerical checks, table-level completeness), alongside robustness checks for cross-vendor performance and template generalization.
Docling, an end-to-end document understanding model, parses diverse invoice formats into a unified document representation, bypassing traditional OCR and layout detection pipelines. It achieved an overall accuracy of 63% and an 80% pass rate on consistency checks. While it showed high accuracy for entities like invoice name and number (90%), it struggled with unstructured text fields, complex table structures, and multi-line descriptions, leading to lower accuracy for tax amount, net amount, currency format (60%), and line items (58%). Its processing time was faster, averaging 10 seconds per document.
The LlamaExtractor, an LLM-based system, uses schema-guided structured extraction to return deterministic JSON. It relies on structured output capabilities like JSON Schema-constrained decoding to guarantee type-safe outputs. This method demonstrated superior performance, achieving an overall extraction accuracy of 94% and a 93% consistency check pass rate. It showed strong precision for invoice and bill-to entities, with line items exhibiting a slightly lower but still impressive 91% accuracy. Notably, the LlamaExtractor recorded zero mathematical validation errors, suggesting its internal reasoning capabilities enhance the logical verification of numeric data. However, its processing time was slower, averaging 30 seconds per document.
In a comparative analysis, the LlamaExtractor clearly outperformed Docling in accuracy and consistency, showcasing a stronger ability to interpret and structure invoice content across various formats. Docling, however, was faster and required lower computational resources, making it more cost-efficient. Error analysis revealed that LlamaExtractor’s primary errors stemmed from variable field descriptions and numeric formatting variations, while Docling’s errors predominantly arose from mathematical validation issues and incomplete line item extractions, often due to OCR misreads. LlamaExtractor also demonstrated better handling of complex layouts and multi-page documents.
In conclusion, the choice between these two methodologies depends on specific operational priorities. The LlamaExtractor offers a more intelligent, semantically aware, and accurate solution, ideal for enterprises demanding high reliability and scalability across diverse invoice templates. Conversely, the Docling method, while less accurate, provides a lightweight, faster, and more cost-efficient alternative, suitable for applications where speed and simplicity are prioritized over high precision. This study highlights the trade-off between semantic accuracy and computational efficiency, underscoring that modern LLM-based extractors, when optimized, can significantly advance automated document understanding. For more details, you can refer to the full research paper here.
Also Read:
- Guide-RAG: Optimizing AI Chatbot Responses for Long COVID Clinical Questions
- PokeeResearch-7B: Advancing AI Agents for Complex Research with Self-Correction
Future research directions include integrating hybrid extraction pipelines that combine LLM’s semantic reasoning with OCR’s layout awareness to achieve a balance of efficiency and accuracy. Exploring domain-adaptive fine-tuning for language models and developing comprehensive benchmark datasets for invoice extraction are also crucial steps toward fully autonomous document understanding systems within enterprise ecosystems.


