text-classification ยท text ยท WASM ยท ~260 MB
A RoBERTa fine-tuned to judge register โ is this written formally (a report, a cover letter) or informally (a text to a friend)? This is stylistic classification, orthogonal to what the text is about or how positive it feels. Type below and watch the formality meter move, then see which words carry the tone. Nothing leaves your device.
| Model | Deepchecks/roberta_base_formality_ranker_onnx (ONNX export of s-nlp/roberta-base-formality-ranker) |
|---|---|
| Task / pipeline | text-classification |
| Labels | formal / informal (binary; softmax over 2 logits) |
| Architecture | RoBERTa-base fine-tuned on formality-labelled corpora (GYAFC + PT-16) |
| Quantization | fp32 (32-bit) ONNX โ no quantised export ships; this is the graph-optimised full-precision file |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~260 MB, cached after first load (heavier on mobile โ see below) |
| License | CC BY-NC-SA 4.0 (non-commercial) |
| Web APIs | WebAssembly, Web Workers โ all Baseline widely available |
Because there's no quantised build, this model is a ~260 MB fp32 download and needs a few hundred MB of memory to run โ comfortable on desktop and modern phones, but heavier than most demos here. It's cached after the first load and never re-downloaded silently.
Type anything. The register re-scores automatically (debounced) a moment after you stop typing. The meter shows how far toward formal or informal the whole text reads.
This is occlusion attribution: we re-run the model with each word removed and see how much the formal score shifts (in log-odds). Remove a word that was pulling the text formal and the score drops โ that word gets a blue weight. Remove a casual word and the score rises โ amber. No gradients, just the model's own predictions, N+1 of them. This is what "register cues" look like: "grateful", "convenience" pull formal; "hey", "u", "lol" pull informal.
Register is a different axis from sentiment or topic: the same message can be warm or cold, positive or negative, and still be phrased formally or casually. Scoring it in the browser means a writing tool can react to tone as the user types โ privately, with no round-trip.
Type text, get formal/informal + a live formality meter.
Tone-check a draft sentence by sentence and flag the casual ones.
Slide a message from casual to formal word by word and watch the needle cross over.
Detect the register, then use a T5 paraphraser to rewrite it into the other one.
Classification is one call. This repo uses a non-standard file layout, so we point at the exact file:
import { pipeline } from "@huggingface/transformers";
const classify = await pipeline(
"text-classification",
"Deepchecks/roberta_base_formality_ranker_onnx",
{ subfolder: "", model_file_name: "model_optimized", dtype: "fp32" },
); // the ONNX sits at the repo root, not under onnx/
const out = await classify("hey can u take a look?", { top_k: 2 });
// โ [{ label: "informal", score: 0.994 }, { label: "formal", score: 0.006 }]
"See inside" re-uses that same call: it classifies the full text plus one copy per word with that word deleted (batched in a single pass), then subtracts the formal log-odds to attribute the shift to each word. All of it runs in a Web Worker so typing never janks.