Inside a T5-style encoder-decoder, which sub-layer reads the encoder outputs, and through which projection?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
The decoder's cross-attention sub-layer reads the encoder outputs: Q is projected from the decoder hidden state; K and V are projected from the encoder's final-layer hidden states.
Picture a translator with a notebook open to a page of English. The translator's pen is moving across a new page in French. Every few seconds the translator's eyes flick to the English page and pull a phrase, then write the equivalent in French. The pen position and what they want to write are the query. The English notebook is what they read from. Cross-attention is exactly this: the decoder asks the question (Q from its own state), and the encoder's page is what it reads (K and V from the encoder). The two stacks meet at this one sub-layer.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
Name the three sub-layers in the decoder block, place cross-attention in the middle, identify Q from decoder and K, V from encoder, note the dedicated cross-attention W_K and W_V per layer, and close with cross-attention K, V caching as the serving win.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Believing the encoder and decoder share QKV projection matrices. Cross-attention uses dedicated W_K and W_V matrices separate from the decoder's self-attention projections.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.