fill-mask ยท text ยท WASM ยท ~45 MB
ALBERT does the same job as BERT โ hide a word behind [MASK] and it ranks what
belongs there โ but it carries only ~11.8M parameters where BERT-base carries
~110M, at the same 12-layer depth. Its trick: it
reuses one transformer block over and over and
factorises its embedding table. Type a sentence, watch the guesses and the raw
logits, then open "See inside" to watch the parameter sharing that shrinks it. All on your device.
| Model | Xenova/albert-base-v2 (ONNX build of albert/albert-base-v2) |
|---|---|
| Task / pipeline | fill-mask โ masked language modelling, loaded via AutoModelForMaskedLM for raw logits |
| Output | A probability over the 30,000-token SentencePiece vocabulary at each [MASK] |
| Architecture | ALBERT-base v2 โ 12 layers that share one block (num_hidden_groups 1), 128-dim factorised embedding โ 768 hidden, ~11.8M params |
| Quantization | q8 (8-bit) ONNX (model_quantized.onnx) |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~45 MB (model ~40 MB + tokenizer), cached after first load |
| License | Apache-2.0 |
| Web APIs | WebAssembly, Web Workers โ all Baseline widely available |
Write a sentence containing [MASK] (use the button if you're not sure).
ALBERT predicts the missing word. You can use more than one mask.
BERT and ALBERT have the same shape โ 12 transformer layers, 768 hidden units. The difference is what's stored. BERT keeps 12 independent blocks; ALBERT keeps one and runs your text through it 12 times. Flip the toggle to see the same stack, two ways โ the parameter counts below are computed from the model's real config.
Every layer points at the same weights.
โ
Instead of a giant vocabโ768 table, ALBERT goes vocabโ128โ768. The 128-wide waypoint is where most of the saving hides.
โ
On the prediction side: a language model doesn't output words โ it outputs a logit (a raw score) for every one of its 30,000 vocabulary tokens at the masked position, which we softmax into the probabilities you see above. The โ below is the entropy of the top-k โ low means ALBERT is sure, high means it's hedging.
top-k entropy: โ bits ยท top-1 carries โ of the shown mass ยท total model โ vs BERT-base ~110M
ALBERT is the answer to a very practical question: how small can a real BERT get without changing its shape? By sharing one block across all layers and factorising the embedding, it fits language understanding into a fraction of the memory โ which is exactly what you want when the model has to live inside a browser tab, a phone, or a cache budget.
[MASK] prompts surface
what a compact model did (and didn't) learn, and the associations baked into its training.One mask, ranked predictions with the probabilities and the raw logits behind them.
Plausibility check โ which word fits the blank best, scored across a fixed candidate set.
Bias probe โ swap one word in a template and watch ALBERT's expectations shift.
Fill the mask, then re-rank the candidates by meaning with MiniLM sentence embeddings.
The one-liner uses the fill-mask pipeline โ identical call, tiny model:
import { pipeline } from "@huggingface/transformers";
const unmask = await pipeline("fill-mask", "Xenova/albert-base-v2");
const out = await unmask("The capital of France is [MASK].");
// โ [{ token_str: "paris", score: 0.05, sequence: "โฆ" }, { token_str: "reims", โฆ }]
For the "see inside" surface we go one level lower โ AutoModelForMaskedLM โ so we
can read the exact logits tensor ([1, sequence, 30000]), 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 โ and because ALBERT reuses one block, the on-disk weights are small even though
the compute still runs the full 12-layer depth.