« home

Single-head attention

Creator: Francois Fleuret (original)

Flow diagram of single-head attention illustrating the equation Attention(Q,K,V)=softmaxrow(QKd)V\displaystyle \mathrm{Attention}(Q, K, V) = \mathrm{softmax}_\text{row} \left( \frac{Q K^\top}{\sqrt{d}} \right) V with border colors to indicate tensor dimensions.


Single-head attention

Download

PNGPNG (HD)PDFSVG

Code

single-head-attention.typ (183 lines)