fill-mask Β· text Β· WASM Β· ~67 MB
DistilBERT is BERT, distilled: a student model trained to mimic BERT-base that keeps
~97% of its language understanding at 40% of the size and ~60% of the latency β the canonical
lightweight encoder. 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/distilbert-base-uncased (ONNX build of distilbert/distilbert-base-uncased) |
|---|---|
| Task / pipeline | fill-mask β masked language modelling, loaded via AutoModelForMaskedLM for raw logits |
| Output | A probability over the whole 30,522-token WordPiece vocabulary at each [MASK] |
| Architecture | DistilBERT-base (6 layers, ~66M params), uncased WordPiece tokenizer β distilled from BERT-base |
| Mask token | [MASK] (BERT style) β the same tokenizer + vocabulary as its BERT-base teacher |
| Quantization | q8 (8-bit) ONNX |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~67 MB, cached after first load |
| License | Apache-2.0 |
| Web APIs | WebAssembly, Web Workers β all Baseline widely available |
Write a sentence containing [MASK] (use a sample if
you're not sure). DistilBERT 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 30,522 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 DistilBERT is sure,
high means it's hedging.
top-k entropy: β bits Β· top-1 carries β of the shown mass
DistilBERT is the reference small English encoder: cheap enough to run interactively on any device, yet 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/distilbert-base-uncased");
const out = await unmask("The capital of France is [MASK].");
// β [{ token_str: "paris", score: 0.10, sequence: "β¦" }, { token_str: "nantes", β¦ }]
For the "see inside" surface we go one level lower β AutoModelForMaskedLM β so we can
read the exact logits tensor ([1, sequence, 30522]), 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.