โ† All models

fill-mask ยท text ยท WASM ยท ~45 MB

ALBERT โ€” the tiny BERT that reuses one layer

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.

At a glance

ModelXenova/albert-base-v2 (ONNX build of albert/albert-base-v2)
Task / pipelinefill-mask โ€” masked language modelling, loaded via AutoModelForMaskedLM for raw logits
OutputA probability over the 30,000-token SentencePiece vocabulary at each [MASK]
ArchitectureALBERT-base v2 โ€” 12 layers that share one block (num_hidden_groups 1), 128-dim factorised embedding โ†’ 768 hidden, ~11.8M params
Quantizationq8 (8-bit) ONNX (model_quantized.onnx)
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~45 MB (model ~40 MB + tokenizer), cached after first load
LicenseApache-2.0
Web APIsWebAssembly, Web Workers โ€” all Baseline widely available

Run it

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.

See inside โ€” the shared layer that makes ALBERT tiny

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.

The 12-layer stack

Every layer points at the same weights.

โ€“

Factorised embedding

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.

Why it matters

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.

Use cases

Basics

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

Practical

Plausibility check โ€” which word fits the blank best, scored across a fixed candidate set.

Wild

Bias probe โ€” swap one word in a template and watch ALBERT's expectations shift.

Multi-model

Fill the mask, then re-rank the candidates by meaning with MiniLM sentence embeddings.

How the API works

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.

References