DAILY PRACTICEBuild your AI engineering skills, one problem at a time.Try today's challenge
InferenceAIStart learning path

Deep Learning · Intermediate

Attention

Attention combines values using weights derived from a query and keys.

TRY IT YOURSELF

Explore attention weights

Select an illustrative query; scores are dot products of fixed two-dimensional vectors.

AI
43.4%
learns
35.1%
context
21.4%

How it works

Scaled dot-product attention computes query-key similarities, divides by the square root of key width, applies softmax, and uses the weights to combine values.

A concrete example

In the interactive example, select a query token to see how its illustrative vector compares with the keys for three tokens.

Watch for this

Attention weights are conditional on the layer, head, and input; they should not automatically be interpreted as a complete explanation.

Try it yourself

Select each query and observe how the distribution changes. Then explore multi-head attention in the architecture walkthrough.

Continue to practice →

Read the source: Attention Is All You Need ↗

Related concepts

Neural networks →

Backpropagation →

CNNs →