Module 3 · The maths the later courses assume · Lesson 9
Vectors, dot products and embeddings
The linear algebra the LLM courses assume, done by hand on ticket vectors, then with TF-IDF and a small CPU embedding model to find a ticket's nearest neighbours.
Setup for the exercises:Install Claude CodePython with uvThe Hollowbrook ticket dataRun Hugging Face models on CPU
By the end of this lesson you can
- Compute a dot product, a vector norm and a cosine similarity by hand for 3-dimensional vectors and say what each measures
- Multiply a 2×3 by a 3×2 matrix by hand, then explain the shapes and the meaning of every entry in X @ W for a batch of inputs and a weight matrix
- Build TF-IDF vectors and small CPU sentence embeddings for tickets, find the k nearest neighbours by cosine, and measure how often they share the category
- Explain what a sentence-embedding model is trained to do and why nearest-neighbour search at scale needs approximate methods
- Relate a query–key dot product in attention to the similarity scores computed here
