Inner Products and Norms
How the dot product induces lengths, distances and angles in $R^n$, and how the angle gives the length-independent cosine similarity used to compare vectors.
Concepts#
- Cosine Similaritythe cosine of the angle between two vectors: dot product normalized by both lengths start here
How it fits together#
Chain. Dot product → norm → distance and angle:
| Quantity | Formula | Measures | Under () |
|---|---|---|---|
| dot product | alignment and lengths | scales by | |
| Euclidean norm | length | scales by | |
| Euclidean distance | dissimilarity (small = close) | changes | |
| cosine similarity | direction only (large = similar) | unchanged |
- Cauchy–Schwarz makes the angle well-defined: , so the quotient lies in and there is a unique with that cosine.
- Orthogonality is the case (). Orthogonal unit vectors are orthonormal; the standard basis vectors are the typical example.
- Normalizing turns cosine into dot product: for unit vectors, and . On the unit sphere, “highest cosine similarity”, “highest dot product” and “smallest Euclidean distance” give the same ranking.
- Which to use: the dot product when length carries meaning (e.g. more occurrences = more relevant), cosine similarity when only the direction matters (e.g. documents of different length), Euclidean distance when absolute position matters.
- Matrix form: the dot products of a vector with all columns of are the entries of ; all pairwise dot products of the columns form the Gram matrix , which is positive semidefinite because .
Key Formulas#
- , (Cauchy–Schwarz)
- (Cosine Similarity)
- with , (Cosine Similarity > Formula)
Lectures#
- No lecture yet. Source: MML ch. 3.1–3.4, pp. 71–77.
- Used in DBIS: DBIS_VL11 (cosine similarity for document ranking, word embeddings), DBIS_VL12 (retrieving RAG chunks), see Word Embeddings and Language Models.
Related Topics#
- Rank and Invertibility — the Gram matrix of all column dot products is PSD and invertible iff has full column rank