Attention

The model turns each token into a query, key, and value vector (Q, K, and V). Query-key scores set the attention weight for each other token. This example uses random projections. It shows the calculation but not weights learned by a model.

Input Sequence

Head Dimension (d_head)

Hover over a row in any matrix to see which tokens it attends to.

Q, K, V Projections

Click a preset to change the settings.