Skip to content
SwankyForge
SwankyForge
All case studies
LLMRAGDocument AI4 months

Document Intelligence (OCR, Extraction, RAG)

Every invoice was read and typed in by hand. Four in five now go through untouched.

Straight-through processing

81%

Confidence-routed extraction

Was

0%

Every document keyed by hand

In plain terms

What this actually was.

No jargon in this section. The technical write-up is further down.

What was going wrong

Contracts and invoices arrived as scans of wildly varying quality. Staff read them and typed the values in, which was slow, easy to get wrong, and left no way to prove where any given number had come from.

What we built

We built extraction that reads the documents, says how confident it is in each value, and sends only the doubtful ones to a person — with every value linked back to the exact spot on the page it came from.

What changed

Four in five documents now pass through with nobody touching them, manual work is limited to real exceptions, and month-end close no longer waits on paperwork. Any figure can be traced back to its page.

Architecture

How it fits together.

Scroll through the stages. Anything marked as added is a component that did not exist before this project.

CHUNKSLOW CONFDoc intakeSCAN + PDFOCRLAYOUT AWAREExtraction47 FIELDSRAG indexCITATIONSReview queueBY CONFIDENCEERP syncVALIDATED
  1. Doc intake

    scan + pdf

    feeds
    OCR
  2. OCR

    layout aware

    receives from
    Doc intake
    feeds
    Extraction · RAG indexchunks
  3. Extraction

    47 fields

    We added this
    receives from
    OCR
    feeds
    Review queuelow conf
  4. RAG index

    citations

    We added this
    receives from
    OCRchunks
  5. Review queue

    by confidence

    We added this
    receives from
    Extractionlow conf
    feeds
    ERP sync
  6. ERP sync

    validated

    receives from
    Review queue
The write-up

How it was actually built.

Dataset, approach, measured results and the stack. Written for whoever has to review it.

LLMRAGDocument AI4 months

Document Intelligence (OCR, Extraction, RAG)

Turn PDFs into structured data and searchable knowledge with citations.

Problem

Contracts and invoices arrived as scans of varying quality. Keyed-in data was slow and error-prone, and there was no audit trail linking a field back to the page it came from.

Dataset

rows
840k pages
features
47 extracted fields
sources
Scans, PDFs, email attachments
window
30 months

Approach

  1. 01OCR with layout preservation so table structure survives extraction
  2. 02Field extraction with per-field confidence and span-level provenance
  3. 03RAG index over the corpus for natural-language lookups with citations
  4. 04Review queue routed by confidence, with corrections feeding back

Metrics

96.8%
field accuracy
+14.2pp
81%
straight-through
no human touch
$0.07
cost / doc
-$1.90
100%
citation coverage
span-linked

Business impact

  • Manual keying reduced to exception handling only
  • Every extracted value traceable to a page and bounding box
  • Month-end close no longer waits on document processing

Tech stack

  • Python
  • Tesseract
  • DocTR
  • LayoutLM
  • PostgreSQL
  • Qdrant
  • FastAPI
  • Next.js

Next

Need a system like this?

Answer six questions and we will tell you whether this shape fits your problem — including when it does not.