Sign In
Back to Visual Labs
5-Stage LLM Forward Pass Visualizer
RoPE · Q/K/V · SwiGLU · GQA · Top-P

Transformer Internals & Attention Flow Visualizer

Inspect every layer of a modern autoregressive Transformer forward pass: BPE subword tokenization and Rotary Position Embeddings (RoPE), scaled dot-product Q/K/V attention matrices, Pre-RMSNorm + SwiGLU residual streams, Grouped-Query Attention KV compression, and Temperature / Top-K / Top-P nucleus decoding.

5-Stage Transformer Pipeline
Scaled Dot-Product Attention · Q/K/V Lab
Query (click token)“street” → 37% “street”Keys / Values
15%22%37%Theanimaldidn'tcrossthestreetbecauseitwastootiredTheanimal15didn'tcross22the8street37becauseitwastootired
Softmax(Q·Kᵀ / √d_k) Matrix (12×12)
Q \ K
The
anim
didn
't
cros
the
stre
beca
it
was
too
tire
Click any row to lock Query× = masked future (−∞ → 0.00)
1

Relative Offset Invariance in RoPE

Open Stage 01 (Tokenization & RoPE) and shift query position m and key position n while keeping the offset delta fixed. Observe how 2D complex-plane rotation makes inner products depend strictly on relative distance.

Verifies (m - n) Inner Product Law
2

Why 1 / √d_k Scaling Prevents Saturation

In Stage 02 (Q/K/V Attention Matrix), toggle scaled dot-product normalization off and watch softmax weights spike toward one-hot saturation, collapsing gradient flow on long vectors.

3

Nucleus Sampling & GQA Bandwidth Savings

Compare Stage 04 (GQA KV Heads) against Stage 05 (Top-P Sampler) to see how reducing KV heads slashes decode memory traffic while nucleus thresholds keep generation coherent.

Mechanism Reference · Transformer ArchitectureInteractive Browser Simulator

How Transformer Internals & Attention Flow Visualizer Works

The Transformer Internals Visualizer decomposes an autoregressive LLM forward pass into five inspectable stages: subword tokenization with RoPE complex-plane rotation, causal scaled dot-product attention with GQA KV-head sharing, RMSNorm + SwiGLU FFN residual streams, encoder-decoder cross-attention evolution, and temperature/Top-K/Top-P autoregressive sampling.

Frequently Asked Engineering Questions

Why do modern LLMs use Rotary Position Embeddings (RoPE) instead of absolute sinusoids?
RoPE rotates query and key sub-vectors by position-dependent angles in 2D subspaces so their inner product depends strictly on relative token offset (m - n), preserving sequence length extrapolation.
How does Grouped-Query Attention (GQA) shrink inference memory?
GQA shares fewer key and value projection heads across multiple query heads, reducing the per-token KV cache footprint proportionally while retaining multi-head expressivity.
How do temperature, Top-K, and Top-P work together during decoding?
Temperature rescales raw logits before softmax, Top-K restricts candidates to the K highest-probability tokens, and Top-P (nucleus sampling) dynamically truncates the smallest set whose cumulative mass reaches threshold p.
Free Guided Course
Free · Verifiable Credential

FS-102LLM Systems Foundations

Build a connected mental model from tokens through retrieval evaluation security and operations.

24 concepts~18h self-paced
Start Free Course
Weekly Engineering Dispatch

Get the weekly systems teardown

One technical note per week covering inference bottlenecks, retrieval harnesses, and commit-pinned teardowns.