# Shippable build — `dynamic-finetuned` This branch **is** the shippable product: one container = FastAPI backend + built React frontend + Tesseract OCR + the dynamic-baseline risk engine, running on the zero-shot DeBERTa classifier (MIT) by default. Verified end-to-end in deployment mode (backend serves the SPA + full API; uploads, risks, dynamic baseline, exports, portfolio, traceability all pass). ## Deploy (one command) ```bash APP_PASSWORD=choose-a-password docker compose up -d --build # app -> http://:8000 (PostgreSQL + zero-shot classifier + OCR, no model downloads at runtime) ``` The image bakes the zero-shot DeBERTa weights, so it runs **air-gapped** — no calls to huggingface.co. SQLite single-container fallback: `DATABASE_URL=sqlite:////app/data/contracts.db`. ## Defaults (the safe, clean ship config) | Setting | Default | Meaning | |---|---|---| | `CLASSIFIER` | `auto` | zero-shot DeBERTa (0.61, MIT) if weights present → rules. **Clean licence.** | | `CORE_LLM_BACKEND` | `auto` | Ollama if reachable → rules. Extraction works with or without an LLM. | | `CORE_LLM_MODEL_OLLAMA` | `qwen2.5:7b` | the extraction LLM (swap to your trained model — see below) | ## Plugging in the trained Ollama model (when ready) 1. Create it in Ollama (e.g. from your GGUF + Modelfile): `ollama create contract-llm -f Modelfile` 2. Point the app at it: `CORE_LLM_MODEL_OLLAMA=contract-llm CORE_LLM_BACKEND=ollama docker compose up -d` No code change — the extraction layer reads the model name from the env var. ## Optional: the fine-tuned classifier (accuracy upgrade) Default ships on zero-shot (clean licence, robust). To run the fine-tuned fusion classifier, drop the model dir in and set one env var — see `docs/ACTIVATE_FINETUNED.md`. Deploy on **DeBERTa 0.67 (MIT)**, not LegalBERT (CC-BY-SA). ## Verify a deployment ```bash curl -fsS http://:8000/api/health # {"status":"ok", ...} cd backend && ../.venv/bin/python tests/test_risk_golden.py # golden test OK ``` ## Accuracy (for the slide) rules 0.50 → zero-shot DeBERTa **0.61 (shipped default)** → fine-tuned fusion **0.68** (measured, optional upgrade). The dynamic baseline — computed from 510 CUAD contracts — runs on top of any of them. ## Status Shippable now on zero-shot + dynamic baseline. Open/optional: trained Ollama model (hook ready above), DeBERTa-0.67 classifier weights (clean-licence accuracy upgrade), merge to `main`.