Phase 2 · Math, when you need it · Linear algebra
Dot product and cosine similarity
The one operation behind similarity search and attention.
Open this lesson Create a free account
Why it matters
If you learn one piece of maths for AI, make it this one. The dot product is how AI search ranks documents. It's how a simple scoring rule works ("2 points per page view, 10 for a demo request"). Every neuron in a neural network computes one. And attention, the heart of models like ChatGPT and Claude, is dot products between words. Learn this one move well and a lot of AI becomes familiar.
What you'll be able to do
- Compute a dot product by hand, with a loop and with NumPy
- Read the dot product geometrically: lengths times the cosine of the angle
- Use cosine similarity to compare directions regardless of length
- See a weighted score (like a lead score) as a dot product: the core of a neuron
Before this lesson
Next in this phase: Matrices