--- title: ClauseGuard emoji: 🛡️ colorFrom: gray colorTo: gray sdk: gradio sdk_version: "5.23.0" python_version: "3.12" app_file: app.py pinned: false --- # 🛡️ ClauseGuard — AI Contract Analysis **The world's most comprehensive open-source legal contract analysis tool.** ClauseGuard automatically analyzes legal contracts using state-of-the-art NLP models fine-tuned on legal data. ## ✨ Features ### Core Analysis - **41 CUAD Clause Categories** — Detects and classifies clauses across the full [CUAD](https://huggingface.co/datasets/theatticusproject/cuad-qa) taxonomy (Document Name, Parties, Governing Law, Indemnification, Termination, Non-Compete, IP Ownership, etc.) - **4-Tier Risk Scoring** — Critical / High / Medium / Low with visual risk matrix - **Legal NER** — Extracts parties, dates, monetary values, jurisdictions, defined terms - **NLI Contradiction Detection** — Identifies conflicting clauses and missing critical provisions - **PDF / DOCX / TXT Support** — Upload any contract format ### UI/UX - **3-Panel Professional Layout** — Sidebar upload + Main analysis + Summary dashboard - **Document Viewer** — Text with inline entity highlights - **Clause Cards** — Expandable cards with risk badges and descriptions - **Export Reports** — JSON (structured data) and CSV (tabular) downloads - **Color-Coded Risk Badges** — Visual indicators for quick triage ## 🧠 Models Used | Component | Model | |-----------|-------| | Clause Classification | `Mokshith31/legalbert-contract-clause-classification` (LoRA on `nlpaueb/legal-bert-base-uncased`) | | Fallback Detection | Regex patterns covering 15+ clause types | | NER | Rule-based with 7 entity types (dates, money, parties, jurisdictions, defined terms) | | NLI | Heuristic contradiction detection across 5 conflict patterns | ## 📚 Datasets - [CUAD](https://huggingface.co/datasets/theatticusproject/cuad-qa) — 510 contracts, 13K annotations, 41 clause categories - [LegalBench](https://huggingface.co/datasets/nguha/legalbench) — 322 legal reasoning tasks - [LexGLUE](https://huggingface.co/datasets/coastalcph/lex_glue) — Unfair Terms of Service classification ## 🚀 Usage 1. Upload a contract (PDF, DOCX, or TXT) or paste text directly 2. Click **Analyze Contract** 3. View results across tabs: Document, Clauses, Entities, Contradictions 4. Download JSON/CSV reports ## ⚠️ Disclaimer *Not legal advice. ClauseGuard is an AI-powered analysis tool for informational purposes only. Always consult a qualified attorney for legal decisions.* ## 🔗 Links - [Space](https://huggingface.co/spaces/gaurv007/ClauseGuard) - [CUAD Paper](https://arxiv.org/abs/2103.06268) - [LegalBench](https://huggingface.co/datasets/nguha/legalbench)