This classifier predicts whether a German text is political (politic) or not (other). It is ikim-uk-essen/geberta-base (GeBERTa, a German DeBERTa-v2) fine-tuned on SinclairSchneider/trainset_political_text_yes_no_german. That dataset contains 234,978 texts: political texts from taz, FOCUS online and the Federal Agency for Civic Education (bpb), and non-political texts from Project Gutenberg books, recipes, and taz/FOCUS sport, culture, car, tech and travel articles.
The training script is in this repository: train.py.
Paper: Ideology Prediction of German Political Texts (Schneider, Steuber, Schneider & Dreo Rodosek, ICWSM 2026). In the paper, this model is the pre-filter of the ideology pipeline. Only texts with P(politic) ≥ 0.8 are passed on to the party and ideology classifiers. Code: github.com/SinclairSchneider/german_ideology_prediction.
Summary of results:
A long-context alternative trained on the same data is SinclairSchneider/german_politic_EuroBERT-210m. The English counterpart is SinclairSchneider/english_politic_RoBERTa-large.
[!IMPORTANT] Before using the model, note:
- It works as a high-recall "not sport / not leisure" filter rather than a precise politics detector. In the training data, the only modern non-political prose was sport, film, music, car, tech and travel journalism, plus recipes and old literature. Modern texts on other topics are usually classified as
politicwith confidence above 0.99. That includes economy, science, health, media, panorama, forums and reviews.- Raising the threshold doesn't help much. Even at 0.999, 89% of business and 78% of science articles are still labeled
politic.- Pass
truncation=True. The model was trained on at most 512 tokens. Longer inputs don't crash, because DeBERTa uses relative positions, but they are outside what the model saw in training and use more memory.
from transformers import pipeline
political_classifier = pipeline("text-classification", model="SinclairSchneider/german_politic_DeBERTa-v2-base")
political_classifier("Trump und Putin einigen sich auf begrenzte Waffenruhe")
# [{'label': 'politic', 'score': 0.9999680519104004}]
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.9969837069511414}]
political_classifier("Der Bundestag hat das Gesetz mit den Stimmen der Koalition verabschiedet.")
# [{'label': 'politic', 'score': 0.9999774694442749}]
political_classifier("Mein Laptop startet seit dem letzten Update nicht mehr richtig, hat jemand eine Idee?")
# [{'label': 'politic', 'score': 0.9996838569641113}] <- wrong: everyday text, see "Limitations"
The outputs were produced on a GPU with transformers 5.15 / torch 2.13. Scores may differ in the last decimal places on other hardware or versions.
from transformers import pipeline
political_classifier = pipeline("text-classification", model="SinclairSchneider/german_politic_DeBERTa-v2-base")
texts = [
"Die Opposition wirft der Regierung Korruption vor.",
"Für dieses Rezept braucht man zwei Tassen Mehl und eine Prise Salz.",
" ".join(["Der Bundestag debattierte stundenlang über den neuen Haushaltsentwurf."] * 120), # > 512 tokens
]
results = political_classifier(texts, truncation=True, top_k=None, batch_size=32)
p_politic = [{d["label"]: d["score"] for d in r}["politic"] for r in results]
print([round(p, 4) for p in p_politic])
# [1.0, 0.0, 1.0]
THRESHOLD = 0.8 # the value used in the ICWSM 2026 paper
print([p >= THRESHOLD for p in p_politic])
# [True, False, True]
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
repo = "SinclairSchneider/german_politic_DeBERTa-v2-base"
tokenizer = AutoTokenizer.from_pretrained(repo)
model = AutoModelForSequenceClassification.from_pretrained(repo).eval()
texts = ["Die NATO-Außenminister berieten in Brüssel über Sanktionen gegen Russland.",
"Der Stürmer traf zweimal, die Heimmannschaft gewann 3:1."]
enc = tokenizer(texts, truncation=True, max_length=512, padding=True, return_tensors="pt")
with torch.no_grad():
probs = model(**enc).logits.softmax(dim=-1)
for text, p in zip(texts, probs):
print(model.config.id2label[int(p.argmax())], round(float(p[1]), 4), text)
# politic 1.0 Die NATO-Außenminister berieten in Brüssel über Sanktionen gegen Russland.
# other 0.0 Der Stürmer traf zweimal, die Heimmannschaft gewann 3:1.
| Developed by | Sinclair Schneider, Research Institute CODE, Bundeswehr University Munich (NLP Research Group UniBW) |
| Model type | DebertaV2ForSequenceClassification |
| Base model | ikim-uk-essen/geberta-base (Dada et al., 2023) |
| Parameters | 139.2 M |
| Language | German |
| Labels | 0 → other, 1 → politic |
| Max input length | 512 tokens |
| Training data | SinclairSchneider/trainset_political_text_yes_no_german |
| Trained | October 2023 |
| License | MIT (same as the base model) |
| Paper | Ideology Prediction of German Political Texts (ICWSM 2026) |
politic). Scores rank better than the hard decisions suggest (ROC-AUC 0.87 out of domain).| 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 | 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 |
These are 117,489 texts per class. 81% of the other class is literature and recipes, and the political texts are much longer: median 532 words vs. 118. The dataset card lists composition, duplicates and known artifacts.
The raw text column was used without cleaning. It was tokenized with the GeBERTa SentencePiece tokenizer (cased) and truncated to 512 tokens, and batches were padded dynamically. The SentencePiece tokenizer treats line breaks like spaces, so the model never sees line structure. The data was split randomly 80/20 with train_test_split(0.2) and no seed, giving 187,982 train / 46,996 eval texts. That split can't be reproduced exactly, and duplicate texts in the dataset can end up on both sides.
| Hyperparameter | Value |
|---|---|
| Optimizer | AdamW (adamw_torch, default betas/epsilon) |
| Learning rate | 2e-5, linear decay to 0, no warm-up |
| Weight decay | 0.01 |
| Epochs | 4 (11,752 steps, 2,938 per epoch) |
| Batch size | 16 per GPU × 4 GPUs = 64 |
| Max sequence length | 512 |
| Precision | fp32 |
| Dropout | 0.1 (hidden and attention) |
| Model selection | best eval loss → epoch 2 (step 5,876) was published |
Seed (Trainer) |
42 |
| Hardware | 4 × NVIDIA RTX 6000 Ada Generation (48 GB) |
| Training time | ≈ 2 h 19 min for 4 epochs (≈ 2.45 h including evaluation) |
| Evaluation throughput | ≈ 261 texts/s (46,996 texts in ≈ 180 s) |
| Inference throughput (single GPU) | ≈ 108 news articles/s (fp32, batch 16, length-sorted 10kGNAD articles, median 298 words) |
| Total training FLOPs | 2.31 × 10¹⁷ |
| Checkpoint size | 557 MB (float32; model.safetensors and pytorch_model.bin) |
| Software | Python 3.10.12, PyTorch 2.0.1, Transformers 4.32.0, Datasets 2.13.1, Tokenizers 0.13.3, SentencePiece 0.1.99 |
| Epoch | Eval loss | Accuracy | Weighted F1 | Weighted precision | Weighted recall |
|---|---|---|---|---|---|
| 1 | 0.0106 | 0.9962 | 0.9962 | 0.9962 | 0.9962 |
| 2 (published) | 0.0104 | 0.9966 | 0.9966 | 0.9966 | 0.9966 |
| 3 | 0.0111 | 0.9969 | 0.9969 | 0.9969 | 0.9969 |
| 4 | 0.0162 | 0.9971 | 0.9971 | 0.9971 | 0.9971 |
The eval texts come from the same sources, and exact duplicates can appear in both train and eval. These numbers reflect how easy it is to tell the training sources apart, not how well the model generalizes.
Setup. 10kGNAD contains 10,273 articles from the Austrian newspaper DER STANDARD (2015–2016). The newspaper's moderators sorted them into 9 sections, and 10,271 articles remain after removing duplicates.
Target: the sections Inland (domestic politics, 1,014) and International (1,510) count as politic; all others count as other (7,747). The model input was the article text (median 298 words), truncated to 512 tokens.
| Input | Accuracy | Precision (politic) | Recall (politic) | F1 (politic) | Macro F1 | ROC-AUC |
|---|---|---|---|---|---|---|
| Full article | 0.415 | 0.296 | 0.998 | 0.456 | 0.412 | 0.866 |
| First 100 words | 0.427 | 0.300 | 0.997 | 0.461 | 0.424 | 0.863 |
| First sentence | 0.480 | 0.307 | 0.886 | 0.456 | 0.479 | 0.728 |
Confusion matrix, full article at 0.5: TN 1,743 · FP 6,004 · FN 5 · TP 2,519.
politic (full article)| Threshold | Inland | International | Wirtschaft | Wissenschaft | Panorama | Web | Etat (media) | Kultur | Sport |
|---|---|---|---|---|---|---|---|---|---|
| 0.5 | 99.9% | 99.7% | 99.0% | 98.6% | 97.9% | 86.7% | 80.8% | 64.4% | 4.9% |
| 0.8 (paper) | 99.7% | 99.6% | 98.6% | 97.6% | 97.2% | 84.7% | 77.2% | 62.0% | 4.2% |
| 0.99 | 99.2% | 99.3% | 96.1% | 91.8% | 95.1% | 78.5% | 67.5% | 53.8% | 3.0% |
| 0.999 | 98.1% | 98.7% | 88.5% | 78.4% | 91.4% | 67.8% | 56.1% | 45.8% | 2.1% |
The median P(politic) is 1.0000 for Wirtschaft and Panorama, 0.9999 for Wissenschaft, 0.9998 for Web, 0.9996 for Etat, 0.9976 for Kultur and 0.0000 for Sport.
Full articles:
| Threshold | Accuracy | Precision | Recall | F1 (politic) | Macro F1 |
|---|---|---|---|---|---|
| 0.5 | 0.415 | 0.296 | 0.998 | 0.456 | 0.412 |
| 0.8 | 0.425 | 0.299 | 0.996 | 0.460 | 0.422 |
| 0.9 | 0.430 | 0.301 | 0.996 | 0.462 | 0.428 |
| 0.99 | 0.456 | 0.310 | 0.993 | 0.473 | 0.455 |
| 0.999 | 0.508 | 0.331 | 0.985 | 0.496 | 0.508 |
These are hand-written examples, not drawn from any dataset. 13 of 19 are correct at 0.5.
| Text | Gold | P(politic) |
|---|---|---|
| Der Senat hat die neue Verfassungsrichterin bestätigt. | politic | 0.051 ✗ |
| Der Premierminister kündigte für nächsten Monat Neuwahlen an. | politic | 0.99998 |
| Die Abgeordneten debattieren über eine Erhöhung des Mindestlohns. | politic | 0.99998 |
| Der Präsident legte sein Veto gegen den Verteidigungshaushalt ein. | politic | 0.997 |
| Die NATO-Außenminister berieten in Brüssel über Sanktionen gegen Russland. | politic | 0.99999 |
| Die Opposition wirft der Regierung Korruption vor. | politic | 0.99998 |
| Der Bundestag hat das Gesetz mit den Stimmen der Koalition verabschiedet. | politic | 0.99998 |
| Trump und Putin einigen sich auf begrenzte Waffenruhe | politic | 0.99997 |
| Ich gehe gerne ins Fitnessstudio. | other | 0.009 |
| Für dieses Rezept braucht man zwei Tassen Mehl und eine Prise Salz. | other | 0.00001 |
| Der Stürmer traf zweimal, die Heimmannschaft gewann 3:1. | other | 0.00004 |
| Das neue Smartphone hat einen größeren Akku und eine bessere Kamera. | other | 0.007 |
| Die Band kündigte eine Welttournee ab März an. | other | 0.953 ✗ |
| Forscher haben im Regenwald eine neue Froschart entdeckt. | other | 0.916 ✗ |
| Ausreichend Wasser zu trinken ist wichtig für die Gesundheit. | other | 0.002 |
| Unser Hotel hatte einen wunderschönen Blick auf den Strand. | other | 0.979 ✗ |
| Mein Laptop startet seit dem letzten Update nicht mehr richtig, hat jemand eine Idee? | other | 0.9997 ✗ |
| Seit geraumer Zeit passiert es immer häufiger, dass das Tachodisplay beim Aufsperren als auch Starten des Fahrzeugs schwarz bleibt. … | other | 0.9996 ✗ |
| Franck Ribéry und Arjen Robben feiern beim "Beckenbauer Cup" ihr Comeback beim FC Bayern. … | other | 0.003 |
The training data's other class is dominated by Gutenberg paragraphs, which are hard-wrapped at about 70 characters and often use pre-1996 spelling. To check whether the model relies on these surface cues, they were applied to the 2,524 political 10kGNAD articles:
| Modification | Predicted politic |
|---|---|
| None | 99.8% |
| Hard line breaks every 70 characters (Gutenberg style) | 99.8% |
| dass → daß (old spelling; 1,631 articles containing dass) | 99.9% → 99.9% |
| First 100 words only | 99.7% |
| First sentence only | 88.6% |
The model is robust to line breaks, because its tokenizer ignores them, and to the dass/daß spelling. Its weakness is topical coverage, not surface formatting. By contrast, the EuroBERT model trained on the same data flips 94% of these articles to other when they are hard-wrapped.
unknown).truncation=True.These figures cover the published run only. An earlier run in October 2023 on a different version of the data isn't included.
ContextPooler (dense 768→768 + GELU on the [CLS] token) → dropout → linear 768→2.If you use this model, please cite the 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}
}
Training data:
@misc{schneider_trainset_political_text_yes_no_german,
author = {Schneider, Sinclair},
title = {German Political vs. Other Text: a weakly labelled training set for political text detection},
year = {2025},
publisher = {Hugging Face},
doi = {10.57967/hf/4925},
howpublished = {\url{https://huggingface.co/datasets/SinclairSchneider/trainset_political_text_yes_no_german}}
}
Base model:
@inproceedings{dada2023geberta,
title = {On the Impact of Cross-Domain Data on {German} Language Models},
author = {Dada, Amin and Chen, Aokun and Peng, Cheng and Smith, Kaleb and Idrissi-Yaghir, Ahmad and Seibold, Constantin and Li, Jianning and Heiliger, Lars and Friedrich, Christoph and Truhn, Daniel and Egger, Jan and Bian, Jiang and Kleesiek, Jens and Wu, Yonghui},
booktitle = {Findings of the Association for Computational Linguistics: EMNLP 2023},
pages = {13801--13813},
year = {2023}
}
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}
}
Sinclair Schneider, Research Institute CODE, Bundeswehr University Munich. Questions and issues are welcome in the Community tab.
pytorch_model.bin 557 MBmodel.safetensors 557 MB