Step by Step
K
Keyword search — finding exact word matches
Keyword search (TF-IDF, BM25) finds documents containing the exact query words, but fails when synonyms are used or the same concept is expressed with different wording.
Example: a keyword search for "heart attack" would fail to retrieve a highly relevant document that only uses the term "myocardial infarction" instead.
S
Semantic search — finding conceptually similar meaning
Semantic search converts both the query and documents into dense vector embeddings, retrieving results by cosine similarity in vector space, capturing meaning-based relevance rather than exact word matches.
Example: a semantic search for "heart attack" successfully retrieves documents about "myocardial infarction," because their embeddings end up close together in vector space, despite sharing no exact keywords.
V
Vector databases — storing and searching embeddings at scale
FAISS and vector databases like Pinecone, Weaviate, and Chroma store and search billions of embeddings efficiently, making large-scale semantic search practically feasible.
Example: using Pinecone to efficiently search through billions of stored document embeddings to find the most semantically relevant results for a given query.
Applied Walkthrough
1
A medical search system needs to correctly retrieve relevant documents for the query "heart attack," even when those documents use the technical term "myocardial infarction" instead.
2
Ask: would a purely keyword-based search (TF-IDF or BM25) succeed here? No — since the exact words don't match, keyword search would likely miss this relevant document entirely.
3
Using semantic search instead, both the query and the document get converted into dense embeddings, and cosine similarity correctly identifies these as closely related in meaning, despite the different terminology.
4
This is exactly why semantic search (powered by vector databases like FAISS, Pinecone, Weaviate, or Chroma) is used for the retrieval step in most modern RAG systems — it succeeds precisely where keyword search would fail.
Exam Application
Exams test whether you understand keyword search's core limitation (missing synonyms and differently-worded concepts) and how semantic search's embedding-based approach specifically solves this, along with recognizing common vector database tools (FAISS, Pinecone, Weaviate, Chroma) used to implement semantic search at scale.
⚠ Common Trap
The most common trap is assuming semantic search is always strictly superior to keyword search in every situation. Keyword search can still outperform semantic search for exact-match needs (specific codes, names, or technical identifiers), which is why hybrid approaches combining both are often preferred in practice.
✓ Quick Self-Check
1. What is the core limitation of keyword search (TF-IDF, BM25)?
It fails when synonyms are used or the same concept is expressed with different wording, since it only matches exact words.
Tap to reveal / hide
2. How does semantic search overcome this limitation?
By converting query and documents into dense embeddings and retrieving by cosine similarity, capturing meaning-based relevance rather than exact word matches.
Tap to reveal / hide
3. Why would a search for "heart attack" using semantic search successfully retrieve documents about "myocardial infarction"?
Because their embeddings end up close together in vector space, despite sharing no exact keywords.
Tap to reveal / hide
4. Name two vector database tools used to store and search embeddings at scale.
Any two of: FAISS, Pinecone, Weaviate, Chroma.
Tap to reveal / hide
5. Is semantic search always strictly better than keyword search?
No — keyword search can still outperform for exact-match needs like specific codes or names, which is why hybrid approaches are often preferred.
Tap to reveal / hide