> Agent-ready spec from Diff of the Day (2026-11-27, idea 3). Give this file to your coding agent (Claude Code, Codex, Cursor) and ask it to build the P0 requirements first.

# Spec: Receipts and PDFs to clean tables with Nemotron 3.5 Parse

## Problem Statement
Receipts, invoices and scanned forms pile up as PDFs and photos, and turning them into rows still means typing. NVIDIA released Nemotron 3.5 Parse, a 0.6B document parser with its training data and a fine-tuning recipe, small enough to run locally. It is a good test of whether a local model can replace manual entry for your own documents.

## Goals
- Turn a folder of 20 mixed documents into one CSV of line items in a single command.
- Reach at least 90% correct totals on your 20-document test set, checked by hand.
- Keep all documents on your machine.

## Non-Goals
- A web app or upload service: local CLI only, no data leaves the machine.
- Accounting features (categories, tax rules): a separate project.
- Handwriting: printed documents first.

## User Stories
- As someone with a folder of receipts, I want one command that produces a CSV so that I stop typing totals.
- As a user, I want each row linked to its source file and page so that I can check it quickly.
- As a user, I want low-confidence fields flagged so that I review only those.
- Edge case: as a user, I want a document the model cannot parse listed in an errors file instead of stopping the run.

## Requirements
### P0 (must have)
1. **CLI** `parse-docs <folder> --out items.csv` for PDF, PNG and JPG.
   - [ ] Runs fully offline once the model is downloaded.
2. **Parsing** with Nemotron 3.5 Parse, loaded as its model card on Hugging Face describes.
   - [ ] Each document produces structured tables saved as JSON next to the CSV.
3. **Normalisation** to columns: file, page, vendor, date, item, quantity, unit price, line total, document total.
   - [ ] Given a receipt whose line totals do not add up to its document total, when the run ends, then the row is flagged "check".
4. **Errors file** `errors.csv` with file name and reason.

### P1 (nice to have)
- A small HTML review page that shows the image next to the extracted rows.
- Fine-tune on 10 corrected examples of one layout that keeps failing, following the release's recipe.

### P2 (future)
- Watch a folder and append new documents automatically.

## Success Metrics
- Leading: all 20 documents processed; under 2 minutes total on your hardware.
- Lagging: document totals correct on at least 90% (18 of 20); you use it for the next month's receipts.

## Open Questions
- GPU or CPU on your machine? This decides speed and batch size. (you)
- Which 20 documents form the test set? (you)

## Timeline
One evening for P0; a second evening for the review page or fine-tuning.

## Agent Instructions
- **Suggested stack**: Python 3.12, the libraries named on the model card, pandas for the CSV.
- **Build order**: load the model and parse one document → batch over a folder → normalise to columns → totals check → errors file → P1.
- **Safety**: documents never leave the machine; no uploads; do not commit the documents or the CSV to a public repo.
- **Done when**: the CSV for the 20-document set exists and you have hand-checked the totals.

## Sources
- Building on Nemotron 3.5 Parse: https://huggingface.co/blog/nvidia/building-on-nemotron-35-parse-open-data-fine-tunin
