LatentLens · Version 2 of MoveLens

Understand modern AI from the inside out.

  1. Intuition
  2. Mechanism
  3. System
  4. Security
  5. Research
  1. 1StorybookBuild intuitionYou learn: Fourteen short read-aloud chapters: next-word guessing, tokens, attention, training, agents, safety, history to 2026.Assumes: Nothing.Why it matters: A picture to hang every later mechanism on.
  2. 2MasteryUnderstand the real mechanismYou learn: 30 topics across six levels: the Qwen3-8B transformer, training and post-training, inference and serving, RAG, agents and MCP, interpretability.Assumes: Basic algebra and some Python; the Storybook helps.Why it matters: Lets you trace one token, one training step and one request without hand-waving.
  3. 3SecurityTrust boundaries, failure modes, defensesYou learn: 17 topics from assets and trust boundaries to prompt injection, poisoning, agent risks and red-team method, plus local synthetic labs.Assumes: Mastery levels 1, 4 and 5.Why it matters: Once a model reads untrusted text and can act, security is a design property of the whole system.
  4. 4ResearchInvestigate model internalsYou learn: Hidden states by layer, RMSNorm, linear probes, the Recall Microscope, and the human-vs-AI question.Assumes: Mastery levels 1 and 6.Why it matters: Moves from what the model outputs to where inside it a signal becomes accessible.
Professor mode: a concise technical walkthrough of Qwen3-8B internals, normalization, latent states and the Recall Microscope.Open professor mode →Daily review
LatentLens · Version 2 of MoveLens

How does this piece of text become the next token?

Follow one sentence through a real language model, Qwen3-8B-Base, one step at a time. You predict, change something, and see what happens. No background is needed to start; the Mechanics and Research levels open the mathematics and the recorded measurements.

The example

The researcher opened the notebook ?

residual streamnormalizationattentionMLP

Every number on these pages is labelled: Toy calculation Recorded Qwen measurement Experiment pending

Three things to try first

  1. Glass BoxOpen one real Qwen block and re-check its mathEvery tensor recorded from Qwen3-8B. Your browser re-derives ten operations and shows that only Qwen's real formulas fit: try LayerNorm, ReLU or the wrong rotation.Open →
  2. Mistake, or another version?9 of Qwen's 73 Gettysburg misses are another Lincoln manuscript's wordingLincoln wrote five copies of the Gettysburg Address. Several of Qwen's 'errors' match another copy word for word, which matters for any recall plateau.Open →
  3. You vs QwenGuess the next word against an 8B modelThe recall experiment as a game: the true text so far, your guess, and Qwen's recorded answer for the same position.Open →

The journey

Eight connected scenes. Each one asks a question, gives you one thing to change, and shows the consequence.

  1. 1outputText becomes tokensWhat does the model actually read?
  2. 2residual streamTokens become vectorsHow does a token turn into numbers?
  3. 3residual streamA block updates the representationWhat happens inside one block, and in what order?
  4. 4attentionAttention mixes informationWhich earlier words can this word look at?
  5. 5MLPThe MLP transforms each tokenWhat does the MLP do that attention does not?
  6. 6residual streamBlocks repeatIs block 30 the same as block 3?
  7. 7outputScores become the next tokenHow does a list of scores become one chosen word?
  8. 8normalizationLearning versus usingWhen do the model's weights change?

Labs

Focused experiments that go deeper than the journey.

All labs →
Research workspace Experiment pending

Can Qwen's internal representations tell human-written from AI-generated text, and where? Plan, controls and status.

Recall evidence Recorded Qwen measurement

Teacher-forced next-token accuracy on a famous text and an unpublished control (Gettysburg Address 76.9%, bfloat16), traced through the layers.

Professor demo5 steps

A keyboard-controlled presentation with presenter notes and optional deeper sections.

Real Qwen: the exact block order

Recorded Qwen measurement· checked in the installed transformers source

Qwen/Qwen3-8B-Base @ 49e3418f: 36 blocks like this, then a final RMSNorm and an output projection to 151,936 scores (not tied to the embedding).

  1. 1input_layernormRMSNorm over 4,096 numbers (ε 0.000001)
  2. 2q_proj, k_proj, v_projQ: 32 heads × 128; K and V: 8 heads × 128; no bias
  3. 3q_norm, k_normRMSNorm over each 128-number Q and K head vector (V is not normalized)
  4. 4rotary embeddingRoPE on Q and K, θ = 1,000,000, rotate-half pairing
  5. 5causal attentiongrouped-query: 4 query heads per KV head; scale 1/√128
  6. 6o_proj4,096 → 4,096
  7. 7+ residualfirst residual addition
  8. 8post_attention_layernormRMSNorm, its own learned gain
  9. 9mlp (SwiGLU)down(SILU(gate(x)) × up(x)): 4,096 → 12,288 → 4,096
  10. 10+ residualsecond residual addition
1Architecture overview

Qwen3-8B-Base, verified: 36 blocks, 4,096-wide residual stream

Every value below was read from the instantiated model, the installed transformers implementation, the checkpoint's config and tensor headers, and the model card. None is typed in from memory or from generic transformer assumptions.

Verified facts

