โ† All models

text-classification ยท text ยท WASM ยท ~126 MB

Irony detection โ€” does this text mean the opposite?

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.

At a glance

ModelXenova/twitter-roberta-base-irony
Task / pipelinetext-classification (single-label)
Labelsirony vs non_irony; softmax (the two scores sum to 1)
ArchitectureRoBERTa-base (125M params) fine-tuned on TweetEval irony (cardiffnlp)
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~126 MB, cached after first load
LicenseUnspecified upstream โ€” research/demo use; base RoBERTa is MIT
Web APIsWebAssembly, Web Workers โ€” all Baseline widely available

Run it

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.

See inside โ€” two competing probabilities

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.

Why it matters

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.

Use cases

Basics

Type text, get an irony vs literal verdict live, and compare a literal line with its sarcastic twin side by side.

Practical

Run a queue of reviews through a sarcasm pre-check and flag the ironic ones before a sentiment model trusts them.

Wild

Probe the hard cases โ€” deadpan, understatement, context-dependent lines โ€” and see where the model wavers.

Multi-model

Chain irony + sentiment: when text is ironic, flip the sentiment to recover its "true" meaning.

How the API works

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.

References