HM LABS / 005
Self-attention
Compute scaled dot-product attention over three synthetic tokens.
softmax(QKᵀ / √dₖ) V · dₖ = 2
q = [1, 0]
| Token | K | V | Score | Weight |
|---|---|---|---|---|
| A | 1, 0 | 1, 0 | 0.707 | 0.488 |
| B | 0.5, 1 | 0, 1 | 0.354 | 0.343 |
| C | -0.5, 0.5 | 0.5, 0.5 | -0.354 | 0.169 |
Output = [0.573, 0.427]
One head, fixed Q=K, no mask; not a trained Transformer.
Other experiments
Sigmoid function ↗
Explore the effect of weight and bias on a logistic curve.
Gradient descent ↗
Observe how the learning rate changes convergence on a quadratic loss.
Neural network ↗
Trace a forward pass through a fixed 2–2–1 network.
Embedding space ↗
Rank synthetic 2D vectors by cosine similarity.
Binary search ↗
Step through a sorted array and observe the search interval.