ClauseGuard — Fine-Tuned LegalBERT Clause Classifier (AmirLGass/clauseguard-legalbert)
ClauseGuard LegalBERT Classifier is a transformer-based sequence classification model fine-tuned on the nlpaueb/legal-bert-base-uncased architecture to categorize legal employment contract clauses into 10 distinct legal categories.
This model serves as the core classification stage in the ClauseGuard AI legal contract intelligence and information extraction pipeline.
Model Details
- Model Name:
AmirLGass/clauseguard-legalbert - Developer / Creator: Amir Bannani (ClauseGuard)
- Base Architecture:
nlpaueb/legal-bert-base-uncased - Model Type: Multi-Class Transformer Sequence Classification Head (
Linear(768 -> 10)) - Primary Language: English (
en) - License: Apache-2.0
10 Legal Categories & Target Classes
The classifier maps input legal clauses into the following 10 target categories (label_id 0 to 9):
| ID | Class Name (employment_category) |
Family Group | Description / Examples |
|---|---|---|---|
0 |
confidentiality |
confidentiality_ip |
Non-disclosure obligations, trade secret protections, proprietary data handling. |
1 |
exclusivity |
restrictive_covenant |
Sole service requirements, exclusive distribution, outside work prohibitions. |
2 |
governing_law |
legal_contractual |
Applicable state/jurisdiction laws and court venue choices. |
3 |
ip_assignment |
confidentiality_ip |
Assignment of inventions, code, patents, copyrights, and works of authorship. |
4 |
liability_indemnity |
legal_contractual |
Indemnification duties, hold harmless agreements, third-party claim defense. |
5 |
no_solicit_customers |
restrictive_covenant |
Prohibitions against approaching or soliciting clients, accounts, or customers. |
6 |
no_solicit_employees |
restrictive_covenant |
Prohibitions against enticing away, hiring, or soliciting staff or contractors. |
7 |
non_compete |
restrictive_covenant |
Non-competition covenants restricting work with competing businesses. |
8 |
other_general |
general |
General notices, audit rights, security protocols, boilerplates. |
9 |
termination_notice |
legal_contractual |
Notice periods, termination types (for cause / without cause), effective dates. |
How to Get Started
You can load and run the model directly in PyTorch using the Hugging Face transformers pipeline or classes:
Quick Inference via pipeline
from transformers import pipeline
# Load fine-tuned ClauseGuard classifier
classifier = pipeline("text-classification", model="AmirLGass/clauseguard-legalbert")
clause_text = (
"During employment and for eighteen (18) months thereafter, the Employee shall not "
"operate or work for any competing business within North America."
)
result = classifier(clause_text)
print(result)
# Output: [{'label': 'non_compete', 'score': 0.9854}]
Advanced Usage with PyTorch
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
# 1. Load model and tokenizer
model_id = "AmirLGass/clauseguard-legalbert"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id)
# 2. Prepare sample legal clause
text = (
"Employee hereby irrevocably assigns and transfers to Employer all right, title, "
"and interest in and to all inventions, code, and patents created during employment."
)
# 3. Tokenize & predict
inputs = tokenizer(text, max_length=256, truncation=True, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=-1)[0]
pred_id = torch.argmax(probs).item()
# Label mapping
labels = [
"confidentiality", "exclusivity", "governing_law", "ip_assignment",
"liability_indemnity", "no_solicit_customers", "no_solicit_employees",
"non_compete", "other_general", "termination_notice"
]
print(f"Predicted Category: {labels[pred_id]} (Confidence: {probs[pred_id].item():.4f})")
Training Setup & Data Processing
- Base Model:
nlpaueb/legal-bert-base-uncased - Input Truncation:
max_length = 256tokens. - Dynamic Batch Padding:
DataCollatorWithPaddingfor batch padding efficiency. - Dataset Partitioning: Document-level grouped splitting (
train,val,test) ensuring zero data leakage across agreement boundaries. - Loss Function: Cross-Entropy Loss over 10 balanced class logits.
Intended Uses & Limitations
Intended Uses
- Automated classification of employment contract clauses into legal domain categories.
- Pre-processing step for structured information extraction pipelines (e.g. with NuExtract 2.0 2B).
- Legal contract risk auditing and compliance checking.
Out-of-Scope Uses
- This model provides automated categorization assistance and does not constitute professional legal advice.
Citation & Acknowledgments
If you use ClauseGuard LegalBERT Classifier in your research or project, please cite:
@misc{clauseguard2026legalbert,
author = {Bannani Amir},
title = {ClauseGuard: Fine-Tuned LegalBERT for Contract Clause Classification},
year = {2026},
publisher = {Hugging Face},
journal = {Hugging Face Model Hub},
howpublished = {\url{https://huggingface.co/AmirLGass/clauseguard-legalbert}}
}