The 50% map — part 1 of 5

Linear Algebra — the language models are written in

Every tensor, layer, embedding and attention score is linear algebra. Roughly 90% of what AI hardware computes is matrix multiplication. Master this part and model code stops being mysterious — it becomes bookkeeping over shapes.

Where it lives: one transformer layer, annotated

The scariest diagram in AI is four matmuls and a softmax.

A transformer layer as shape algebra

Tokens shape (S × D) × W Q, K, V 3 matmuls with learned weights W (D × D) Q·Kᵀ scores (S × D)·(D × S) → (S × S) dot product = similarity softmax × V → mix info (S × S)·(S × D) → (S × D) Feed-forward network (S×D)·(D×4D) → ·(4D×D) most of the parameters live here Read the shapes and you can read the layer: · attention cost grows as S² — the (S × S) matrix · parameter count is dominated by weight matrices
S = sequence length, D = hidden size. Every arrow is a matrix multiplication with learned weights — this is why "90% of AI compute is matmul" is literal.

The roadmap of understanding — three levels deep

Level 1 — Intuition

what you must be able to picture
vectors = points of meaning  ·  matrices = transformations  ·  matmul = composed transforms

The ideas

  • A vector is a point in space — and a row of data, and a "meaning"
  • A matrix transforms space (rotate, stretch, project)
  • Matrix multiplication chains transformations
  • Dot product measures alignment — similarity

Where it lives

  • Embeddings: "meaning of a word" = a 1,000-dim vector
  • Vector search / RAG: nearest points = related content
  • Every dense layer: transform the representation

What it explains

  • Why "distance = meaning" works at all
  • Why a model is literally a stack of transformations
  • Why similar inputs produce similar outputs

Level 2 — Working fluency

the daily language of model code
shape algebra  ·  batched tensors (B, S, D)  ·  broadcasting  ·  norms

The ideas

  • Shape rule: (m×n)·(n×p) → (m×p) — inner dims must match
  • Tensors = stacked matrices: batch × sequence × hidden
  • Transpose, broadcasting, element-wise vs matrix ops
  • Norms (L1/L2) — the "size" of a vector or gradient
  • Cosine similarity = normalized dot product

Where it lives

  • Attention: softmax(QKᵀ/√D)·V — read it now, shape by shape
  • Gradient clipping: cap the L2 norm of the update
  • Weight decay: penalize large weight norms
  • Every framework error message you'll ever see

What it explains

  • The #1 daily bug class: shape mismatches
  • Why attention cost is quadratic in context length
  • Where a model's parameter count comes from

Level 3 — The deep end

reach for it when you need it
rank & low-rank  ·  SVD  ·  eigenvalues  ·  orthogonality

The ideas

  • Rank: how much independent information a matrix carries
  • Low-rank approximation: big matrix ≈ product of two thin ones
  • SVD: any matrix = rotate · stretch · rotate
  • Eigenvalues: directions a transform only stretches

Where it lives

  • LoRA: fine-tune ΔW = A·B with rank 8 instead of the full matrix
  • PCA: project embeddings to 2-D for visualization
  • Model compression & distillation of weight matrices
  • Initialization schemes and rotary position embeddings

What it explains

  • Why LoRA with r=8 can steer a 7B model: weight updates are naturally low-rank
  • Why PCA plots of embeddings show meaningful clusters
  • Why bad initialization explodes activations

Cheat sheet: concept → where → purpose

ConceptWhere you meet itWhat it's doing there
Dot productAttention scores QKᵀ · cosine similarity in vector DBsMeasuring how related two things are
Matrix multiplicationDense, conv and attention layers — all of themTransforming representations; 90% of all FLOPs
Shapes (B, S, D)Every line of PyTorch / JAX you'll readThe type system of ML — most bugs are shape bugs
Norms (L1 / L2)Gradient clipping, weight decay, RMSNormKeeping magnitudes in a healthy range
BroadcastingBias adds, normalization layers, maskingOne small tensor applied across a big one
Low-rank / SVDLoRA adapters, compressionCheap fine-tuning: two thin matrices instead of one huge one
Eigenvalues / PCAEmbedding visualization, spectral tricks, stability analysisFinding the directions that matter in a learned space
The one habit that carries the whole part: read model code shape-first. Annotate every tensor with its (B, S, D) shape and every equation in a paper becomes checkable bookkeeping — including attention, which is three matmuls and a softmax.
← The 50% mapOverview