SESK: Stuff Everyone Should Know · sesk.info/ai-cross-attention-sources
In Transformer cross-attention, where do queries and key-value pairs come from?
Queries come from the decoder, keys and values from the encoder.
- All come from the tokenizer
- Decoder queries, encoder keys and values ✔
- Encoder queries, dataset keys only
Why: The decoder asks what input information is relevant using its queries. The encoder output supplies the keys to match and values to retrieve.
Huh, didn't know that: This lets every decoder position attend over all encoded input positions.
The decoder asked the questions, and the encoder had the key values.
Like this card?
References
Answer: Decoder queries, encoder keys and values. The decoder asks what input information is relevant using its queries. The encoder output supplies the keys to match and values to retrieve.
- Attention Is All You Need arxiv.org/html/1706.03762
queries come from the previous decoder layer, and the memory keys and values come from the output of the encoder
Checked 2026-10-10.
Think this answer is wrong? Tap "Challenge this answer" on the card in the game and tell us why.
More stuff everyone should know
That's stuff everyone should know.