Spaces:
Runtime error
Runtime error
| # Team test runbook β `dynamic-finetuned` | |
| The full product: dynamic baseline + fine-tuned classifier (fusion) + LLM | |
| extraction + traceability + features. Here's how to run and what to verify. | |
| ## 1. Get the branch + the model | |
| ```bash | |
| git fetch && git checkout dynamic-finetuned | |
| # the fine-tuned weights are gitignored β drop the folder in by hand: | |
| # backend/finetune/legalbert-sent-cuad/ (LegalBERT 0.70, demo) | |
| # backend/finetune/deberta-sent-cuad/ (DeBERTa 0.67, deploy β clean licence) | |
| ``` | |
| ## 2. Run it | |
| ```bash | |
| ./run.sh # backend :8000, frontend :5173 | |
| ``` | |
| Pick the classifier with env vars (backend): | |
| | Goal | Command | | |
| |---|---| | |
| | Demo, most accurate | `CLASSIFIER=fusion CORE_LLM_BACKEND=ollama uvicorn app.main:app --port 8000` | | |
| | Deploy, clean licence | `CLASSIFIER=fusion LEGALBERT_MODEL_DIR=finetune/deberta-sent-cuad uvicorn app.main:app --port 8000` | | |
| | No models / safest | `CLASSIFIER=rules CORE_LLM_BACKEND=rules uvicorn app.main:app --port 8000` | | |
| | LLM extraction | also: `ollama serve` + `ollama pull qwen2.5:7b` once | | |
| `fusion` falls back to zero-shot β rules automatically if a model is missing, | |
| so it always runs. | |
| ## 3. What to verify (the demo path) | |
| 1. Upload `data/samples/demo_msa.pdf` β register + key dates + ranked risks appear. | |
| 2. **Risks tab:** "Liability/direct damages uncapped" (sev ~85), "Auto-renewal | |
| 90-day notice" β finding shows **"β75th percentile of 41 real contracts"**. | |
| 3. Click any finding β the exact clause **highlights in the PDF** (traceability). | |
| 4. **Key dates:** non-renewal notice deadline computed (e.g. 2029-04-01) β | |
| "Add to calendar" downloads an .ics; "Excel register" downloads .xlsx. | |
| 5. Upload the **scanned** copy (`demo_msa_scanned.pdf`) β identical findings via OCR. | |
| 6. **Chat:** ask "what is the liability cap?" β grounded answer with clause cite. | |
| 7. **Compare / Heatmap / Portfolio / Defined terms** tabs render. | |
| ## 4. Measure accuracy (the slide number) | |
| ```bash | |
| cd backend | |
| ../.venv/bin/python -m eval.run_eval --classifier legalbert --limit 50 # ~0.70 (LegalBERT) | |
| ../.venv/bin/python -m eval.run_eval --classifier zeroshot --limit 50 # 0.61 (zero-shot) | |
| ../.venv/bin/python -m eval.run_eval --classifier rules --limit 50 # 0.50 (rules) | |
| ``` | |
| ## 5. Safety check (no regression) | |
| ```bash | |
| cd backend && ../.venv/bin/python tests/test_risk_golden.py # must print "golden test OK" | |
| ``` | |
| ## Notes | |
| - Deploy on **DeBERTa 0.67 (MIT)**, not LegalBERT (CC-BY-SA). Same code, one env var. | |
| - The dynamic baseline is the differentiator β it works on any classifier. | |