text-classification · text · WASM · ~13 MB
A tiny distilled BERT with a dedicated 10-class topic head reads a headline or article and picks its desk — Sports, Business & Finance, Politics, Science, Health and more — with a confidence, in a single forward pass. Type below and watch the newsroom board auto-tag it live. Nothing leaves your device.
| Model | tarekziade/topic_classification |
|---|---|
| Task / pipeline | text-classification |
| Labels | 10 fixed topics: Society & Culture · Science & Mathematics · Health · Education & Reference · Computers & Internet · Sports · Business & Finance · Entertainment & Music · Family & Relationships · Politics & Government (multi-label — an independent sigmoid score per topic) |
| Architecture | xtremedistil-l6-h256-uncased (6-layer, 256-hidden distilled BERT) with a sequence-classification head |
| Quantization | q8 (8-bit) ONNX |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~13 MB, cached after first load |
| License | MIT |
| Web APIs | WebAssembly, Web Workers — all Baseline widely available |
Type a headline or paste a paragraph. It re-tags automatically (debounced) a moment after you stop typing. The verdict shows the top topic; the bars below show the full distribution.
This head is multi-label: it gives every topic its own independent 0–100% score (a sigmoid per label), so the bars below don't add up to 100% — a story can genuinely belong to several desks at once. A clear headline lights one bar; a cross-topic one lights two or three. The top bar is the primary desk; the rest tell you what else it touches.
This is a dedicated classification head: the label set (these 10 topics) is baked in at training time, and one forward pass produces a probability for every label at once — fast, tiny (~13 MB), and calibrated to exactly this taxonomy.
A zero-shot classifier (like BART-MNLI) works completely differently: you supply the candidate labels at query time, and it runs a separate natural-language-inference pass for each label ("does this text entail the topic X?"). That's flexible — any labels, no retraining — but it costs one model run per label and isn't tuned to a fixed set.
Rule of thumb: a stable taxonomy you classify constantly (a news desk, a support queue) wants a dedicated head; an ad-hoc or changing label set wants zero-shot.
Routing text by topic is the plumbing behind every content feed, newsroom CMS, and support desk. Doing it in the browser means you can categorise a stream the instant it arrives — no server round-trip, no per-call bill, and no article text leaving the device.
Type a headline, get its topic + confidence, updating live as you type.
Paste a feed of headlines and watch them auto-sort onto newsroom desks.
Craft a cross-topic headline and watch the model get genuinely torn — an ambiguity meter.
Route an article to its desk, then summarise it with DistilBART — two models, one pipeline.
Classification is one call; top_k returns the full distribution:
import { pipeline } from "@huggingface/transformers";
const classify = await pipeline(
"text-classification",
"tarekziade/topic_classification",
{ dtype: "q8" },
); // downloads + caches ~13 MB once
const out = await classify("The Fed raised interest rates.", { top_k: 10 });
// → [{ label: "Business & Finance", score: 0.99 }, { label: "Politics & Government", score: 0.96 }, … ]
// multi-label: each score is independent (a sigmoid), so they don't sum to 1.
Asking for top_k: 10 (the number of classes) returns every topic's score, sorted — that's
what powers the bars. All of it runs in a Web Worker so typing never janks.