Self-attention · Numerical visual lab

Q, K, V: Watch Attention Work

Follow a token as it compares Queries with Keys, turns scores into weights, and combines Value vectors. Step through each calculation or change the numbers yourself.

SENTENCE
“The cat eats fish.”
Selected query token: cat
Ready · Step 1 of 5

Follow the signal through self-attention

Select a step to inspect the numbers

01 / Input token vectors

Each token starts with a small illustrative vector.

INPUT

Selected token catCurrent step 1 / 5Demo values editable

Attention weight chart

How much the selected token attends to each position.

LIVE CHART

Weights update when the score controls change. Hover or focus a bar to inspect its value.

Make the numbers yours

Change the illustrative scaled scores. Softmax weights and the weighted output recalculate immediately.

0.0
2.8
1.4
0.0
Raise a score to give that token more attention weight, all else equal.

Inspect the Value vectors

These simple 2D Value vectors are for teaching. Their weighted sum changes with the attention weights.

Attention weights determine how much each Value vector contributes to the output.
Educational simplification: real Q, K, and V are learned linear projections of each token representation. The scores here are illustrative scaled scores; real attention commonly uses QKᵀ/√dₖ, then a softmax, followed by a weighted sum of V. Real models use much larger vectors and multiple heads.
Go deeper into QKV

You have just stepped through Query, Key and Value on a four-token sentence. Each subtopic below takes one piece of that calculation and explains it on its own.

7 subtopics — click to study
Query 🔴 Key 🔴 Value 🔴 Q × K 🔴 Scaling 🔴 Softmax 🔴 Attention × V 🔴
🧪
RASL Pull · Sprint S-04 — Parallel Learning
You're reading this because RASL is blocked on: how does Q/K/V actually compute relevance scores — why does the verifier weight some evidence higher?
These pages explain the math behind relevance scoring. The intuition — query asking keys, values carrying payload — applies directly when designing how verifier.py scores evidence. Return to reliable-agent-lab/agent/verifier.py and continue building. Read only what unblocks you.
🔨 Lab: M-05 → scaled_dot_product_attention() 🔁 Q/K/V intuition → RASL evidence weighting design 📋 View full parallel plan →
← Back to Roadmap
This page 0:00
This session 0:00
Total (all pages) 0:00
Today 0:00
▶ Running
📊 View all study stats →
0:00 studying