What is Semantic Search?
Semantic search is a search approach that aims to understand the intent and contextual meaning of search queries, rather than just matching keywords. It uses embeddings and vector similarity to find results that are conceptually related to the query.
Keyword vs. Semantic Search
| Keyword Search | Semantic Search |
|---|---|
| Exact matching | Meaning matching |
| Fast, simple | More compute |
| Miss synonyms | Understands synonyms |
| No context | Context-aware |
How It Works
-
Convert to Embeddings Query and documents → vectors
-
Compute Similarity Cosine similarity, dot product
-
Retrieve Results Top-K most similar
-
Rank and Return Present to user
Similarity Metrics
Cosine Similarity
similarity = (A · B) / (||A|| × ||B||)
Range: -1 to 1
Euclidean Distance
distance = √(Σ(ai - bi)²)
Lower is more similar.
Dot Product
similarity = Σ(ai × bi)
With normalized vectors = cosine.
Use Cases
- Enterprise search
- RAG systems
- Product search
- Document discovery
- FAQ matching
- Code search
Implementation Components
Embedding Model Convert text to vectors.
Vector Database Store and search vectors.
Indexing ANN (Approximate Nearest Neighbor).
Best Practices
- Choose appropriate embedding model
- Optimize chunk size
- Consider hybrid search
- Implement relevance feedback
- Monitor search quality