Text Classification
Transformers
Safetensors
English
legal-nlp
legal-bert
contract-analysis
clause-classification
legaltech
contractguard
Instructions to use AnuragBodkhe/contractguard-clause-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AnuragBodkhe/contractguard-clause-classifier with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="AnuragBodkhe/contractguard-clause-classifier")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("AnuragBodkhe/contractguard-clause-classifier", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,13 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# ContractGuard Clause Classifier
|
| 2 |
|
| 3 |
A fine-tuned Legal-BERT model for clause-level classification of contracts.
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
## Model Description
|
| 6 |
|
| 7 |
-
|
| 8 |
-
contract
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
|
| 12 |
## Intended Use
|
| 13 |
|
|
@@ -15,76 +66,122 @@ This model is intended for:
|
|
| 15 |
|
| 16 |
- Contract clause classification
|
| 17 |
- Legal document analysis
|
| 18 |
-
- Contract intelligence
|
|
|
|
| 19 |
- Clause-level downstream risk analysis
|
| 20 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
The
|
|
|
|
| 23 |
|
| 24 |
-
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
## Training Data
|
| 35 |
|
| 36 |
-
The
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
-
|
| 39 |
-
- LEDGAR
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
## Evaluation
|
| 45 |
|
| 46 |
-
|
| 47 |
|
| 48 |
-
| Metric |
|
| 49 |
|---|---:|
|
| 50 |
-
| Macro F1 | 0.8923 |
|
| 51 |
-
| Expected Calibration Error (ECE) | 0.0391 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
-
|
|
|
|
| 54 |
|
| 55 |
-
|
| 56 |
-
and a confidence score.
|
| 57 |
|
| 58 |
-
|
|
|
|
| 59 |
|
| 60 |
-
|
|
|
|
| 61 |
|
| 62 |
-
|
| 63 |
|
| 64 |
-
|
| 65 |
-
- Jurisdictions
|
| 66 |
-
- Drafting styles
|
| 67 |
-
- Languages
|
| 68 |
-
- Clauses outside the training distribution
|
| 69 |
|
| 70 |
-
|
| 71 |
-
|
| 72 |
|
| 73 |
-
|
|
|
|
| 74 |
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
|
| 79 |
-
|
| 80 |
|
| 81 |
-
|
| 82 |
|
| 83 |
-
|
| 84 |
|
| 85 |
-
|
| 86 |
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
license: other
|
| 5 |
+
library_name: transformers
|
| 6 |
+
pipeline_tag: text-classification
|
| 7 |
+
base_model: nlpaueb/legal-bert-base-uncased
|
| 8 |
+
tags:
|
| 9 |
+
- legal-nlp
|
| 10 |
+
- legal-bert
|
| 11 |
+
- contract-analysis
|
| 12 |
+
- clause-classification
|
| 13 |
+
- legaltech
|
| 14 |
+
- text-classification
|
| 15 |
+
- contractguard
|
| 16 |
+
datasets:
|
| 17 |
+
- cuad
|
| 18 |
+
- ledgar
|
| 19 |
+
metrics:
|
| 20 |
+
- f1
|
| 21 |
+
---
|
| 22 |
+
|
| 23 |
# ContractGuard Clause Classifier
|
| 24 |
|
| 25 |
A fine-tuned Legal-BERT model for clause-level classification of contracts.
|
| 26 |
|
| 27 |
+
This model is part of **ContractGuard AI**, a LegalTech platform designed to
|
| 28 |
+
analyze contracts at the clause level and provide AI-assisted contractual
|
| 29 |
+
risk analysis.
|
| 30 |
+
|
| 31 |
+
> **Not legal advice.** ContractGuard AI provides AI-assisted contract analysis
|
| 32 |
+
> for informational and decision-support purposes. Model outputs are predictions,
|
| 33 |
+
> not legal conclusions. Material decisions should be reviewed by a qualified
|
| 34 |
+
> professional in the relevant jurisdiction.
|
| 35 |
+
|
| 36 |
+
---
|
| 37 |
+
|
| 38 |
## Model Description
|
| 39 |
|
| 40 |
+
The ContractGuard Clause Classifier is a fine-tuned transformer encoder designed
|
| 41 |
+
to classify individual contract clauses into predefined clause categories.
|
| 42 |
+
|
| 43 |
+
The model is used as the clause-classification component of the ContractGuard AI
|
| 44 |
+
multi-model architecture.
|
| 45 |
+
|
| 46 |
+
### Model Details
|
| 47 |
+
|
| 48 |
+
| Property | Value |
|
| 49 |
+
|---|---|
|
| 50 |
+
| Model | ContractGuard Clause Classifier |
|
| 51 |
+
| Version | 2.0 |
|
| 52 |
+
| Task | Clause Classification |
|
| 53 |
+
| Architecture | Fine-tuned Transformer Encoder |
|
| 54 |
+
| Base Model | `nlpaueb/legal-bert-base-uncased` |
|
| 55 |
+
| Library | Hugging Face Transformers |
|
| 56 |
+
| Domain | Legal / Contract Documents |
|
| 57 |
+
| Language | English |
|
| 58 |
+
| Number of Clause Types | 40 |
|
| 59 |
+
| Model Format | Safetensors |
|
| 60 |
|
| 61 |
+
---
|
| 62 |
|
| 63 |
## Intended Use
|
| 64 |
|
|
|
|
| 66 |
|
| 67 |
- Contract clause classification
|
| 68 |
- Legal document analysis
|
| 69 |
+
- Contract intelligence
|
| 70 |
+
- LegalTech applications
|
| 71 |
- Clause-level downstream risk analysis
|
| 72 |
+
- Contract review assistance
|
| 73 |
+
- Research involving legal NLP and contract understanding
|
| 74 |
+
|
| 75 |
+
The model can be integrated into a larger contract-analysis pipeline where
|
| 76 |
+
clause classification is used as one input to subsequent analysis stages.
|
| 77 |
+
|
| 78 |
+
---
|
| 79 |
+
|
| 80 |
+
## How ContractGuard Uses This Model
|
| 81 |
+
|
| 82 |
+
ContractGuard AI uses multiple specialized models rather than relying on a
|
| 83 |
+
single model for every task.
|
| 84 |
+
|
| 85 |
+
The overall architecture contains separate components for:
|
| 86 |
+
|
| 87 |
+
1. Clause classification
|
| 88 |
+
2. Risk classification
|
| 89 |
+
3. Legal Named Entity Recognition
|
| 90 |
+
4. Retrieval embeddings
|
| 91 |
+
5. Contract Natural Language Inference
|
| 92 |
+
|
| 93 |
+
This model is responsible specifically for **clause classification**.
|
| 94 |
|
| 95 |
+
The predicted clause type can subsequently be used by downstream components
|
| 96 |
+
for contractual risk analysis and rule evaluation.
|
| 97 |
|
| 98 |
+
---
|
| 99 |
|
| 100 |
+
## Classification Task
|
| 101 |
+
|
| 102 |
+
The model predicts **one of 40 predefined clause types** for an input contract
|
| 103 |
+
clause.
|
| 104 |
+
|
| 105 |
+
The predicted clause type is accompanied by a model confidence score.
|
| 106 |
+
|
| 107 |
+
The clause classification output is not itself a legal conclusion.
|
| 108 |
+
|
| 109 |
+
---
|
| 110 |
|
| 111 |
## Training Data
|
| 112 |
|
| 113 |
+
The clause classifier was trained using:
|
| 114 |
+
|
| 115 |
+
- **CUAD**
|
| 116 |
+
- **LEDGAR**
|
| 117 |
+
|
| 118 |
+
The training pipeline uses document-level splitting rather than randomly
|
| 119 |
+
splitting individual clauses.
|
| 120 |
+
|
| 121 |
+
This is intended to reduce data leakage caused by clauses from the same
|
| 122 |
+
document appearing in both training and evaluation sets.
|
| 123 |
|
| 124 |
+
---
|
|
|
|
| 125 |
|
| 126 |
+
## Base Model
|
| 127 |
+
|
| 128 |
+
The model was fine-tuned from:
|
| 129 |
+
|
| 130 |
+
`nlpaueb/legal-bert-base-uncased`
|
| 131 |
+
|
| 132 |
+
Legal-BERT provides a transformer representation specialized for legal-domain
|
| 133 |
+
text, which is used as the foundation for this clause classification model.
|
| 134 |
+
|
| 135 |
+
---
|
| 136 |
|
| 137 |
## Evaluation
|
| 138 |
|
| 139 |
+
### Version 2.0 Results
|
| 140 |
|
| 141 |
+
| Metric | Result |
|
| 142 |
|---|---:|
|
| 143 |
+
| Macro F1 | **0.8923** |
|
| 144 |
+
| Expected Calibration Error (ECE) | **0.0391** |
|
| 145 |
+
|
| 146 |
+
The model was evaluated on a held-out test split as part of the ContractGuard
|
| 147 |
+
training and evaluation pipeline.
|
| 148 |
+
|
| 149 |
+
### Why Macro F1
|
| 150 |
|
| 151 |
+
Macro F1 gives equal weight to each class and is therefore useful when the
|
| 152 |
+
classification taxonomy contains classes with different frequencies.
|
| 153 |
|
| 154 |
+
### Expected Calibration Error
|
|
|
|
| 155 |
|
| 156 |
+
ECE measures the difference between model confidence and observed accuracy
|
| 157 |
+
across confidence ranges.
|
| 158 |
|
| 159 |
+
It is used separately from the classification score because confidence and
|
| 160 |
+
classification performance represent different properties of the model.
|
| 161 |
|
| 162 |
+
---
|
| 163 |
|
| 164 |
+
## Version 2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
|
| 166 |
+
ContractGuard Clause Classifier version 2.0 expanded training coverage by
|
| 167 |
+
combining CUAD with LEDGAR.
|
| 168 |
|
| 169 |
+
The project documentation reports that the earlier version had coverage
|
| 170 |
+
limitations across the full 40-class taxonomy.
|
| 171 |
|
| 172 |
+
Version 2.0 expanded coverage to additional clause types and was activated
|
| 173 |
+
only after comparison against the baseline on a real contract showed no
|
| 174 |
+
finding was lost.
|
| 175 |
|
| 176 |
+
---
|
| 177 |
|
| 178 |
+
## Input
|
| 179 |
|
| 180 |
+
The model expects legal/contractual text representing an individual clause.
|
| 181 |
|
| 182 |
+
Example:
|
| 183 |
|
| 184 |
+
```text
|
| 185 |
+
The Contractor shall indemnify and hold harmless the Company from any claims,
|
| 186 |
+
losses, damages, liabilities, and expenses arising from the Contractor's
|
| 187 |
+
performance of the Services.
|