Basics · 6-Layer Causal Self-Attention · Greedy vs Top-K vs Temperature · Context Sensitivity · Apache-2.0

Inside DistilGPT-2: Decoding Controls & Context Sensitivity

DistilGPT-2 (distilbert/distilgpt2 → Xenova/distilgpt2, 84.91 MB ONNX / 87.02 MB WASM q8) passes every token through 6 causal self-attention layers (12 heads each) where position t can only attend to positions ≤ t. Watch how decoding temperature/top-k and left-context specificity reshape real next-token probabilities and continuations.

1. Greedy vs Top-K Sampling vs Temperature Sweep

Pick a decoding comparison prompt or write your own:

Open-ended continuations diverge dramatically between Greedy (T=0) and Creative (T=1.2) sampling.
Configs completed–
Total sweep latency–
Mean speed–
NaN check–

Awaiting decoding sweep

Initialise DistilGPT-2 above to compare Greedy, Low-Temp, Balanced, and Creative sampling live.

2. Context-Window Continuation & Prompt Sensitivity Lab

In a causal transformer, adding disambiguating words to the left prefix alters attention keys and values across all 6 layers. Compare a short ambiguous prefix against a rich context-anchored prefix and inspect both the next-token Shannon entropy shift (ΔH) and the live continuations.

Extra left context collapses BPE next-token entropy and steers away from competing word senses.
Short H(P)–
Rich H(P)–
Entropy shift (ΔH)–
Pair latency / NaN–

A · Short Prefix

Pending

Run comparison above to inspect next-token candidates for Prefix A.

Live continuation A will appear here.

B · Rich Context Prefix

Pending

Run comparison above to inspect next-token candidates for Prefix B.

Live continuation B will appear here.

3. Inspect Decoding Sweep & Softmax Entropy Source

Show the code — worker.js handleCompareDecoding() 4-way decoding sweep
Show the code — distilgpt2-core.mjs computeTopKFromLogits() 50,257-vocab softmax & entropy