Spaces:
Runtime error
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)
APP_PASSWORD=choose-a-password docker compose up -d --build
# app -> http://<server>: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)
- Create it in Ollama (e.g. from your GGUF + Modelfile):
ollama create contract-llm -f Modelfile - Point the app at it:
CORE_LLM_MODEL_OLLAMA=contract-llm CORE_LLM_BACKEND=ollama docker compose up -dNo 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
curl -fsS http://<server>: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.