Skip to Content
ProjectsInvoice OCR Pipeline

Multi-Model Invoice OCR Pipeline

Build an end-to-end invoice processing system using LayoutLMv3, TrOCR, and fine-tuned BERT for entity extraction

Problem Statement

We asked NEO to : Build an end-to-end invoice processing system using LayoutLMv3 for layout detection, TrOCR for text recognition, and a fine-tuned BERT model for entity extraction (vendor name, total amount, line items, dates). Handle multiple invoice formats and languages.

Multi-Model Invoice OCR Pipeline Architecture

Solution Overview

NEO built a multi-stage pipeline combining:

  1. LayoutLMv3: Detects the structure and layout of invoices
  2. TrOCR: Performs high-accuracy text recognition
  3. Fine-tuned BERT: Extracts relevant entities from recognized text

The pipeline allows robust handling of diverse invoice formats in a scalable way.


Workflow / Pipeline

StepDescription
1. Data IngestionCollect invoices from multiple vendors in PDF or image format
2. Layout DetectionUse LayoutLMv3 to segment invoices into header, line items, totals, and metadata regions
3. OCR Text RecognitionApply TrOCR on segmented regions for accurate text extraction
4. Entity ExtractionFine-tune BERT to extract vendor names, totals, dates, and line items
5. Post-processingNormalize date formats, currency symbols, and line items
6. Output GenerationProduce structured JSON or CSV for downstream accounting and ERP systems

Repository & Artifacts

Generated Artifacts:

  • Preprocessed invoice datasets
  • Trained LayoutLMv3 and TrOCR models
  • Fine-tuned BERT entity extraction model
  • Evaluation metrics and reports
  • Pipeline scripts for ingestion → output automation

Technical Details

  • Preprocessing: PDF/image conversion, rotation correction, noise reduction
  • Layout Detection: Fine-tuned LayoutLMv3 for region segmentation
  • Text Recognition: TrOCR with multilingual support
  • Entity Extraction: BERT fine-tuned on annotated invoice datasets
  • Error Handling: Skipped unreadable invoices, logging for manual review

Results

  • OCR Accuracy: 96%+ across multiple invoice layouts
  • Entity Extraction F1-Score: 93%
  • Multi-language support successfully handled invoices in English, Spanish, and French
  • JSON outputs ready for ERP integration

Best Practices & Lessons Learned

  • Annotate diverse invoice layouts for robust BERT fine-tuning
  • Normalize extracted entities immediately for consistent downstream processing
  • Separate layout detection from OCR for modularity and easier debugging
  • Log edge cases for manual verification to improve dataset iteratively

Next Steps

  • Add support for more languages
  • Implement real-time invoice processing for high-volume accounts
  • Integrate automated anomaly detection for invoice validation

References