Index Ai Academy
Glossary · Phase 5 · Transformers

Cross-attention

Attention where one sequence looks at another, such as a translation model's decoder reading the encoder's output.

The encoder reads the source sentence, with attention in both directions. The decoder writes the translation one token at a time, with a causal mask. To look back at the source, the decoder uses cross-attention. The queries come from the decoder. The keys and values come from the encoder's outputs. So each word being written can look up the parts of the source it needs.

Try it now

The difference comes down to who can see what.

Learn it properly

Encoders and embedding models · BERT-style models and where they fit. About 30 minutes.

Create a free account See what's in the lesson

Other terms from the same lesson

Never trained an AI?

Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account.

Teach it to write