Last updated
Similarity & Vector Search
Definition: Once text is embedded into vectors, you measure how related two pieces of text are by how close their vectors are. The most common measure is cosine similarity, which ranges from 0 (unrelated) to 1 (identical direction).
The intuition
Think of each vector as an arrow. If two arrows point the same way, the texts mean similar things (similarity near 1). If they point in different directions, they are unrelated (near 0).
Run it yourself
The demo computes cosine similarity between a query vector and two document vectors. Whichever scores higher is the better match — this is the heart of "vector search".
This is exactly what a vector database does, just across millions of vectors and very fast.
💡 Key point: retrieval in RAG = embed the question, then find the document chunks with the highest similarity.