Lesson 1.1foundation2 h 30 min

Vectors, dot products and norms

The geometry every model lives in

Every object a model touches is a vector: an image is a point in R784\mathbb{R}^{784}, a word becomes a 768-dimensional embedding, a user is a row of features. Dot products measure alignment, norms measure size, and together they define similarity, distance and projection — the operations behind neurons (4.1 From perceptron to MLP; universal approximation), kNN (3.4 k-Nearest Neighbors), attention scores (7.2 Scaled dot-product and multi-head attention, fully derived) and the cosine similarity that ranks documents in RAG (9.2 Embeddings deep dive).

You'll be able to

  • Compute dot products, norms, angles and projections by hand and in NumPy
  • Explain why a neuron's pre-activation is a dot product and what it measures
  • Use cosine similarity and Euclidean distance appropriately and know when they agree
  • State what happens to distances and angles in high dimensions and why it matters for embeddings

Key ideas

  1. A vector is both an arrow and a row of data; ML is geometry in high-dimensional spaces.
  2. Dot product = Σ xᵢyᵢ = ‖x‖‖y‖cos θ: it measures alignment, and a neuron's pre-activation is exactly this alignment score.
  3. Cosine similarity is the dot product of unit vectors; for normalized embeddings, cosine ranking and Euclidean-distance ranking coincide.
Show 4 more key ideas
  1. The ℓ₂ norm gives Euclidean length/distance; ℓ₁'s diamond-shaped ball is why ℓ₁ regularization yields sparsity; ℓ∞ bounds the largest coordinate.
  2. Projection onto v is (x·v / v·v) v — least squares and PCA are projections.
  3. In high dimensions random vectors are nearly orthogonal and distances concentrate; learned embeddings restore meaningful geometry.
  4. Cauchy–Schwarz |x·y| ≤ ‖x‖‖y‖ guarantees cosine similarity lives in [−1, 1].

Suggested path through this lesson