โ† All models

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

Formality detection โ€” read the register, not the sentiment

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.

At a glance

ModelDeepchecks/roberta_base_formality_ranker_onnx (ONNX export of s-nlp/roberta-base-formality-ranker)
Task / pipelinetext-classification
Labelsformal / informal (binary; softmax over 2 logits)
ArchitectureRoBERTa-base fine-tuned on formality-labelled corpora (GYAFC + PT-16)
Quantizationfp32 (32-bit) ONNX โ€” no quantised export ships; this is the graph-optimised full-precision file
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~260 MB, cached after first load (heavier on mobile โ€” see below)
LicenseCC BY-NC-SA 4.0 (non-commercial)
Web APIsWebAssembly, 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.

Run it

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.

See inside โ€” which words set the register

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.

Why it matters

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.

Use cases

Basics

Type text, get formal/informal + a live formality meter.

Practical

Tone-check a draft sentence by sentence and flag the casual ones.

Wild

Slide a message from casual to formal word by word and watch the needle cross over.

Multi-model

Detect the register, then use a T5 paraphraser to rewrite it into the other one.

How the API works

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.

References