TRANSFORMER ARCHITECTURE // ATTENTION MECHANISM
PARALLEL SELF-ATTENTION & RESIDUAL FEATURE CONDUITS
CURRENT FORMULATION
Attention(Q,K,V) = softmax(QKᵀ/√dₖ)V
PE(pos, 2i) = sin(pos/10000²ⁱ/ᵈ)
RAW INPUT TEXT STREAM
"Attention Is All You Need — Transformer Architecture Deep Dive"
QUERY (Q)
W_q · X
KEY (K)
W_k · X
VALUE (V)
W_v · X
ATTENTION WEIGHT MATRIX [A]
Softmax(Q · Kᵀ / √dₖ)
TOKEN RELATIONAL ENERGY FLOW
Dynamic Head #1 / #8
Multi-Head Self-Attention
Linear Projections & Scaled Dot-Product
Add & LayerNorm
LayerNorm(x + Sub(x))
Feed-Forward Network (FFN)
FFN(x) = max(0, xW₁ + b₁)W₂ + b₂
Add & LayerNorm
Dense 512 → 2048 → 512
▲ RESIDUAL HIGHWAY: PRESERVES LOW-LEVEL GRADIENT DYNAMICS
ENCODER STACK (Nx=6)
Feed Forward
Add & Norm
Multi-Head Attention
Add & Norm
Input Embedding + PE
K, V
DECODER STACK (Nx=6)
Feed Forward
Cross Multi-Head Attention
Add & Norm
Masked Multi-Head Attention
Output Embedding + PE
Linear & Softmax Out
LATENT D_MODEL (512-D)
High-dimensional Semantic Tensor
SEMANTIC SPACE
PHASE 1/4
Tokenization & Positional Encoding: Input text slices into discrete embedding vectors with injected sinusoidal harmonics.
1. Tokens & PE
2. Self-Attention
3. FFN & Residuals
4. Encoder-Decoder Stack