text-classification · text · WASM · ~279 MB
Most sentiment models only understand English. This one reads social-media text in about eight languages — English, Spanish, French, German, Italian, Portuguese, Arabic, Hindi and more that share its multilingual backbone — and scores each as negative, neutral or positive. Type a post in any of them below and watch the real class probabilities; then look inside to see which words (and emoji) moved the verdict. Nothing leaves your device.
| Model | onnx-community/twitter-xlm-roberta-base-sentiment-ONNX |
|---|---|
| Base model | cardiffnlp/twitter-xlm-roberta-base-sentiment (TweetEval / UMSAB) |
| Task / pipeline | text-classification — three classes: negative · neutral · positive |
| How it works | XLM-RoBERTa encodes the text into one shared multilingual space, then a small head predicts the 3-class softmax |
| Architecture | XLM-RoBERTa base (~278M params), fine-tuned on ~198M multilingual tweets + labelled UMSAB sentiment data |
| Languages | Trained/evaluated on Arabic, English, French, German, Hindi, Italian, Portuguese, Spanish; the XLM-R backbone generalises to more |
| Quantization | q8 (8-bit) ONNX (model_quantized.onnx) |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~279 MB, cached after first load |
| License | Not formally specified by the authors (research model; cite the TweetEval / XLM-T papers) |
| Web APIs | WebAssembly, Web Workers — all Baseline widely available |
Type or paste a short post in any language, or pick a sample. The verdict updates as you type; the class bars show the full probability split.
The model never picks out "sentiment words" from a list — it reads the whole sentence through one multilingual encoder. To make its reasoning 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, this works in every language — and shows emoji carrying real weight.
The moment your users aren't all English speakers, an English-only sentiment model quietly fails — it either mislabels or collapses to "neutral" on text it can't read. A single multilingual model that scores Spanish, Arabic and Japanese on the same footing means one pipeline instead of a dozen, and it runs in a tab, so opinion data — reviews, DMs, support tickets — never has to leave the device.
The same sentence in eight languages — watch one model score them all the same way.
Paste a batch of reviews or comments and get a sorted, colour-coded sentiment board.
Break it: mixed-language posts, emoji-only messages, sarcasm and negation.
Detect the language first, then score sentiment — and contrast against an English-only model.
The pipeline takes a string and returns labelled class scores. Ask for all three with top_k:
import { pipeline } from "@huggingface/transformers";
const clf = await pipeline(
"text-classification",
"onnx-community/twitter-xlm-roberta-base-sentiment-ONNX",
{ dtype: "q8" },
); // downloads + caches ~279 MB once
const out = await clf("Me encanta este lugar 😍", { top_k: 3 });
// → [{ label: "positive", score: 0.94 },
// { label: "neutral", score: 0.04 },
// { label: "negative", score: 0.02 }]
The label order is fixed by the model config (0 negative · 1 neutral · 2 positive).
"See inside" reuses that same loaded instance to re-score occluded variants of the text and read off
each word's pull. All of it runs in a Web Worker so the UI never janks.