How it works · 3 of 37 Foundation
How does semantic (vector) search find text by meaning?
Finding by meaning
Semantic (vector) search: Place the question on the same map, fetch the nearest texts.
Loading the animation…
Say it like this Semantic search puts the question on the same meaning map as your documents and returns the nearest ones, so it finds the right page even when the words differ.
Under the hood — for builders
- Why meaning search won: Dense Passage Retrieval (2020)
- Facebook AI searched Wikipedia by embedding both questions and passages, and compared it with classic keyword search (BM25, the standard word-matching score):
- Measure your own: recall@k
- Take test questions whose right page you know; count how often it lands in the top k. Worked example:
- Speed
- Checking every page is exact but slow. Approximate indexes such as HNSW (a graph that hops between nearby pages) check a fraction, and rarely miss.
- Bigger k
- Finds more right pages, but puts more pages (and tokens) in the prompt.
- Tools
- pgvector (HNSW, IVFFlat), FAISS, Elasticsearch/OpenSearch k-NN, or a hosted vector database.
- Watch out
- There's always a nearest page, even a wrong one: set a minimum score. Codes need keyword search.
- Sources
- Karpukhin et al., Dense Passage Retrieval (EMNLP 2020) · Malkov & Yashunin, HNSW (2018).
What happens in the semantic (vector) search animation, step by step?
- These are a shop's help pages, already placed on the meaning map by their embeddings.
- A customer asks: "My parcel never showed up." The question is embedded too, so it lands on the same map.
- Your turn: which page would you pick for this question? Tap one, then see what the search picks.
- The search measures how close every page sits to the question. Scores run up to 1 (same meaning): higher is closer.
- The nearest three become RAG's pages. "Parcel sizes" shares the word "parcel", yet sits far away: it's about box sizes, not lost parcels.
What everyday example explains semantic (vector) search?
Asking for "something about sleepy cats" and getting a book titled "Napping Felines".
Why should a team care about semantic (vector) search?
This is the "R" in RAG.