Instructions to use Timperator/xlm-r-biasscanner-ellul with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Timperator/xlm-r-biasscanner-ellul with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Timperator/xlm-r-biasscanner-ellul")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Timperator/xlm-r-biasscanner-ellul", device_map="auto") - Notebooks
- Google Colab
- Kaggle
xlm-r-biasscanner-ellul
xlm-r-biasscanner-ellul is a multilingual, multi-task model based on XLM-RoBERTa-base. It was trained on 3,668 human-annotated German and English news sentences to detect news bias, classify bias types, and estimate bias strength.
The model uses the ELLUL dataset and the Menzner-Leidner taxonomy of 38 fine-grained news-bias types and propaganda techniques.
Table of Contents
- Model Details
- Uses and Limitations
- Training Details
- Evaluation
- Technical Specifications
- Citation
- Model Card Authors
- Model Card Contact
- How to Get Started with the Model
Model Details
Model Description
- Developed by: Tim Menzner
- Funded by: High-Tech Agenda Bayern (compute support through HPC4AI on the FAU-HPC cluster)
- Shared by: Tim Menzner
- Model type: Multi-task encoder classifier (XLM-RoBERTa-base with four prediction heads)
- Languages: German, English
- License: Apache-2.0
- Fine-tuned from: FacebookAI/xlm-roberta-base
Architecture and Outputs
The model consists of a shared XLM-RoBERTa encoder and four parallel prediction heads:
| Head | Task | Output |
|---|---|---|
binary |
Binary bias detection | Probability of a sentence being biased |
types |
Multi-label classification | Probabilities for 38 fine-grained bias types |
strength |
Ordinal regression | Bias strength from 0 (none) to 1 (extreme) |
primary |
Multi-class classification | One dominant bias type or non-biased |
The strength head uses 10 cumulative CORAL levels. The primary head predicts one of 39 classes (38 bias types plus non-biased).
Default classification thresholds:
- Binary classification: 0.5
- Fine-grained type classification: 0.35 per type
This is not a standard
transformerssequence-classification checkpoint.The architecture consists of one XLM-RoBERTa encoder and four custom prediction heads. The uploaded
model.ptcontains a raw PyTorchstate_dictwith all model weights.Loading via
AutoModelForSequenceClassification.from_pretrained()will not work. Use the custom loading procedure in How to Get Started with the Model.
Model Sources
- Taxonomy paper: Menzner & Leidner (2026), The Table of Media Bias Elements.
- Training dataset: ELLUL (forthcoming; will be published separately on Hugging Face).
- Project: BiasScanner.
Uses and Limitations
The model is intended for sentence-level analysis of news bias in German and English news text.
It can be used without additional fine-tuning to:
- Detect potentially biased sentences.
- Identify fine-grained bias types and propaganda techniques.
- Estimate bias strength on an ordinal scale.
- Predict the dominant bias type of a sentence.
Sentence-level predictions can be aggregated to analyse entire articles, publications, or larger news corpora. The model is also used as part of the BiasScanner add-on and project.
The model is not intended for general-purpose fake-news detection or fact-checking. The ELLUL dataset it was trained on primarily consists of sentences gathered from news articles; it might perform differently on other domains.
Predictions should not be treated as objective or definitive judgments. This is not only because of varying model output quality, but also because of the task itself. News bias remains, to an extent, a subjective phenomenon. Even when formulating concrete annotation guidelines and distinct bias types, human language remains nuanced and cannot be entirely captured by any such framework. All the more so when we consider that we all bring our own biases to the table, the authors and annotators of any framework and dataset are no exception. Even if one places great importance on trying to sideline these biases, it is probably an unattainable ideal to assume that we can produce any work completely free from them. Our ultimate goal with our BiasScanner models and the add-on is therefore not to provide a definite judgement about what is biased or not but rather to support discussion around bias and propaganda in the media we all consume. When somebody disagrees with an output one of our models gives, but arrives at this disagreement by critical reflection of the media which was analyzed, it served its purpose.
For research use, keep the default thresholds (binary: 0.5; types: 0.35) or recalibrate them using independent held-out data.
Training Details
Training Data
The model was trained on ELLUL, a bilingual dataset of 3,668 human-annotated German and English news sentences.
| Label | Number of sentences |
|---|---|
| Biased | 1,917 |
| Unbiased | 1,751 |
| Total | 3,668 |
The dataset uses the Menzner-Leidner taxonomy of 38 fine-grained bias types and propaganda techniques, with additional annotations for primary type and bias strength.
The annotation process, dataset composition, annotation guidelines and other dataset-specific details are documented separately in the ELLUL dataset card.
ELLUL will be published separately on Hugging Face. The dataset is not included in this model repository, and this model card does not grant redistribution rights to the underlying dataset or source texts.
Training Procedure
Model and hyperparameter selection was conducted through five-fold cross-validation within an 80% development partition. The remaining 20% (n = 733) was held out and evaluated only after model selection.
Splits were stratified by language and binary bias status and constructed without data leakage between partitions.
After evaluation and model selection, the selected training setup was used to refit the final model on all 3,668 annotated sentences. The uploaded checkpoint is this full-data corpus-inference model.
Preprocessing
The packaged XLM-RoBERTa tokenizer is used with a maximum sequence length of 512 tokens, including special tokens.
Of the 3,668 training sentences, 11 exceed 256 tokens and one sentence (646 tokens) exceeds the 512-token limit and is truncated.
Hyperparameters
| Parameter | Value |
|---|---|
| Training epochs | 5 |
| Batch size | 32 |
| Optimizer | AdamW |
| Learning rate | 2e-5 |
| Weight decay | 0.1 |
| Warmup ratio | 0.1 |
| Learning-rate scheduler | Linear |
| Gradient clipping | 1.0 |
| Mixed precision | FP16 AMP |
| Maximum sequence length | 512 |
The joint multi-task objective combines:
- Binary cross-entropy for binary bias detection.
- Focal binary cross-entropy for multi-label type classification (Ξ³ = 2.0, Ξ± cap = 3.0).
- CORAL ordinal loss for strength estimation.
- Class-weighted cross-entropy for primary type classification (class-weight cap = 3.0).
Loss weights (binary, types, strength, primary): 1.0 / 1.0 / 1.0 / 0.5.
Evaluation
Testing Data, Factors and Metrics
Testing Data
Evaluation was conducted on an untouched held-out 20% partition of ELLUL (n = 733).
The held-out partition contains:
- 383 biased sentences.
- 350 unbiased sentences.
The results were obtained using the 80%-trained evaluation checkpoint, not the uploaded model trained on the complete dataset.
The evaluation checkpoint and the final uploaded checkpoint follow the same selected training recipe, thresholds and inference settings. The uploaded checkpoint was subsequently refitted on all 3,668 annotated sentences after the held-out evaluation.
The reported results therefore serve as a proxy for the final full-data checkpoint.
Factors
Results are reported overall and separately for German and English. The evaluation covers binary detection, fine-grained multi-label classification, ordinal strength estimation and derived category-level classification.
Metrics
| Task | Metrics |
|---|---|
| Binary detection | F1 (biased class), precision, recall, ROC-AUC, MCC |
| Strength estimation | MAE (0β1 scale), Spearman Ο |
| Fine-grained classification (38 types) | Micro-F1, Macro-F1 |
| Category aggregation (8 categories) | Micro-F1, Macro-F1 |
Binary precision, recall and F1 are calculated for the positive class (biased), using the default threshold of 0.5.
Fine-grained type scores use the threshold of 0.35.
No separate quantitative evaluation result for the primary classification head is reported here.
Results
Overall Results
| Task | Metric | Score |
|---|---|---|
| Binary | F1 (biased class) | 0.890 |
| Binary | Precision (biased class) | 0.942 |
| Binary | Recall (biased class) | 0.843 |
| Binary | ROC-AUC | 0.963 |
| Binary | MCC | 0.787 |
| Strength | MAE (0β1) | 0.112 |
| Strength | Spearman Ο | 0.850 |
| Types (38) | Micro-F1 (threshold 0.35) | 0.273 |
| Types (38) | Macro-F1 (threshold 0.35) | 0.199 |
| Categories (8) | Micro-F1 | 0.545 |
| Categories (8) | Macro-F1 | 0.501 |
Binary Confusion Matrix
Held-out partition (n = 733 sentences).
Positive class: biased. Classification threshold: 0.5.
| Actual / Predicted | Predicted biased | Predicted unbiased |
|---|---|---|
| Actually biased | TP = 323 | FN = 60 |
| Actually unbiased | FP = 20 | TN = 330 |
Performance by Language
| Metric | German | English |
|---|---|---|
| Binary F1 | 0.886 | 0.892 |
| Binary ROC-AUC | 0.894 | 0.972 |
| Binary MCC | 0.593 | 0.824 |
| Types Macro-F1 | 0.174 | 0.210 |
| Strength Spearman Ο | 0.737 | 0.844 |
Summary
Binary detection and bias-strength estimation show promising performance.
Fine-grained 38-type classification remains substantially more challenging, especially for rare and underrepresented types.
Aggregating fine-grained predictions into eight broader categories improves classification performance at the cost of granularity. These categories are derived post-hoc from the fine-grained predictions and are not directly trained objectives.
German performance trails English performance, particularly in binary MCC and strength estimation.
Technical Specifications
Model Architecture
The model uses a single XLM-RoBERTa-base encoder with four parallel prediction heads.
| Component | Specification |
|---|---|
| Backbone | XLM-RoBERTa-base |
| Encoder layers | 12 |
| Hidden size | 768 |
| Attention heads | 12 |
| Vocabulary size | 250,002 |
| Pooling | First token ([CLS]) |
| Binary head | 1 logit |
| Types head | 38 logits |
| Strength head | 10 cumulative CORAL logits |
| Primary head | 39 logits |
All four prediction heads share the same encoder representation.
Compute Infrastructure
Hardware
- GPU: Single NVIDIA A100 (40 GB).
- Cluster: FAU-HPC cluster "Alex" (NHR@FAU).
- Job management: SLURM.
Software
- Python: 3.12.
- PyTorch: 2.13.0.
- Transformers: 5.15.1.
- Hugging Face Hub: 1.28.0.
Compute support was provided through HPC4AI and the High-Tech Agenda Bayern.
Citation
Please cite the taxonomy paper when using the model in research.
APA
Menzner, T., & Leidner, J. L. (2026). The Table of Media Bias Elements: A sentence-level taxonomy of media bias types and propaganda techniques. arXiv:2601.05358.
https://arxiv.org/abs/2601.05358
BibTeX
@article{menzner2026table,
title = {The Table of Media Bias Elements: A sentence-level taxonomy of media bias types and propaganda techniques},
author = {Menzner, Tim and Leidner, Jochen L.},
journal = {arXiv preprint arXiv:2601.05358},
year = {2026},
url = {https://arxiv.org/abs/2601.05358}
}
Model Card Authors
Tim Menzner
Model Card Contact
For questions or feedback, please use the Discussions tab of this Hugging Face model repository.
How to Get Started with the Model
Requirements: torch, transformers, huggingface_hub.
The following example loads the custom architecture and exposes predictions from all four heads:
import json
import torch
import torch.nn as nn
from pathlib import Path
from huggingface_hub import snapshot_download
from transformers import AutoConfig, AutoModel, AutoTokenizer
local_dir = Path(
snapshot_download("Timperator2/xlm-r-biasscanner-ellul")
)
cfg = json.loads((local_dir / "config.json").read_text())
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
class MultiTaskBias(nn.Module):
"""Custom multi-task XLM-R classifier."""
def __init__(self, backbone, n_types, n_primary, n_strength=10):
super().__init__()
self.backbone = backbone
h = backbone.config.hidden_size
self.head_binary = nn.Linear(h, 1)
self.head_types = nn.Linear(h, n_types)
self.head_strength = nn.Linear(h, n_strength)
self.head_primary = nn.Linear(h, n_primary)
def forward(self, input_ids, attention_mask):
out = self.backbone(
input_ids=input_ids,
attention_mask=attention_mask
)
pooled = out.last_hidden_state[:, 0]
return {
"binary": self.head_binary(pooled).squeeze(-1),
"types": self.head_types(pooled),
"strength": self.head_strength(pooled),
"primary": self.head_primary(pooled),
}
backbone_cfg = AutoConfig.from_pretrained(local_dir / "backbone")
backbone = AutoModel.from_config(backbone_cfg).float()
model = MultiTaskBias(
backbone,
cfg["n_types"],
cfg["n_primary_classes"],
cfg["n_strength_levels"]
)
state = torch.load(
local_dir / "model.pt",
map_location="cpu",
weights_only=True
)
model.load_state_dict(state)
model.to(device).eval()
tokenizer = AutoTokenizer.from_pretrained(local_dir / "tokenizer")
sentences = [
"Taylor Swift Scores Win Over Donald Trump",
]
batch = tokenizer(
sentences,
return_tensors="pt",
padding=True,
truncation=True,
max_length=512
).to(device)
with torch.no_grad():
out = model(**batch)
# Binary predictions
binary_probs = out["binary"].sigmoid().cpu()
is_biased = binary_probs >= 0.5
# Fine-grained multi-label predictions (38 types, per-type threshold)
type_probs = out["types"].sigmoid().cpu()
flagged_types = type_probs > cfg["types_threshold"]
# Bias strength: expected strength in [0, 1] β mean of the sigmoid
# over the 10 cumulative CORAL logits
strength = out["strength"].sigmoid().mean(dim=-1).cpu()
# Primary class predictions (39 classes): index 0 = no primary bias,
# classes 1..38 map to cfg["primary_vocab"][idx - 1]
primary_probs = out["primary"].softmax(dim=-1).cpu()
primary_idx = primary_probs.argmax(dim=-1)
primary_labels = [
None if idx == 0 else cfg["primary_vocab"][idx - 1]
for idx in primary_idx.tolist()
]
The example decodes the outputs with the production conventions: the strength is the mean of the sigmoid over the 10 cumulative CORAL logits (expected strength in [0, 1]), and primary class index 0 means no primary bias, while classes 1β38 map to the entries of primary_vocab in order.
- Downloads last month
- -
Model tree for Timperator/xlm-r-biasscanner-ellul
Base model
FacebookAI/xlm-roberta-base