LearnBenchStart learning →

AI Research Scientist · Attention Mechanisms & Kernels

Self-attention mechanism (QKV)

Real lesson card · Page 1 of 4

Self-attention mechanism (QKV)

Query, Key, and Value vectors

For each token, three separate learned weight matrices WQW_Q, WKW_K, WVW_V project its embedding into a query vector qq, a key vector kk, and a value vector vv — three distinct roles computed from the same input.
Example
A token’s embedding xx times WQW_Q gives q=WQxq=W_Q x, different from k=WKxk=W_K x using that same xx: one token, three separate vectors.

Recall check from the same lesson

If the sqrt(d_k) scaling step is skipped, larger key dimensions make raw dot-product scores spread out more, pushing softmax toward a near one-hot output and shrinking the gradients that flow back through the attention weights.

Sources

· Editorial policy

One sitting · 20–30 minutes

A focused session on your AI Research Scientist interview

LearnBench starts from what you already know — skip what you have, master what you’re missing.

Start now

More Attention Mechanisms & Kernels questions