Recorded Qwen measurement· verified from the checkpoint
QuantityValueVerified from
ModelQwen/Qwen3-8B-Base @ 49e3418fcheckpoint
Transformer blocks36model object
Hidden size (residual stream width)4,096model object
MLP intermediate size12,288model object
Query heads / KV heads32 / 8 (4 query heads per KV head)model object
Head dimension128model object
Vocabulary (embedding rows / tokenizer entries)151,936 / 151,669model object, tokenizer
NormalizationQwen3RMSNorm (RMSNorm), eps 1e-6; plus Q/K RMSNorm over 128 dimsimplementation source
PositionsRoPE on Q and K, theta 1,000,000, rotate-half pairing, 64 frequenciesconfig, implementation source
MLP activationSILU inside SwiGLU (gate, up, down; no bias)config, implementation source
Attention biasnoneconfig
Embedding and LM head tied?no, stored separatelymodel object, safetensors
Context length (max position embeddings)32,768config, model card
Sliding windownot usedconfig
Parameters8,190,735,360 total; 6,946,075,648 excluding embedding and LM headmodel object = stored tensors
Per block192,946,432 (attention 41,943,040, MLP 150,994,944, norms 8,448)model object
Stored weightsbfloat16, 15.3 GiBsafetensors index

Model card (Pretraining): 8.2B parameters, 6.95B non-embedding, 36 layers, 32 for Q and 8 for KV, context 32,768. Consistent with the counts above.

Order of operations, checked in the installed source (13/13)

transformers 5.18.0
  • ✓ Block is pre-norm: input_layernorm is applied before self_attn, and the residual is added after it
    residual = hidden_states
    hidden_states = self.input_layernorm(hidden_states)
    hidden_states, _ = self.self_attn(
    hidden_states = residual + hidden_states
    residual = hidden_states
    hidden_states = self.post_attention_layernorm(hidden_states)
    hidden_states = self.mlp(hidden_states)
    hidden_states = residual + hidden_states
  • ✓ Second sub-layer: post_attention_layernorm, then MLP, then the second residual addition
    hidden_states = self.post_attention_layernorm(hidden_states)
    hidden_states = self.mlp(hidden_states)
  • ✓ q_norm and k_norm are RMSNorms over head_dim (one head vector at a time), not over hidden_size
    self.q_norm = Qwen3RMSNorm(self.head_dim, eps=config.rms_norm_eps)  # unlike olmo, only on the head dim!
    self.k_norm = Qwen3RMSNorm(self.head_dim, eps=config.rms_norm_eps)  # thus post q_norm does not need reshape
  • ✓ q_norm / k_norm are applied after the projection and reshape to heads, and before RoPE
    query_states = self.q_norm(self.q_proj(hidden_states).view(hidden_shape)).transpose(1, 2)
    key_states = self.k_norm(self.k_proj(hidden_states).view(hidden_shape)).transpose(1, 2)
    value_states = self.v_proj(hidden_states).view(hidden_shape).transpose(1, 2)
    query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
  • ✓ V is not normalized and not rotated
    value_states = self.v_proj(hidden_states).view(hidden_shape).transpose(1, 2)
    key_states, value_states = past_key_values.update(key_states, value_states, self.layer_idx)
  • ✓ RoPE rotates Q and K only (applied inside attention, not added to the residual stream)
    query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin)
  • ✓ RoPE uses the rotate-half pairing (dimension i with i + head_dim/2), not interleaved pairs
    x1 = x[..., : x.shape[-1] // 2]
    x2 = x[..., x.shape[-1] // 2 :]
    return torch.cat((-x2, x1), dim=-1)
  • ✓ Attention scores are scaled by head_dim ** -0.5
    self.scaling = self.head_dim**-0.5
  • ✓ Grouped-query attention: K/V heads are shared by num_attention_heads // num_key_value_heads query heads
    self.num_key_value_groups = config.num_attention_heads // config.num_key_value_heads
  • ✓ Attention is causal
    self.is_causal = True
  • ✓ MLP is SwiGLU: down_proj(act(gate_proj(x)) * up_proj(x))
    down_proj = self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))
    return down_proj
  • ✓ RMSNorm computes in float32: x * rsqrt(mean(x^2) + eps), then multiplies by a learned gain (no bias, no mean subtraction)
    hidden_states = hidden_states.to(torch.float32)
    variance = hidden_states.pow(2).mean(-1, keepdim=True)
    hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
    return self.weight * hidden_states.to(input_dtype)
  • ✓ A final RMSNorm (model.norm) follows the last decoder layer
    hidden_states = self.norm(hidden_states)
The whole forward pass, with verified shapes
  1. Text
    string
  2. Tokenizer
    T pieces
  3. Token IDs
    [B, T]
  4. Embeddings
    [B, T, 4096]
  5. 36 transformer blocks
    [B, T, 4096]
  6. Final RMSNorm
    [B, T, 4096]
  7. LM head
    [B, T, 151,936]
  8. Softmax
    probabilities
  9. Next token
    1 id
Version 1 · MoveLens

What does the model output?

A Regan-inspired statistical baseline, Maia-3 and Qwen3-8B compared on the same chess decisions, using their output probabilities.

Open Version 1
Version 2 · LatentLens

What is happening inside the model that produces those outputs?

The same Qwen3-8B-Base checkpoint, opened up: residual stream, normalization, attention, MLP, and what a linear probe can read at each depth.

  1. 1Understand the architecture
  2. 2Instrument the architecture
  3. 3Measure the representations
  4. 4Test research hypotheses
Which models can be probed

Internal probe models and black-box generators

Internal probe model

Weights and hidden states are available, so we can read the residual stream, RMSNorm inputs and outputs, attention and MLP updates. Example: Qwen3-8B-Base (open weights). Only models of this kind appear in LatentLens's internal measurements.

Black-box generator

Only text comes back through an API. Examples include proprietary frontier systems. Their generated text can be studied as data (for example as the AI side of a human-vs-AI dataset), but their residual streams, normalization states, attention and MLP activations are not accessible and are never shown here.

Every tensor shape on this site refers to Qwen3-8B-Base only.