Orthogonality & Projections

Why attention, PCA, and weight initialization depend on perpendicularity

Why

Orthogonality is the reason SVD's components don't interfere with each other, why PCA axes are independent, why attention heads can specialize, and why orthogonal weight initialization leads to better gradient flow. It ties the entire linear algebra section together — the singular vectors in SVD are orthogonal, eigenvectors of symmetric matrices are orthogonal, and PCA components are orthogonal by construction. Understanding projections lets you explain what it means to "project a query onto a key" in attention.

Intuition

Two vectors are orthogonal when their dot product is zero — they share zero information. A projection is the shadow one vector casts onto another. When you project a high-dimensional point onto a lower-dimensional subspace, you're asking: "what's the closest point in that subspace?"

Explanation
Orthogonality
u ⊥ v ⟺ u · v = 0 Orthonormal: u · v = 0 AND ‖u‖ = ‖v‖ = 1 Orthogonal matrix Q: QᵀQ = I ⟺ columns are orthonormal

An orthogonal matrix Q preserves lengths and angles: ‖Qx‖ = ‖x‖ for all x. Multiplying by Q is a pure rotation — no stretching. This is why U and V in SVD are called "rotation matrices."

Projection onto a vector
proj_u(v) = (v · u) · u = (uuᵀ) v Projection matrix onto u: P = uuᵀ Residual: v − proj_u(v) ⊥ u

In attention: the dot product q·k measures how much of q "projects onto" the direction k — larger values mean higher similarity and more attention weight.

Projection onto a subspace
proj(v) = U_k · U_kᵀ · v (U_k has orthonormal columns) Projection matrix: P = U_k U_kᵀ Properties: P² = P (idempotent), Pᵀ = P (symmetric)

This is exactly what PCA does: project each data point onto the subspace spanned by the top-k principal components. The projected coordinates are uncorrelated because the columns of U_k are orthogonal.

Why orthogonality matters in ML
  • PCA components are independent: orthogonal axes capture non-overlapping variance — no double-counting
  • SVD structure: U and Vᵀ are orthogonal — they rotate without distortion, so singular values cleanly represent stretching per direction
  • Attention heads: Q, K, V projections map tokens into subspaces; each head can learn a different "axis of similarity"
  • Orthogonal weight initialization: initializing weight matrices as orthogonal matrices preserves gradient norms during backpropagation — avoids vanishing/exploding gradients at initialization