25 — Deep Learning

Attention Mechanism#

Architecture✓ Mathematical
◆ The PatternSelectively focusing on relevant parts of the input

Each token asks: "which other tokens are most relevant to me?" via dot-product similarity between queries and keys.

Attention(Q,K,V) = softmax(QKᵀ / √d) · V
Q = Query  |  K = Key  |  V = Value  |  √d = scaling to prevent saturation
// Attention heatmap — click cells to boost connections
Click cells to strengthen
Multi-Head Attention: Run h attention functions in parallel, each with different learned projections. Allows attending to syntax, semantics, and coreference simultaneously.
Pattern bridge: Selectively weighting inputs by relevance appears in VWAP (volume-weighted attention to price) and transformer self-attention.
← Previous
Embeddings
Open in the full reader, with the topic sidebar →