SAAD-DEV

saad-dev.com / work / document_pipeline

Document AI · human-in-the-loop

document_pipeline

Claude-vision state machine. Any document in, a validated row out. Three LLM calls, one repair attempt, one human gate, 69 tests.

$ python -m document_pipeline invoice.pdf
  1. [classify] invoice.pdf → INVOICE 0.9s
  2. [extract] 14 fields, schema-enforced 1.4s
  3. [validate] cross-field check .......... FAIL
  4. [repair] 1 attempt ................... OK
  5. [human] approved ✓
  6. ✓ committed to postgres · 3 llm calls · 69/69 tests

What it does

Upload a PDF or a photo of a document; Claude classifies it, extracts the fields into a schema, a non-AI check validates the numbers, one repair attempt runs if they do not add up, and a person approves before anything is written to the database.

How it works

  • LangGraph pipeline: load → classify → extract → validate → (one repair loop) → review queue.
  • Claude's native PDF and vision input, so there is no separate OCR service.
  • Cross-field validation is plain code, not an LLM: cheap and deterministic.
  • At most three LLM calls per document: classify, extract and an optional repair.
  • A review queue shows the document next to the extracted fields; Approve & Commit writes the rows in one transaction.

By the numbers

  • 69 tests
  • ≤3 LLM calls per document
  • 1 repair attempt
  • 1 human approval gate

Stack

  • Python
  • LangGraph
  • Anthropic Claude
  • Pydantic
  • PostgreSQL
  • SQLAlchemy
  • Streamlit
  • Docker

Questions

Can I run document_pipeline myself?

Yes. It is open source at https://github.com/s-wasim/document_pipeline, and the README walks through running it locally.

Can Saad Waseem build something like document_pipeline for my team?

Yes. He builds production AI agents and automations like this one, remotely from Lahore for teams in the US and EU, at $40/hr for build work. Book 20 minutes from the CV, or email saad@saad-dev.com.