โ† All models

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

Spam detector โ€” is this message spam or ham?

A DistilBERT classifier fine-tuned to separate junk from real messages. Paste any message or email and it scores it as SPAM or HAM (not spam) with a confidence โ€” then look inside to see which exact words tripped the spam signal. Everything runs on your device.

At a glance

Modelonnx-community/tanaos-spam-detection-v1-ONNX
Task / pipelinetext-classification
Labelsspam / not_spam (binary; softmax over 2 logits)
ArchitectureDistilBERT fine-tuned for spam / content-moderation (tanaos)
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~136 MB, cached after first load
LicenseMIT
Web APIsWebAssembly, Web Workers โ€” all Baseline widely available

Run it

Paste a message. The verdict re-scores automatically (debounced) a moment after you stop typing. The dual meter shows the full probability split between the two classes.

See inside โ€” the spam-signal words

This is occlusion attribution: we re-run the model with each word removed and see how much the SPAM score shifts (measured in log-odds, because the model is so confident that raw percentages barely move). Remove a word that was pushing "spam" and the score drops โ€” so that word gets a red weight. Remove a word that was keeping it looking legitimate and the score rises โ€” green. No gradients, no hand-waving: just the model's own predictions, N+1 of them.

Why it matters

Spam filtering is the oldest applied text classifier there is โ€” and running it in the browser means you can triage messages the instant they arrive, without a round-trip and without their contents ever leaving the device. That unlocks fast, private, always-available filtering.

Use cases

Basics

Type a message, get SPAM/HAM + confidence, updating live as you type.

Practical

Paste a whole inbox and watch it auto-triage into Inbox and Junk columns.

Wild

Adversarial spam: obfuscate a message and watch how far you can fool the filter.

Multi-model

Spam-gate an inbox, then summarize only the real messages with DistilBART.

How the API works

Classification is one call; top_k returns both class scores:

import { pipeline } from "@huggingface/transformers";

const classify = await pipeline(
  "text-classification",
  "onnx-community/tanaos-spam-detection-v1-ONNX",
); // downloads + caches ~136 MB once

const out = await classify("Claim your FREE prize now!", { top_k: 2 });
// โ†’ [{ label: "spam", score: 0.9994 }, { label: "not_spam", score: 0.0006 }]

"See inside" re-uses that same call: it classifies the full message plus one copy per word with that word deleted (batched in a single pass), then subtracts the SPAM log-odds to attribute the shift to each word. All of it runs in a Web Worker so typing never janks.

References