Downloads · 30 days
5
10% of all-time downloads
vaschko/xlm-roberta-base-unfair-clauses
xlm-roberta-base-unfair-clauses is a text classification model from vaschko. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as cc-by-nc-4.0.
A sentence classifier that answers one question: is this sentence a potentially unfair clause? It returns a probability, nothing else. Given a German or English sentence from consumer terms of service, it flags the ki…
Downloads · 30 days
5
10% of all-time downloads
All-time downloads
49
Public
Parameters
278M
1.1 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors1.1 GB · 98%
From the Hugging Face model README
A sentence classifier that answers one question: is this sentence a potentially unfair clause? It returns a probability, nothing else. Given a German or English sentence from consumer terms of service, it flags the kinds of clauses the CLAUDETTE project annotates as unfair: unilateral changes and termination, limitation of liability, jurisdiction and choice-of-law clauses, arbitration, content removal, contract by use, and privacy-related clauses.
The model was built for a bachelor's thesis (2026) as the selection stage of a browser extension that summarizes terms and conditions and highlights red flags. In that pipeline the classifier picks the sentences worth reporting and ranks them; a local LLM then assigns a category and writes the explanation. Code, evaluation harness and training script: https://github.com/yetiiil/SummarizationBenchmark (Testing/Scripts/Evaluation/RedFlags/).
Not intended as legal advice, and not licensed for commercial use (see License).
Each section of a document is split into sentences (with an abbreviation-aware splitter for legal German and English). All sentences are scored; those with a probability of at least 0.85 are kept, sorted by probability, and capped at five per section. The kept sentences are quoted verbatim, so every flag is grounded in the text by construction.
CLAUDETTE multilingual corpus (Drawzeski et al., 2021): terms of service of 25 online platforms, sentence-level annotations for nine unfair clause types and four fairness levels. Only the German and English versions were used. The split follows the corpus and is by company, so no company appears in more than one split.
| Split | Companies | Documents | Sentences | Unfair sentences |
|---|---|---|---|---|
| train | 20 | 40 | 9,858 | 943 (9.6 %) |
| validation | 2 | 4 | 819 | 88 |
| test | 3 (Weebly, Yelp, Zynga) | 6 | 2,065 | 188 |
Positive label: the sentence is annotated potentially_unfair or clearly_unfair. Everything else (untagged, clearly_fair) is negative.
FacebookAI/xlm-roberta-base, with a single-logit classification head (num_labels=1, sigmoid at inference).BCEWithLogitsLoss with pos_weight = negatives / positives (about 9.5), because only 9.6 % of the sentences are positive.threshold.json and history.json in this repository record that choice and the full per-epoch history.cd Testing/Scripts/Evaluation/RedFlags
PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0 python3 classifier_train.py --epochs 10 --batch-size 8 --max-length 192
Training on Apple GPUs is not bit-exact; a retrain gives comparable, not identical numbers (the spread between epochs was about ±0.04 F1).
All figures at threshold 0.85. The CLAUDETTE numbers were measured the way the extension uses the model: whole documents are reconstructed, split by the application's own sentence splitter, scored, and the flagged spans are mapped back to the annotated sentences.
CLAUDETTE test split (DE + EN, 188 annotated unfair sentences)
| Precision | Recall | F1 | |
|---|---|---|---|
| Exact sentence | 0.705 | 0.750 | 0.727 |
| Within one sentence of the annotation | 0.806 | 0.883 | 0.843 |
Precision@5 over the six test documents: 0.867; precision@10: 0.833.
Recall per annotated clause type:
| Clause type | Gold sentences | Recall |
|---|---|---|
| Arbitration | 10 | 0.30 |
| Unilateral change | 26 | 0.73 |
| Content removal | 22 | 0.86 |
| Jurisdiction | 14 | 0.93 |
| Choice of law | 10 | 0.70 |
| Limitation of liability | 70 | 0.77 |
| Unilateral termination | 40 | 0.90 |
| Contract by using | 16 | 0.63 |
| Privacy included | 4 | 0.50 |
External check: LexGLUE UNFAIR-ToS (coastalcph/lex_glue, config unfair_tos, English). This dataset descends from the same project, and 1,779 of its sentences occur verbatim in the training or validation data. Those were removed first; on the remaining 7,351 sentences (834 positive) the model reaches P 0.758 / R 0.729 / F1 0.743. On the overlapping sentences the two corpora agree on the label in 97.4 % of cases, so the label definitions are compatible.
In the shipped pipeline (classifier selects, gemma4:e4b labels and explains), the same test split gives P 0.737 / R 0.702 / F1 0.719. The prompted LLM alone, without the classifier, reached F1 0.305.
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
repo = "vaschko/xlm-roberta-base-unfair-clauses"
tokenizer = AutoTokenizer.from_pretrained(repo)
model = AutoModelForSequenceClassification.from_pretrained(repo).eval()
sentences = [
"We may terminate your account at any time, for any reason, without notice.",
"Diese Bedingungen gelten für alle Bestellungen über unseren Online-Shop.",
]
batch = tokenizer(sentences, truncation=True, max_length=192, padding=True, return_tensors="pt")
with torch.no_grad():
probabilities = torch.sigmoid(model(**batch).logits.squeeze(-1))
for sentence, p in zip(sentences, probabilities.tolist()):
print(f"{p:.2f} {'unfair' if p >= 0.85 else 'ok'} {sentence}")
The threshold of 0.85 is the one tuned on the validation split; lower it to trade precision for recall.
The weights are released under CC BY-NC 4.0: attribution required, non-commercial use only.
The non-commercial restriction is inherited from the training data. The CLAUDETTE multilingual corpus is licensed CC BY-NC 2.5; whether fine-tuned weights are a derivative work of their training data is legally unsettled, and this release takes the conservative reading and passes the restriction on. The base model xlm-roberta-base is MIT licensed.