HMHumberto MouraHM Labs
← HM Labs

HM LABS / 005

Self-attention

Compute scaled dot-product attention over three synthetic tokens.

softmax(QKᵀ / √dₖ) V · dₖ = 2

q = [1, 0]

Keys, values and attention
TokenKVScoreWeight
A1, 01, 00.7070.488
B0.5, 10, 10.3540.343
C-0.5, 0.50.5, 0.5-0.3540.169

Output = [0.573, 0.427]

One head, fixed Q=K, no mask; not a trained Transformer.

Other experiments