PrettyPipeline
Turn PDFs into structured JSON. OCR runs locally; field extraction uses a cheap cloud LLM.
Why this is cheap
Cloud OCR APIs charge per page. PrettyPipeline does the expensive vision work on your GPU with baidu/Unlimited-OCR (MIT, 3B params, 32K context — a whole PDF in one infer_multi() pass). The only API call is GPT-5.4 nano on the resulting text (~$0.20 / 1M input tokens), prompted with your JSON schema.
You pay for a small text completion, not for pixels.
PDF → PyMuPDF pages → Unlimited-OCR (local GPU) → raw text
↓
GPT-5.4 nano (OpenAI) → JSON
↓
validation → needs_review flags
Nulls, model-marked uncertain fields, and OCR that looks garbled are flagged for a human instead of being silently accepted.
Install
Python 3.10–3.13 (3.12 recommended). NVIDIA GPU (CUDA) or Apple Silicon (MPS). CPU works but is slow.
python3.12 -m venv .venv
source .venv/bin/activate
pip install prettypipeline-ocr
# or from this repo:
pip install -e .
On NVIDIA Linux, install a CUDA build of PyTorch first if the default wheel is CPU-only:
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu124
pip install -e .
The first run downloads baidu/Unlimited-OCR from Hugging Face (~6GB).
Usage
export OPENAI_API_KEY=sk-...
prettypipeline run invoice.pdf --schema examples/invoice.schema.json
prettypipeline run invoice.pdf --schema examples/invoice.schema.json -o out.json
prettypipeline run invoice.pdf --schema examples/invoice.schema.json --ocr-only
prettypipeline run invoice.pdf --schema examples/invoice.schema.json --device mps
prettypipeline run invoice.pdf --schema examples/invoice.schema.json --max-length 2048
--schema is any JSON Schema. Swap the file to extract a different document type — nothing is hardcoded.
Device is auto-detected (cuda → mps → cpu). Override with --device.
On Apple Silicon, Unlimited-OCR can start looping (it hardcodes CUDA). Use --max-length 2048 for short docs. NVIDIA CUDA is the model's native path.
Output
{
"data": { "date": "…", "vendor": "…", "line_items": [], "total": 0 },
"needs_review": [{ "field": "tax", "reason": "null" }],
"ocr_text": "…"
}
License
MIT. Unlimited-OCR is also MIT.
Metadata
Release files for prettypipeline-ocr 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| prettypipeline_ocr-0.1.0.tar.gz | 9.2 kB | Without provenance | Details for prettypipeline_ocr-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| prettypipeline_ocr-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for prettypipeline_ocr-0.1.0-py3-none-any.whl |
Total release size: 17.9 kB
Release files / prettypipeline_ocr-0.1.0.tar.gz
| Download URL | prettypipeline_ocr-0.1.0.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c4d5dae36d2bd695bc1b2f73d0419c862c48c547e018089e29ac419b0e6c52df
|
|
BLAKE2b-256 checksum How to use checksums |
69017e6a6e6d0e358aae7f401aeaae32c6f65192c43e4b09de1ab83f96ff0840
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.9
|
Release files / prettypipeline_ocr-0.1.0-py3-none-any.whl
| Download URL | prettypipeline_ocr-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
638b797fdb79029521117b879ac6aa8091d7dcc4b0ca2cd0a950f49189866385
|
|
BLAKE2b-256 checksum How to use checksums |
610ba39d0649f08204efb1728cc223fe40561b0f5cd455df2588897ba603906a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.9
|
Security for prettypipeline-ocr 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.