text-classification ยท text ยท WASM ยท ~126 MB
Sarcasm is where language breaks the rules: "oh great, another Monday" is positive words, negative meaning. This Twitter-RoBERTa classifier, trained on the TweetEval irony task, decides whether a piece of text is ironic or literal โ reading the incongruity, not just the vocabulary. Type below and watch the irony meter move, all on-device.
| Model | Xenova/twitter-roberta-base-irony |
|---|---|
| Task / pipeline | text-classification (single-label) |
| Labels | irony vs non_irony; softmax (the two scores sum to 1) |
| Architecture | RoBERTa-base (125M params) fine-tuned on TweetEval irony (cardiffnlp) |
| Quantization | q8 (8-bit) ONNX |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~126 MB, cached after first load |
| License | Unspecified upstream โ research/demo use; base RoBERTa is MIT |
| Web APIs | WebAssembly, Web Workers โ all Baseline widely available |
Type anything. The irony score re-computes automatically (debounced) a moment after you stop typing. Above 50% the model reads the text as ironic/sarcastic.
This is the model's raw softmax: two numbers, irony and non_irony,
that sum to 1. There's no attention magic on show here because that's the honest point โ
sarcasm has no reliable surface signal. "This is fine" is literal in one context and bitterly
ironic in another; the same words flip on tone, situation, and shared knowledge the text doesn't contain. The
model leans on patterns it saw in tweets (over-the-top praise, incongruous framing, "just what I needed"), so
it's strong on stock sarcasm and genuinely uncertain on deadpan or context-dependent lines. Watch the two
bars โ when they're near 50/50, that uncertainty is the finding.
Sarcasm quietly breaks every text pipeline that assumes words mean what they say. A sarcasm flag is a cheap guardrail โ and running it on-device means you can screen text as it's typed, privately, no round-trip.
Type text, get an irony vs literal verdict live, and compare a literal line with its sarcastic twin side by side.
Run a queue of reviews through a sarcasm pre-check and flag the ironic ones before a sentiment model trusts them.
Probe the hard cases โ deadpan, understatement, context-dependent lines โ and see where the model wavers.
Chain irony + sentiment: when text is ironic, flip the sentiment to recover its "true" meaning.
Binary classification is one call; ask for both scores with top_k:
import { pipeline } from "@huggingface/transformers";
const classify = await pipeline(
"text-classification",
"Xenova/twitter-roberta-base-irony",
); // downloads + caches ~126 MB once
const out = await classify("oh great, another Monday", { top_k: 2 });
// โ [{ label: "irony", score: 0.99 }, { label: "non_irony", score: 0.01 }]
A default problem_type means Transformers.js applies a softmax over the two
classes, so irony and non_irony sum to 1. It runs in a Web Worker so typing never
janks.