← All models

fill-mask Β· text Β· WASM Β· ~120 MB

RoBERTa β€” predict the missing English word

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.

At a glance

ModelXenova/roberta-base (ONNX build of FacebookAI/roberta-base)
Task / pipelinefill-mask β€” masked language modelling, loaded via AutoModelForMaskedLM for raw logits
OutputA probability over the whole 50,265-token byte-level BPE vocabulary at each <mask>
ArchitectureRoBERTa-base (12 layers, ~125M params), byte-level BPE tokenizer
Mask token<mask> (RoBERTa style), not BERT's [MASK]
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~120 MB, cached after first load
LicenseMIT
Web APIsWebAssembly, Web Workers β€” all Baseline widely available

Run it

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.

See inside β€” logits, not just a guess

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.

Why it matters

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.

Use cases

Basics

One mask, ranked predictions with probabilities and the raw logits behind them.

Practical

A word-choice aid β€” score your own candidate words at the blank across writing templates.

Wild

Does RoBERTa know its proverbs? A batch probe of English idioms and sayings.

How the API works

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.

References