text-generation · 84.91 MB ONNX (87.02 MB total) · WASM q8 · 82M · 6 layers · Apache-2.0

DistilGPT-2 — 6-Layer Causal BPE Streaming Workbench

distilbert/distilgpt2 (ONNX export Xenova/distilgpt2, Apache-2.0) distills GPT-2 Small (124M, 12 layers) down to 82M parameters and 6 transformer decoder layers (768 hidden, 12 heads, 50,257 byte-level BPE vocab, max_position_embeddings=1024) — streaming real next-token continuations in CPU WebAssembly via TextStreamer.

Upstream Card distilbert/distilgpt2
Loaded ONNX ID Xenova/distilgpt2
Task & Arch text-generation · GPT2LMHeadModel
Weights & Quant 84.91 MB ONNX (87.02 MB) · WASM q8
Dimensions 6 layers · 768d · 12 heads · 1024 ctx
Vocab & License 50,257 BPE · Apache-2.0 · PPL 21.1

1. Causal BPE Next-Token Streaming Workbench

Pretrained base completion model (not instruction-tuned): DistilGPT-2 runs pipeline("text-generation", "Xenova/distilgpt2", { device: "wasm", dtype: "q8" }) via shared @huggingface/transformers@3.7.5 off the main thread. Feed a natural prose, story, tech, or code prefix below — DistilGPT-2 predicts what comes next rather than answering chat instructions. Special token: <|endoftext|> (BOS/EOS/UNK ID 50256).

Choose a writing, code, story, or technical lead preset:

Upload, drop, or paste a local file (.txt, .md, .csv, .json) File contents stay 100% on your device. Drag-and-drop or press Ctrl/Cmd+V outside text fields.
First-token (TTFT)–
Decode speed–
In + Out / 1024–
Total latency–
NaN check–
Backend / dtypeWASM · q8

Live Streamed Continuation

Idle
Initialise DistilGPT-2 above to stream causal BPE tokens locally on WebAssembly.

2. See Inside: Byte-Level BPE (Ġ / Ċ) & Next-Token Probabilities

GPT-2 uses a 50,257-entry byte-level BPE tokenizer where leading spaces become Ġ (U+0120) and newlines become Ċ (U+010A). Inspect the exact tokens of your prompt + continuation alongside the real top-10 next-token probability distribution over all 50,257 vocabulary entries.

Next-Token Candidate Probabilities

Entropy –

Full 50,257-vocab Shannon entropy H(P) will appear after a live forward pass.

Run a prompt above to inspect live logits from pipe.model(inputs).

BPE Whitespace (Ġ) & Subword Inspector

Space prefix (Ġ) Subword continuation Newline (Ċ) Special (50256)

Tokenization breakdown will appear after running DistilGPT-2.

Run generation to inspect Ġ whitespace and subword splits.

3. Why DistilGPT-2 Matters · Ladder & Source

By distilling 12 layers of GPT-2 Small down to 6 layers with a triple loss (language modeling + cosine hidden-state alignment + KL divergence), DistilGPT-2 keeps 82M parameters and fits into an 84.91 MB quantized ONNX graph that loads quickly in any browser without a GPU. Explore the full 5-route ladder below:

Show the code — worker.js ensureLoaded() shared Transformers.js pipeline init
Show the code — worker.js runSingleGeneration() TextStreamer + BPE + real nanCount