Reference · Glossary

Linear algebra for ML

Last updated

When you need to understand why embeddings are vectors, how matrix multiplication powers neural nets, or why cosine similarity measures "closeness" in high dimensions.

#When to use

When you need to understand why embeddings are vectors, how matrix multiplication powers neural nets, or why cosine similarity measures "closeness" in high dimensions.

#When not to

For tabular business rules with no learned representations — a spreadsheet lookup may be enough without vectors.

#Example

import numpy as np
a = np.array([0.2, 0.8, 0.1])  # embedding for "refund policy"
b = np.array([0.3, 0.7, 0.2])  # embedding for "return rules"
similarity = np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))

Key ideas: **dot product** (similarity), **matrix multiply** (layer transforms), **norms** (vector length).