60-second card
Embeddings
An embedding turns text into a vector of numbers, so texts with similar meaning end up close together.
- 'Reset my password' and 'forgot login' get nearby vectors.
- Embed questions and documents with the same model.
- Normalised vectors make the dot product equal cosine similarity.
import numpy as np
v = np.array([3.0, 4.0])
print((v / np.linalg.norm(v)).tolist())Prints
[0.6, 0.8]Remember: Same model for questions and documents, always.
Common mistake: Switching embedding models without re-embedding the old documents.