← All models

text-classification · text · WASM · ~279 MB

Multilingual sentiment — the mood of text in any language

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.

At a glance

Modelonnx-community/twitter-xlm-roberta-base-sentiment-ONNX
Base modelcardiffnlp/twitter-xlm-roberta-base-sentiment (TweetEval / UMSAB)
Task / pipelinetext-classification — three classes: negative · neutral · positive
How it worksXLM-RoBERTa encodes the text into one shared multilingual space, then a small head predicts the 3-class softmax
ArchitectureXLM-RoBERTa base (~278M params), fine-tuned on ~198M multilingual tweets + labelled UMSAB sentiment data
LanguagesTrained/evaluated on Arabic, English, French, German, Hindi, Italian, Portuguese, Spanish; the XLM-R backbone generalises to more
Quantizationq8 (8-bit) ONNX (model_quantized.onnx)
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~279 MB, cached after first load
LicenseNot formally specified by the authors (research model; cite the TweetEval / XLM-T papers)
Web APIsWebAssembly, Web Workers — all Baseline widely available

Run it

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.

See inside — which words moved the verdict

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.

Analyse some text, then explain it to inspect word-level attribution.

Why it matters

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.

Use cases

Basics

The same sentence in eight languages — watch one model score them all the same way.

Practical

Paste a batch of reviews or comments and get a sorted, colour-coded sentiment board.

Wild

Break it: mixed-language posts, emoji-only messages, sarcasm and negation.

Multi-model

Detect the language first, then score sentiment — and contrast against an English-only model.

How the API works

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.

References