CoolFace
Modelpublic

Agreemind/lexglue-legalbert-unfair-tos

sourceHugging Facemitupdated 8mo agoView on Hugging Face
0likes17downloads
Model Card

lexglue-legalbert-unfair-tos

Legal-BERT fine-tuned on LexGLUE UNFAIR-ToS — matches published benchmark

Model Description

This model is fine-tuned on the LexGLUE UNFAIR-ToS benchmark dataset to detect unfair clauses in Terms of Service documents.

Base Model: nlpaueb/legal-bert-base-uncased Training: Standard BCEWithLogitsLoss, lr=3e-5, batch_size=8, linear scheduler, up to 20 epochs with early stopping (matching Chalkidis et al., 2022)

Performance

Evaluated on the official LexGLUE test set (1,607 samples) using the paper's evaluation methodology (includes implicit "fair" class in micro-F1 computation).

MetricScore
Micro-F1 (LexGLUE method)96.0
Macro-F1 (LexGLUE method)84.1
Exact Match Accuracy95.7%

Comparison with LexGLUE Leaderboard

Modelμ-F1m-F1
Legal-BERT (LexGLUE paper)96.083.0
CaseLaw-BERT (LexGLUE paper)96.082.3
RoBERTa-large (LexGLUE paper)95.881.6
lexglue-legalbert-unfair-tos (ours)96.084.1

Risk Categories

The model classifies text into 8 types of potentially unfair clauses:

IDCategoryDescription
0Limitation of liabilityLimits the provider's legal responsibility
1Unilateral terminationProvider may terminate without clear cause
2Unilateral changeTerms can change with minimal notice
3Content removalProvider may remove user content
4Contract by usingAgreement implied by using the service
5Choice of lawSpecifies governing jurisdiction's law
6JurisdictionSpecifies where disputes are handled
7ArbitrationRequires arbitration instead of court

Usage

python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

model_id = "Agreemind/lexglue-legalbert-unfair-tos"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id)

labels = [
    "Limitation of liability", "Unilateral termination",
    "Unilateral change", "Content removal",
    "Contract by using", "Choice of law",
    "Jurisdiction", "Arbitration",
]

text = "We may terminate your account at any time without notice."
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)

with torch.no_grad():
    probs = torch.sigmoid(model(**inputs).logits).squeeze()

for label, prob in sorted(zip(labels, probs), key=lambda x: x[1], reverse=True):
    if prob > 0.5:
        print(f"  {label}: {prob:.3f}")

Citation

If you use this model, please cite:

bibtex
@article{chalkidis2022lexglue,
  title={LexGLUE: A Benchmark Dataset for Legal Language Understanding in English},
  author={Chalkidis, Ilias and Jana, Abhik and Hartung, Dirk and Bommarito, Michael and Androutsopoulos, Ion and Katz, Daniel Martin and Aletras, Nikolaos},
  journal={arXiv preprint arXiv:2110.00976},
  year={2022}
}

License

MIT