text-classification · text · WASM · ~437 MB
Most sentiment models are English-first. german-sentiment-bert is the opposite: a bert-base-german-cased fine-tuned on about 1.8 million German samples — reviews, tweets and service messages — to score text as positiv, negativ or neutral. Its whole vocabulary and corpus are German, so it reads compound words, umlauts (ä/ö/ü), the ß and German register as first-class signal. Type something in German below and watch the real class probabilities; then look inside to see which words moved the verdict. Nothing leaves your device.
| Model (weights) | oliverguhr/german-sentiment-bert — ONNX classification head + weights |
|---|---|
| Tokenizer | google-bert/bert-base-german-cased — the base model's tokenizer (byte-identical vocab; ships tokenizer.json) |
| Task / pipeline | text-classification — three classes: positiv · negativ · neutral |
| How it works | German BERT encodes the text, then a small head predicts the 3-class softmax (config id2label: 0 positive · 1 negative · 2 neutral) |
| Architecture | BERT base (~110M params), German cased vocab, fine-tuned on ~1.8M German samples (reviews, tweets, service texts) |
| Language | German only — a language specialist, not a multilingual model |
| Quantization | fp32 (full-precision) ONNX (onnx/model.onnx) — the only export the repo ships |
| Backend | WebAssembly (WASM) — runs anywhere; no WebGPU needed |
| Download | ~437 MB, cached after first load (fp32 — larger than a quantized model) |
| License | MIT (oliverguhr/german-sentiment-bert) — cite the German Sentiment paper |
| Web APIs | WebAssembly, Web Workers — all Baseline widely available |
Why two repos: the weights repo ships an ONNX export but no tokenizer.json (only
vocab.txt), which transformers.js can't build a tokenizer from. This model is a fine-tune of
bert-base-german-cased, and the two vocabularies are byte-identical, so we load the same
WordPiece tokenizer from the base repo and the real weights from the fine-tune — a legitimate
AutoTokenizer + AutoModel load.
Type or paste some German, or pick a sample. The verdict updates as you type; the class bars show the full probability split.
The model never matches "sentiment words" from a list — it reads the whole sentence through one German encoder. To make that legible we run occlusion attribution: re-score the text with each word removed and measure how far the winning class's confidence drops (in log-odds). A word tinted in the verdict colour was pushing that verdict; a grey word was pulling against it. Because the tokenizer decides what a "word" contributes, a compound noun, a negation (nicht, kein) or an intensifier all carry real weight.
A multilingual model (XLM-R) spreads one embedding space across ~100 languages — brilliant when your text could be in any of them. german-sentiment-bert goes the other way: all of its ~110M parameters and its entire vocabulary are German, pre-trained and fine-tuned on German text. On idiomatic German — negation stacking, long compound nouns, service-desk politeness — a specialist often reads the register a generalist flattens. The multi-model demo runs both side by side so you can see where they agree and where they part.
German is the most-spoken native language in the EU, and a lot of opinion data — reviews, DMs, support tickets, social posts — arrives in it. A model that was actually trained on German reads its register, not a translated approximation, and it runs in a tab, so that text never has to leave the device.
Type German, get positiv / negativ / neutral with the full probability split.
Paste a batch of German reviews and get a sorted, colour-coded monitoring board.
Break it: negation stacking, sarcasm, dialect and long compound nouns.
German-native BERT vs a multilingual XLM-R model on the same text.
The weights repo has no tokenizer.json, so we load the identical tokenizer from the base
model and the head + weights from the fine-tune, then run them together:
import {
AutoTokenizer,
AutoModelForSequenceClassification,
} from "@huggingface/transformers";
// Same WordPiece vocab as the fine-tune (byte-identical vocab.txt).
const tokenizer = await AutoTokenizer.from_pretrained(
"google-bert/bert-base-german-cased",
);
const model = await AutoModelForSequenceClassification.from_pretrained(
"oliverguhr/german-sentiment-bert",
{ dtype: "fp32" },
); // downloads + caches ~437 MB once
const inputs = await tokenizer("Ich liebe diesen Ort 😍");
const { logits } = await model(inputs);
// softmax(logits) → { positive: 0.99, negative: 0.00, neutral: 0.01 }
// (config id2label: 0 positive · 1 negative · 2 neutral)
This page maps the labels to positiv / negativ / neutral, lightly cleans the text the way the model was trained (lowercase, strip digits/punctuation), and runs everything in a Web Worker so the UI never janks. "See inside" reuses the same loaded model to re-score occluded variants of the text and read off each word's pull.