german_politic_EuroBERT-210m
This classifier predicts whether a German text is political (politic) or not (other), reading up to 8,192 tokens of context. It is EuroBERT/EuroBERT-210m fine-tuned on SinclairSchneider/trainset_political_text_yes_no_german, the same 234,978 texts used for german_politic_DeBERTa-v2-base. The DeBERTa model reads at most 512 tokens.
The training script is in this repository: train.py.
Related paper: Ideology Prediction of German Political Texts (Schneider, Steuber, Schneider & Dreo Rodosek, ICWSM 2026). The paper uses the DeBERTa version of this classifier as the pre-filter of its ideology pipeline (threshold 0.8). This EuroBERT model is a long-context alternative trained on the same data.
Summary of results:
- On a held-out split of its training data, the model reaches 99.6% accuracy / 0.996 weighted F1.
- On real-world German news (10kGNAD) it misses only 1 of 2,524 political articles.
- Like the DeBERTa model, it labels most non-political news as political: business, science and panorama 99.8%, media 97%, web/tech 91%.
- It handles everyday texts (forum posts, reviews, hobbies) much better than the DeBERTa model: 17 of 19 vs. 13 of 19 hand-written examples correct.
- It reacts strongly to hard line breaks. Text wrapped every ~70 characters is classified as
other. - See Evaluation.
[!NOTE] Loading. On 2026-11-09 the output layer was renamed from
out_proj(its name in the March 2025 EuroBERT code) toclassifier(its name in the current EuroBERT code and in native Transformers). The weights are unchanged and give the same predictions as before.
- Transformers ≥ 5.3 has native EuroBERT support: load the model like any other and don't pass
trust_remote_code=True, which fails there withKeyError: 'default'. Tested with 5.15.- Transformers 4.x needs
trust_remote_code=Trueand an explicitly loaded tokenizer, see Older Transformers versions. Tested with 4.49.- Transformers 5.0–5.2 cannot load it: there is no native EuroBERT yet, and the remote code fails with
KeyError: 'default'(tested with 5.2).Revisions up to
b9c36destill call the layerout_proj. Loaded the normal way, they get a randomly initialized output layer without any error, so use the current revision.
[!IMPORTANT] Before using the model, note:
- Normalize whitespace before classifying. Line breaks are visible to the model, and the
otherclass in training was dominated by hard-wrapped Project Gutenberg paragraphs. Hard-wrapping a political news article at 70 characters flips it tootherin 94% of cases. For texts of 20 lines or more it flips nearly always; very short texts are less affected. Text extracted from PDFs, e-mails or poems has the same pattern." ".join(text.split())removes the effect.- Expect it to over-include non-political news. See Evaluation.
Quick start
Tested with transformers 5.15 and torch 2.13. Any Transformers version from 5.3 on should work.
from transformers import pipeline
political_classifier = pipeline("text-classification", model="SinclairSchneider/german_politic_EuroBERT-210m")
political_classifier("Trump und Putin einigen sich auf begrenzte Waffenruhe")
# [{'label': 'politic', 'score': 0.9991077780723572}]
political_classifier("Franck Ribéry und Arjen Robben feiern beim \"Beckenbauer Cup\" ihr Comeback beim FC Bayern. Sie präsentieren sich wie zu besten Zeiten und wecken eine große Sehnsucht beim Rekordmeister.")
# [{'label': 'other', 'score': 0.9865761995315552}]
political_classifier("Mein Laptop startet seit dem letzten Update nicht mehr richtig, hat jemand eine Idee?")
# [{'label': 'other', 'score': 0.9479537010192871}]
political_classifier("Forscher haben im Regenwald eine neue Froschart entdeckt.")
# [{'label': 'politic', 'score': 0.9884822368621826}] <- wrong: science news, see "Limitations"
The first two outputs are identical to those the model produced when it was uploaded in March 2025. Scores may differ in the last decimal places on other hardware.
Recommended usage: normalize whitespace, truncate, batch
import textwrap
def normalize(text):
return " ".join(text.split()) # remove line breaks: hard wraps push the model towards "other"
text = (
"Die Bundesregierung hat sich nach wochenlangen Verhandlungen auf einen Kompromiss beim Bundeshaushalt geeinigt. "
"Finanzminister und Kanzler stellten die Eckpunkte am Mittwoch in Berlin vor. Demnach sollen die Ausgaben für "
"Verteidigung und Infrastruktur steigen, während bei mehreren Förderprogrammen gekürzt wird. Die Schuldenbremse "
"soll eingehalten werden, allerdings plant die Koalition ein Sondervermögen für die Modernisierung der Bahn. "
"Die Opposition kritisierte die geplanten Kürzungen bei den Sozialausgaben scharf. Die Fraktionsvorsitzende der "
"größten Oppositionspartei sprach von einem Haushalt der sozialen Kälte und kündigte an, im Bundestag gegen den "
"Entwurf zu stimmen. Auch die Länder meldeten Bedenken an, weil sie höhere Kosten bei der Unterbringung von "
"Geflüchteten befürchten. Innerhalb der Koalition gibt es weiterhin Streit über die Finanzierung der Bundeswehr "
"und über die Frage, ob Steuererhöhungen für sehr hohe Einkommen ausgeschlossen bleiben sollen. Ökonomen "
"bewerteten den Kompromiss unterschiedlich: Während einige die Investitionen in Schiene und Digitalisierung "
"lobten, warnten andere vor zu optimistischen Annahmen über die Steuereinnahmen der kommenden Jahre. Der "
"Haushaltsausschuss soll den Entwurf nach der Sommerpause beraten, die abschließende Abstimmung im Parlament "
"ist für Ende November geplant. Bis dahin dürften sich Regierung und Opposition weitere Auseinandersetzungen "
"über die Prioritäten der Haushaltspolitik liefern, zumal in mehreren Ländern im kommenden Jahr Landtagswahlen anstehen."
)
wrapped = textwrap.fill(text, 70) # 24 lines, e.g. like text extracted from a PDF
for variant, t in [("hard-wrapped", wrapped), ("normalized", normalize(wrapped))]:
results = political_classifier([t], truncation=True, top_k=None, batch_size=16)
p_politic = [{d["label"]: d["score"] for d in r}["politic"] for r in results]
print(variant, [round(p, 4) for p in p_politic])
# hard-wrapped [0.0018]
# normalized [0.9999]
With truncation=True, inputs are cut at 8,192 tokens, the model's maximum length.
Older Transformers versions
Transformers 4.x has no native EuroBERT, so the model runs on the EuroBERT remote code. On these versions the pipeline doesn't find the tokenizer by itself, so pass it explicitly:
from transformers import AutoTokenizer, pipeline
repo = "SinclairSchneider/german_politic_EuroBERT-210m"
political_classifier = pipeline("text-classification", model=repo,
tokenizer=AutoTokenizer.from_pretrained(repo),
trust_remote_code=True)
political_classifier("Trump und Putin einigen sich auf begrenzte Waffenruhe")
# [{'label': 'politic', 'score': 0.9991077780723572}]
Tested with transformers 4.49.0, the version the model was trained with.
Model details
| Developed by | Sinclair Schneider, Research Institute CODE, Bundeswehr University Munich (NLP Research Group UniBW) |
| Model type | EuroBertForSequenceClassification (encoder with mean-pooled token logits) |
| Base model | EuroBERT/EuroBERT-210m (Boizard et al., 2025) |
| Parameters | 212.4 M |
| Language | German. The base model is multilingual, but the fine-tuning data is German. |
| Labels | 0 → other, 1 → politic |
| Max input length | 8,192 tokens |
| Training data | SinclairSchneider/trainset_political_text_yes_no_german |
| Trained | March 2025 |
| License | Apache-2.0 (same as the base model) |
| DOI | 10.57967/hf/9334 |
| Paper | Ideology Prediction of German Political Texts (ICWSM 2026) |
Uses
Direct use
- Pre-filtering long German documents before political analysis, e.g. full articles, reports and speeches, when missing political texts is worse than including non-political ones.
- Mixed collections that include everyday texts, where it makes fewer errors than the DeBERTa model. It is still not precise on general news.
Downstream use
- Fine-tuning on a target domain. Adding modern non-political negatives (economy, science, health, culture, regional news) would likely fix the main weakness.
Out-of-scope use
- Precise separation of political and non-political news without further validation.
- Political stance, ideology or party detection.
- Automated decisions about individuals without human review.
- Non-German text, which is untested.
Training data
This is the same dataset as for the DeBERTa model:
| Label | Source | Rows |
|---|---|---|
politic |
taz.de, articles tagged Politik | 80,663 |
politic |
bpb.de (Federal Agency for Civic Education) | 31,282 |
politic |
FOCUS online, section politik | 5,544 |
other |
Project Gutenberg, paragraphs of German books (hard-wrapped, historical spelling) | 85,983 |
other |
taz.de, Sport/Film/Musik | 13,710 |
other |
Chefkoch.de recipe instructions | 9,009 |
other |
FOCUS online, sport/auto/digital/reisen | 8,787 |
The dataset card lists composition, duplicates and artifacts.
Training procedure
Preprocessing
The raw text column was used without cleaning. It was tokenized with the EuroBERT tokenizer (Llama-3-style byte-level BPE; line breaks are kept as tokens) and truncated to 8,192 tokens, and batches were padded dynamically. The data was split randomly 80/20 with train_test_split(0.2) and no seed, giving 187,982 train / 46,996 eval texts.
Training hyperparameters
| Hyperparameter | Value |
|---|---|
| Optimizer | AdamW (adamw_torch) |
| Learning rate | 1e-5, linear decay to 0, no warm-up |
| Weight decay | 0.01 |
| Epochs | 4 (46,996 steps, 11,749 per epoch) |
| Batch size | 4 per GPU × 4 GPUs = 16 |
| Max sequence length | 8,192 |
| Precision | weights loaded in bfloat16 (bf16/fp16 flags off) |
| Classifier pooling | late: per-token logits averaged over non-padding tokens |
| Model selection | best eval loss → epoch 4 (step 46,996) was published |
Seed (Trainer) |
42 |
Speeds, sizes, times
| Hardware | 4 × NVIDIA RTX 6000 Ada Generation (48 GB) |
| Training time | 38,959 s ≈ 10.8 h, at 19.3 samples/s |
| Mean training loss | 0.0180 |
| Total training FLOPs | 2.74 × 10¹⁸ |
| Inference throughput (single GPU) | ≈ 68 news articles/s (fp32, batch 16, length-sorted 10kGNAD articles, median 298 words), vs. ≈ 108/s for the DeBERTa model |
| Checkpoint size | 849 MB (float32 safetensors) |
| Software | Python 3.10.12, PyTorch 2.6.0, Transformers 4.49.0 (with EuroBERT remote code), Datasets 3.0.1, Tokenizers 0.21.0 |
Evaluation
1. In-distribution: held-out 20% of the training data (46,996 texts)
| Epoch | Eval loss | Accuracy | Weighted F1 | Weighted precision | Weighted recall |
|---|---|---|---|---|---|
| 1 | 0.02502 | 0.9946 | 0.9946 | 0.9946 | 0.9946 |
| 2 | 0.02164 | 0.9955 | 0.9955 | 0.9955 | 0.9955 |
| 3 | 0.02104 | 0.9957 | 0.9957 | 0.9957 | 0.9957 |
| 4 (published) | 0.02099 | 0.9957 | 0.9957 | 0.9957 | 0.9957 |
These are same-source eval texts, with possible duplicates across the split. The numbers mostly reflect how easy it is to tell the training sources apart.
2. Out-of-domain: 10kGNAD (derStandard.at)
Setup. 10kGNAD contains 10,273 articles from the Austrian newspaper DER STANDARD (2015–2016), sorted into 9 sections by the newspaper's moderators. 10,271 articles remain after removing duplicates. Inland (1,014) and International (1,510) count as politic, and the other 7 sections as other (7,747). The articles have no line breaks.
| Input | Accuracy | Precision (politic) | Recall (politic) | F1 (politic) | Macro F1 | ROC-AUC |
|---|---|---|---|---|---|---|
| Full article (up to 8,192 tokens) | 0.375 | 0.282 | 0.9996 | 0.440 | 0.366 | 0.860 |
| Truncated to 512 tokens | 0.383 | 0.285 | 0.999 | 0.443 | 0.376 | 0.863 |
| First 100 words | 0.394 | 0.288 | 0.999 | 0.447 | 0.388 | 0.861 |
| First sentence | 0.396 | 0.283 | 0.951 | 0.436 | 0.393 | 0.709 |
Confusion matrix, full article at 0.5: TN 1,327 · FP 6,420 · FN 1 · TP 2,523.
Share of each section predicted as politic (full article)
| Threshold | Inland | International | Wirtschaft | Wissenschaft | Panorama | Etat (media) | Web | Kultur | Sport |
|---|---|---|---|---|---|---|---|---|---|
| 0.5 | 100% | 99.9% | 99.8% | 99.8% | 99.8% | 96.6% | 91.4% | 76.4% | 14.6% |
| 0.8 | 100% | 99.9% | 99.7% | 99.5% | 99.6% | 96.1% | 89.3% | 72.2% | 12.2% |
| 0.99 | 99.9% | 99.9% | 99.3% | 99.1% | 99.2% | 92.1% | 82.6% | 62.5% | 7.2% |
| 0.999 | 99.4% | 99.3% | 91.1% | 95.8% | 95.5% | 79.5% | 63.1% | 47.9% | 2.0% |
Threshold sweep
Full articles:
| Threshold | Accuracy | Precision | Recall | F1 (politic) | Macro F1 |
|---|---|---|---|---|---|
| 0.5 | 0.375 | 0.282 | 1.000 | 0.440 | 0.366 |
| 0.8 | 0.384 | 0.285 | 1.000 | 0.444 | 0.377 |
| 0.9 | 0.389 | 0.287 | 0.999 | 0.446 | 0.383 |
| 0.99 | 0.410 | 0.294 | 0.999 | 0.454 | 0.406 |
| 0.999 | 0.482 | 0.321 | 0.993 | 0.485 | 0.482 |
Observations
- It over-includes non-political news even more than DeBERTa does (accuracy 0.375 vs. 0.415, AUC 0.860 vs. 0.866). The two models agree on 93.3% of the decisions, and the correlation of their scores is r = 0.79.
- Some of these errors come from noisy section labels. derStandard filed much of the 2015 refugee and Greek-debt coverage under Panorama and Wirtschaft. Science, web and media articles that clearly aren't political are also labeled
politic, though. - Only one political article was missed: a football report filed under International.
- Long context brings no gain here. On the 3,804 articles with more than 380 words, reading the full article gives AUC 0.813, compared with 0.822 when truncated to 512 tokens. 98 decisions change.
- The scores are overconfident. 91.9% of predictions have a confidence ≥ 0.99, but only 35.8% of those are correct.
3. Short sentences and everyday texts
These are hand-written examples, not drawn from any dataset. 17 of 19 are correct at 0.5; the DeBERTa model gets 13 of 19.
| Text | Gold | P(politic) | DeBERTa |
|---|---|---|---|
| Der Senat hat die neue Verfassungsrichterin bestätigt. | politic | 0.997 | 0.051 ✗ |
| Der Premierminister kündigte für nächsten Monat Neuwahlen an. | politic | 0.999 | 0.99998 |
| Die Abgeordneten debattieren über eine Erhöhung des Mindestlohns. | politic | 0.999 | 0.99998 |
| Der Präsident legte sein Veto gegen den Verteidigungshaushalt ein. | politic | 0.996 | 0.997 |
| Die NATO-Außenminister berieten in Brüssel über Sanktionen gegen Russland. | politic | 0.9996 | 0.99999 |
| Die Opposition wirft der Regierung Korruption vor. | politic | 0.998 | 0.99998 |
| Der Bundestag hat das Gesetz mit den Stimmen der Koalition verabschiedet. | politic | 0.999 | 0.99998 |
| Trump und Putin einigen sich auf begrenzte Waffenruhe | politic | 0.999 | 0.99997 |
| Ich gehe gerne ins Fitnessstudio. | other | 0.237 | 0.009 |
| Für dieses Rezept braucht man zwei Tassen Mehl und eine Prise Salz. | other | 0.0003 | 0.00001 |
| Der Stürmer traf zweimal, die Heimmannschaft gewann 3:1. | other | 0.011 | 0.00004 |
| Das neue Smartphone hat einen größeren Akku und eine bessere Kamera. | other | 0.165 | 0.007 |
| Die Band kündigte eine Welttournee ab März an. | other | 0.079 | 0.953 ✗ |
| Forscher haben im Regenwald eine neue Froschart entdeckt. | other | 0.988 ✗ | 0.916 ✗ |
| Ausreichend Wasser zu trinken ist wichtig für die Gesundheit. | other | 0.996 ✗ | 0.002 |
| Unser Hotel hatte einen wunderschönen Blick auf den Strand. | other | 0.006 | 0.979 ✗ |
| Mein Laptop startet seit dem letzten Update nicht mehr richtig, hat jemand eine Idee? | other | 0.052 | 0.9997 ✗ |
| Seit geraumer Zeit passiert es immer häufiger, dass das Tachodisplay beim Aufsperren als auch Starten des Fahrzeugs schwarz bleibt. … | other | 0.013 | 0.9996 ✗ |
| Franck Ribéry und Arjen Robben feiern beim "Beckenbauer Cup" ihr Comeback beim FC Bayern. … | other | 0.013 | 0.003 |
Both errors fall into topics that were missing from the training negatives (science, health).
4. Shortcut probes: line breaks and spelling
Surface features of the Project Gutenberg paragraphs, which make up 73% of the training other class, were applied to 10kGNAD articles:
| Modification | Political articles → politic |
Non-political articles → politic |
|---|---|---|
| None | 99.96% | 82.9% |
| Hard line breaks every 70 characters (Gutenberg style) | 5.8% | 2.9% |
| Line breaks every 300 characters (control) | 99.9% | – |
| dass → daß (old spelling; 1,631 political articles) | 99.9% → 99.9% | – |
| Old spelling + hard line breaks | 1.2% | – |
| First 100 words only | 99.9% | – |
| First sentence only | 95.1% | – |
The effect grows with the number of wrapped lines. Share of political articles still classified as politic after hard-wrapping:
| Lines after wrapping | < 8 | 8–11 | 12–19 | 20–39 | ≥ 40 |
|---|---|---|---|---|---|
| Articles | 59 | 62 | 423 | 890 | 1,090 |
Still politic |
75–86% | 24% | 15% | 2.6% | 0% |
Short, hard-wrapped lines are a decisive cue for other. The model learned this from the Gutenberg paragraphs, and the old spelling has no effect. The DeBERTa model is immune because its tokenizer turns line breaks into spaces. Normalize whitespace before classifying (see Recommended usage).
Bias, risks, and limitations
- Old revisions. Revisions up to
b9c36destore the output layer asout_proj. Loaded the normal way, they give a random output layer and meaningless predictions, without any error message. See Loading. - Formatting sensitivity. Hard line breaks (PDF extracts, e-mails, poems, subtitles) push predictions towards
other, independent of content. - The definition of "political" is narrow on the negative side. The training negatives were sport, film, music, cars, tech gadgets, travel, recipes and historical literature. Most modern news on economy, science, health, media and panorama is labeled political.
- Overconfidence. Scores near 1.0 are typical for any news-like text.
- Domain and time. The training news comes from German outlets, 2010s–2023. Austrian news (10kGNAD) shows the same pattern of errors.
- Training data copyright. The training texts are partly copyrighted news articles (license
unknown).
Recommendations
- After loading, check a known example: "Trump und Putin einigen sich auf begrenzte Waffenruhe" should give
politic0.9991. - Normalize whitespace (
" ".join(text.split())) before classifying. - Use the model as a high-recall filter, and add a second stage if precision on news matters.
- Validate the threshold on a labeled sample of your own data.
Environmental impact
- Hardware: 4 × NVIDIA RTX 6000 Ada (300 W TDP each), on-premise university GPU server.
- Time: ≈ 10.8 h.
- Energy: at most ≈ 13 kWh for the GPUs.
- Carbon emitted: ≈ 5.2 kg CO₂eq, assuming ~0.4 kg CO₂eq/kWh (Lacoste et al., 2019).
Technical specifications
- Encoder: EuroBERT-210m with 12 layers, hidden size 768, 12 attention heads, intermediate size 3,072, SiLU activation, RMSNorm and rotary position embeddings (θ = 250,000). It reads up to 8,192 tokens, and its byte-level BPE vocabulary has 128,256 tokens.
- Classification head (
latepooling): dense 768→768 + GELU + linear 768→2, applied to every token. The logits are averaged over the non-padding tokens. - Objective: softmax cross-entropy.
Citation
Related paper:
@article{schneider2026ideology,
title = {Ideology Prediction of German Political Texts},
author = {Schneider, Sinclair and Steuber, Florian and Schneider, Jo{\~a}o A. G. and Dreo Rodosek, Gabi},
journal = {Proceedings of the International AAAI Conference on Web and Social Media},
volume = {20},
number = {1},
pages = {2006--2021},
year = {2026},
doi = {10.1609/icwsm.v20i1.42735},
url = {https://doi.org/10.1609/icwsm.v20i1.42735}
}
This model:
@misc{schneider_german_politic_eurobert_210m,
author = {Schneider, Sinclair},
title = {german\_politic\_EuroBERT-210m: a long-context classifier for detecting political text in German},
year = {2025},
publisher = {Hugging Face},
doi = {10.57967/hf/9334},
howpublished = {\url{https://huggingface.co/SinclairSchneider/german_politic_EuroBERT-210m}}
}
Base model:
@misc{boizard2025eurobert,
title = {EuroBERT: Scaling Multilingual Encoders for European Languages},
author = {Boizard, Nicolas and Gisserot-Boukhlef, Hippolyte and Alves, Duarte M. and Martins, Andr{\'e} and Hammal, Ayoub and Corro, Caio and Hudelot, C{\'e}line and Malherbe, Emmanuel and Malaboeuf, Etienne and Jourdan, Fanny and Hautreux, Gabriel and Alves, Jo{\~a}o and El Haddad, Kevin and Faysse, Manuel and Peyrard, Maxime and Guerreiro, Nuno M. and Fernandes, Patrick and Rei, Ricardo and Colombo, Pierre},
year = {2025},
eprint = {2503.05500},
archivePrefix = {arXiv}
}
Out-of-domain evaluation data (10kGNAD is derived from the One Million Posts Corpus):
@inproceedings{schabus2017onemillion,
title = {One Million Posts: A Data Set of German Online Discussions},
author = {Schabus, Dietmar and Skowron, Marcin and Trapp, Martin},
booktitle = {Proceedings of the 40th International ACM SIGIR Conference on Research and Development in Information Retrieval},
pages = {1241--1244},
year = {2017},
doi = {10.1145/3077136.3080711}
}
Model card authors and contact
Sinclair Schneider, Research Institute CODE, Bundeswehr University Munich. Questions and issues are welcome in the Community tab.