coastalcph/lex_glue
Viewer • Updated • 237k • 33.3k • 75
How to use Agreemind/modernbert-unfair-tos with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="Agreemind/modernbert-unfair-tos") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("Agreemind/modernbert-unfair-tos")
model = AutoModelForSequenceClassification.from_pretrained("Agreemind/modernbert-unfair-tos")ModernBERT fine-tuned for UNFAIR-ToS classification
This model is fine-tuned on the LexGLUE UNFAIR-ToS dataset to detect unfair clauses in Terms of Service documents.
Base Model: answerdotai/ModernBERT-base
| Metric | Score |
|---|---|
| Exact Match Accuracy | 70.6% |
| Micro-F1 | 0.79 |
| Precision | 0.98 |
The model classifies text into 8 risk categories:
| ID | Category |
|---|---|
| 0 | Limitation of liability |
| 1 | Unilateral termination |
| 2 | Unilateral change |
| 3 | Content removal |
| 4 | Contract by using |
| 5 | Choice of law |
| 6 | Jurisdiction |
| 7 | Arbitration |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name = "Agreemind/modernbert-unfair-tos"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
text = "We reserve the right to terminate your account at any time."
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
with torch.no_grad():
outputs = model(**inputs)
probs = torch.sigmoid(outputs.logits)
# Get predictions
labels = ["Limitation of liability", "Unilateral termination", "Unilateral change",
"Content removal", "Contract by using", "Choice of law", "Jurisdiction", "Arbitration"]
for label, prob in zip(labels, probs[0]):
if prob > 0.5:
print(f"{label}: {prob:.2%}")
@misc{agreemind-unfair-tos,
author = {Agreemind},
title = {modernbert-unfair-tos},
year = {2024},
publisher = {HuggingFace},
url = {https://huggingface.co/Agreemind/modernbert-unfair-tos}
}
Base model
answerdotai/ModernBERT-base