Skip to main content

fastdocparse

Extract structured data from semi-structured documents — invoices, bills, tax forms, resumes, bank statements, shipment manifests — using any OpenAI-compatible LLM (OpenAI, Ollama, vLLM, Groq, etc.), with per-field grounding and confidence, not just raw extraction.

Why this, not just another parser

Most extractors give you a value and no way to know if it's real. This one tells you:

  • grounded — the value was found verbatim (or near-verbatim) in the source document text.
  • ungrounded — the value doesn't appear in the source — likely a hallucination. Flag for human review.
  • missing_required — a field you marked required came back empty.
  • invalid_format — the value doesn't match a pattern/enum constraint you declared (e.g. a shipment status outside the allowed list).
  • failed_check — a custom cross-field rule failed (e.g. line items don't sum to the stated total).

No extra LLM call for any of this — it's deterministic, string/rule-based validation against text you already extracted.

Where it fits: semi-structured documents with recurring fields (invoices, bills, tax forms, resumes, statements), and prose documents where proving a value came from the source matters (contracts, legal clauses, insurance claims). It is not a vision-LLM pipeline — it works from extracted text (digital PDF text layer, or local OCR for scans/images), which is what keeps it fast, cheap, and usable with small local models. Messy handwritten forms or complex multi-column layouts are a known weaker spot (see document-extractor-spec.md).

Two ways to use it

Who it's for How
CLI No coding needed fastdocparse extract <file> <schema.json>
Python API Building it into your own app DocumentParser(client).extract(document_bytes, schema)

Defining what to extract also has two paths — hand-write a JSON/YAML schema file, or describe it in plain English and let the LLM draft the schema for you.

Install

pip install fastdocparse

For local development instead:

git clone https://github.com/pranjalparmar/fastdocparse
cd fastdocparse
python -m venv venv
source venv/bin/activate        # Windows: venv\Scripts\activate
pip install -e ".[dev]"

You also need access to an LLM. Either:

  • An OpenAI API key (export OPENAI_API_KEY=... or pass --api-key), or
  • A local model via Ollama — no API key, no cloud, documents never leave your machine.

Quickstart — CLI (no coding)

# 1. Extract using one of the bundled example schemas
fastdocparse extract sample_invoice.png src/fastdocparse/schemas/invoice.json \
  --model gpt-4o-mini --api-key sk-...

# Or with a local model via Ollama (no API key needed):
fastdocparse extract sample_invoice.png src/fastdocparse/schemas/invoice.json \
  --model llama3.2 --base-url http://localhost:11434/v1 --api-key ollama

Output is JSON, printed to stdout (or saved with --output result.json):

{
  "_meta": { "truncated": false, "truncation_reason": null },
  "invoice_number": { "value": "INV-9011", "confidence": "high", "flags": ["grounded"] },
  "total_price": { "value": 100.0, "confidence": "high", "flags": ["grounded"] }
}

Don't want to write JSON at all? Describe the fields in plain English instead:

fastdocparse schema-from-text \
  "I want the invoice number, total price, and vendor name. Invoice number and total are required." \
  --output my_invoice_schema.json

# review my_invoice_schema.json, then:
fastdocparse extract my_invoice.pdf my_invoice_schema.json

Quickstart — Python API

from fastdocparse import Schema, Field, LLMClient, DocumentParser

schema = Schema(
    name="Invoice",
    fields=[
        Field(name="invoice_number", description="The invoice number", required=True),
        Field(name="total_price", description="Total amount due", type="number", required=True),
    ],
)

client = LLMClient(model="gpt-4o-mini", api_key="sk-...")
# or: LLMClient(base_url="http://localhost:11434/v1", api_key="ollama", model="llama3.2")

parser = DocumentParser(client=client)

with open("invoice.pdf", "rb") as f:
    result = parser.extract(f.read(), schema)

print(result["invoice_number"])  # {'value': 'INV-9011', 'confidence': 'high', 'flags': ['grounded']}

Full documentation

  • Getting Started — step-by-step install, CLI, and API walkthroughs
  • Schema Guide — every field option (type, required, pattern, enum, sub_fields, few-shot examples), for JSON, YAML, and plain-English authoring
  • Output & Validation — the full result shape, what each confidence flag means, and how to write custom cross-check rules
  • Architecture — diagrams of the pipeline, the module dependency graph, and where to plug in a contribution
  • Project spec — architecture, phased roadmap, honest competitive positioning

Want to contribute? Start with docs/architecture.md for the map, then CONTRIBUTING.md for the process.

Status

Core extraction, grounding, chunking, both CLI/API paths, and real packaging are implemented and tested (74 tests, pytest -v). Published on PyPI as fastdocparsepip install fastdocparse installs a working fastdocparse command and a proper fastdocparse.* import namespace, verified end to end with a clean-virtualenv install straight from the real public index. Not yet done: a hosted API — see document-extractor-spec.md for the roadmap.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastdocparse-0.2.0.tar.gz (40.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastdocparse-0.2.0-py3-none-any.whl (35.1 kB view details)

Uploaded Python 3

File details

Details for the file fastdocparse-0.2.0.tar.gz.

File metadata

  • Download URL: fastdocparse-0.2.0.tar.gz
  • Upload date:
  • Size: 40.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.7

File hashes

Hashes for fastdocparse-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ac2a0f70f0f9bb73e395d228643a02e8721884ac89d1637333f469087cef7a48
MD5 9c5bcc37151bd0fe87db707d99b74745
BLAKE2b-256 1b954f32c481806eec92bc8e69cb85871c9cec117aec2bff1cb8f3b693497008

See more details on using hashes here.

File details

Details for the file fastdocparse-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: fastdocparse-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 35.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.7

File hashes

Hashes for fastdocparse-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 585add2d8ce759c5b096a386c4d580bd1caecdf2105a2c36fe3e58b8795bbba0
MD5 72d158e8fd068cda2ea9846c4524c4f6
BLAKE2b-256 3c8633786f95f17b040daabfb0b45216136e56e658c9d4a8aecab40f7f068156

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.0

2 files

This release

0.2.0 This release

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page