Build a Contract-Intelligence Pipeline
Build a working contract-intelligence pipeline end to end. Ingest sample contracts, run OCR + open-source LLM extraction, persist to Postgres against a realistic contract data model, build an evaluation harness, expose results via API. ~3 hours start to finish; ~6 chapters of working code at every step.
A minimal but real contract-intelligence pipeline. Drop a PDF in a folder; an ingestion job picks it up, runs OCR, extracts structured fields with an LLM, persists to Postgres with the contract data model, and exposes results via a FastAPI endpoint. An eval harness scores accuracy against a small gold set. Working code; ready to extend.
Python 3.11+, Docker (for Postgres), an LLM API key (Anthropic Claude or OpenAI — Claude shown by default), familiarity with FastAPI or willingness to read along, and a few sample contracts (5–10 PDFs work; public templates are fine for a first pass).
documents. Handle re-ingest idempotently.
03Extraction: OCR + LLM
Use Tesseract for OCR on scanned PDFs; route native PDFs through pdfplumber. Then call Claude with a structured-output prompt to extract parties, effective date, renewal terms. Confidence scoring.
04Persistence: The Contract Data Model
SQLAlchemy models for documents, agreements, obligations, suppliers. Upsert by (document_id, model_version) for idempotency. Provenance columns.
05Evaluation Harness
A tiny gold-set repository, a CLI to run extraction over the gold set and score per-field accuracy, a calibration check, a Markdown report. Run before every prompt or model change.
06API Exposure
FastAPI endpoints: list agreements, fetch an agreement with its obligations, search by supplier. Pagination, filters, basic auth. The API your customer's BI / app would call.