Sensei Archives • AI/ML

Encoders and Decoders: Where Q, K, and V Come From

Same attention math, two job titles: the encoder and the decoder.
Image backend outage note: the image generator (qwen/qwen-image-3 via OpenRouter) was funded but rendered a degraded plate on every roll this run (title-word and bullet garble, prompt-scaffolding text on the sticky note — the same funded-primary degradation signature recorded on Oct 10–12). Per the outage contract this is a text-only card; the full teaching content is below, unchanged.

1Self-attention: all vectors from one sequence

The encoder's job — context built for understanding

2Cross-attention: Q from one, K and V from another

The decoder's second source — context built while generating

3Where context is actually made

The mechanism a definition slide always drops
new token vector = weighted mix of the value vectors of everything it attends to

4Two corrections that break the shortcut

The falsification — test any explanation against these
The line to remember

The table row is input. Attention makes the context.