Vectors
Be able to add vectors, multiply by a scalar, calculate the dot product and the length, and explain why the dot product measures "how alike" two vectors are.
Practise in Mattegrafen ↗ · Matematik 1cPrerequisites
Intuition
A vector is a list of numbers: (3, 4). Draw it as an arrow from the origin. Two numbers give an arrow in the plane, three in space, 768 in… well, a space we cannot draw but can calculate in.
Almost everything in AI is vectors: an image is a long vector of pixel values, a word becomes a vector of hundreds of numbers, a neuron's input is a vector.
Formal
For u = (u₁, u₂, …) and v = (v₁, v₂, …):
- Addition: u + v = (u₁+v₁, u₂+v₂, …)
- Scalar times vector: 2u = (2u₁, 2u₂, …)
- Dot product: u · v = u₁v₁ + u₂v₂ + …
- Length (norm): ‖u‖ = √(u₁² + u₂² + …)
- Cosine similarity: cos θ = (u · v) / (‖u‖ ‖v‖)
The dot product is large when the arrows point the same way, zero when they are perpendicular, negative when they point in opposite directions. That is why it is used to measure similarity: two words with similar meanings have vectors that point in similar directions. (3, 4) · (4, 3) = 24; ‖(3, 4)‖ = 5.
Mastery means
- Calculates the dot product and the norm by hand
- Interprets the cosine similarity between two vectors
Sign in to do the exercises and build your mastery up.
Sources
Leads to
Part of the goals (35)
- Understand how generative AI works
- Classical machine learning in practice
- The developer's toolbox
- Training neural networks for real
- Build a RAG system you can trust
- The mathematics behind the models
- Systems knowledge for AI engineers
- Seeing and hearing with AI
- Image classification with convolutional networks
- Run models more cheaply: quantisation
- Multimodal systems
- Classical ML for real
- Frontier Lab — an independent research project
- AI safety in practice
- Build a transformer from scratch
- Interpreting a language model
- Train your first neural network
- Fine-tune a model with LoRA
- Language models in practice
- Deep reinforcement learning
- Build a voice interface
- Generative models in depth
- Fine-tune and run your own models
- Data: collect, clean, document
- Responsible AI in practice
- Build a memory system for an agent
- Build an AI service that survives production
- AI in production
- Evals in practice
- Reproduce a paper
- Statistics for experiments
- Build an agent you can trust
- An AI service in operation
- Build an NLP system end to end
- AI, ethics and society