← All models

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

DistilBERT β€” the small, fast BERT that predicts the missing word

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.

At a glance

ModelXenova/distilbert-base-uncased (ONNX build of distilbert/distilbert-base-uncased)
Task / pipelinefill-mask β€” masked language modelling, loaded via AutoModelForMaskedLM for raw logits
OutputA probability over the whole 30,522-token WordPiece vocabulary at each [MASK]
ArchitectureDistilBERT-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
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~67 MB, cached after first load
LicenseApache-2.0
Web APIsWebAssembly, Web Workers β€” all Baseline widely available

Run it

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.

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 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.

Why it matters

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.

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 DistilBERT 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/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.

References