fill-mask Β· text Β· WASM Β· ~120 MB
RoBERTa is the canonical βBERT, trained properlyβ: the same 12-layer encoder,
but trained ten times longer on 160 GB of English. Its one job here is
masked language modelling: hide a word behind <mask> and it
ranks what belongs there. Type a sentence with a mask and see its guesses, plus the exact
logits it computed. Everything runs on your device.
| Model | Xenova/roberta-base (ONNX build of FacebookAI/roberta-base) |
|---|---|
| Task / pipeline | fill-mask β masked language modelling, loaded via AutoModelForMaskedLM for raw logits |
| Output | A probability over the whole 50,265-token byte-level BPE vocabulary at each <mask> |
| Architecture | RoBERTa-base (12 layers, ~125M params), byte-level BPE tokenizer |
| Mask token | <mask> (RoBERTa style), not BERT's [MASK] |
| Quantization | q8 (8-bit) ONNX |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~120 MB, cached after first load |
| License | MIT |
| Web APIs | WebAssembly, Web Workers β all Baseline widely available |
Write an English sentence containing <mask> (use a sample if
you're not sure). RoBERTa predicts the missing word. You can use more than one mask.
A language model doesn't output words β it outputs a logit (a raw, unbounded
score) for every one of its 50,265 vocabulary tokens at the masked position. We
softmax those into probabilities. The bars above show the probability; the
logit beside each is the actual number the network produced. Watch how a confident
prediction ("Paris") sits far above the pack in logit space, while an ambiguous slot spreads the
mass out. The entropy below is computed over the shown top-k β low means RoBERTa is sure,
high means it's hedging.
top-k entropy: β bits Β· top-1 carries β of the shown mass
RoBERTa is the reference English encoder: it reads context well enough that its masked-word distribution is a usable probability model of English. Because it scores every word in context, you can ask it what fits, how strongly, and compare alternatives β all locally, with no prompt engineering and no API bill.
The one-liner uses the fill-mask pipeline:
import { pipeline } from "@huggingface/transformers";
const unmask = await pipeline("fill-mask", "Xenova/roberta-base");
const out = await unmask("The capital of France is <mask>.");
// β [{ token_str: " Paris", score: 0.83, sequence: "β¦" }, { token_str: " Lyon", β¦ }]
For the "see inside" surface we go one level lower β AutoModelForMaskedLM β so we can
read the exact logits tensor ([1, sequence, 50265]), slice the row at the
<mask> position, and softmax it ourselves. That's the only way to show the real
logit values, not just the pipeline's rounded scores. All of it runs in a Web Worker so the page
never janks.