INTERACTIVE NOTEBOOK

Inside the model

One context. 28 layers. 448 attention heads.
Trace how the prediction at each token changes.

MODEL Qwen3-0.6B28 LAYERS / 16 Q HEADS / 8 KV HEADSCheckpoint · loading…
CONTEXT → TRANSFORMER → NEXT TOKEN
Context tokens—

Exact model tokenization

Next token · layer 28—

Probability over the full vocabulary

Forward pass—

28 layers × 16 heads

Text→tokens→28 layers→predictions

Every token under the microscope

Choose a template or enter your own context.
Layer predictions and attention maps will appear here after the run.

Computed from the actual Qwen3-0.6B weights

MODEL & METHOD

How to read this experiment

01

The actual model

Qwen3-0.6B has 28 decoder layers, 16 query heads, and 8 KV heads. A full causal forward pass includes attention and MLP blocks. With GQA, query head h uses KV head ⌊h / 2⌋.

02

One LM head for every layer

After each layer, apply the final RMSNorm and shared language model head, then softmax over all 151,936 tokens. This is a logit lens: early layers were not trained to predict text independently. The final layer gives the standard model prediction.

03

Reasoning and the template

Chat uses the official apply_chat_template with enable_thinking. Disabling reasoning adds an empty <think>…</think> block. In Raw mode, you supply the control tokens and prefix. <think> is an added token with special=false in the tokenizer configuration.

04

Attention weights

Each head has a separate map after softmax, with an attention mask. The mean averages these probabilities across all query heads in the selected layer. Each row sums to approximately 100%. Color amplification only affects the display. Attention is not a complete measure of influence: values, output projections, MLPs, and the residual stream also contribute.

hₜ⁽ˡ⁾ → RMSNorm → LM head → softmax → argmax / A⁽ˡ,ʰ⁾ = softmax(QKᵀ / √128 + causal mask)

Float32 computation from the BF16 checkpoint; maps are stored in float16. The inspector limit is 512 tokens, including the continuation; input is never truncated. Checkpoint ↗