Skip to main content
Hybrid search combines vector similarity search with keyword-based full-text search to provide more accurate and comprehensive results. This guide shows you how to implement hybrid search in Chroma. Hybrid search leverages two complementary approaches:
  1. Vector Search (KNN) - Finds semantically similar content using embedding vectors
  2. Full-Text Search (BM25) - Finds keyword matches using traditional information retrieval
Results are combined using Reciprocal Rank Fusion (RRF) to produce a unified ranking.

Setting Up

First, create a collection with hybrid search support:

Adding Documents

Understanding the Components

KNN (K-Nearest Neighbors)

Vector similarity search finds semantically similar content:
KNN is excellent for:
  • Finding semantically related content
  • Handling synonyms and paraphrases
  • Cross-lingual search (with multilingual models)
Keyword-based search using the BM25 algorithm:
BM25 excels at:
  • Exact keyword matching
  • Technical terms and jargon
  • Proper nouns and specific phrases

RRF (Reciprocal Rank Fusion)

Combines multiple search results:
The k parameter controls the fusion:
  • Lower k (e.g., 20): Emphasizes top-ranked results
  • Higher k (e.g., 100): Gives more weight to lower-ranked results
  • Default: k=60 (balanced)

With Metadata Filtering

Search with multiple queries:

Custom Scoring

Adjust the balance between vector and keyword search:

Using BM25 Embedding Function

Chroma provides a built-in BM25 embedding function for full-text search:

Real-World Use Cases

Benefits:
  • Finds products by features (semantic)
  • Matches exact brand/model names (keyword)
  • Ranks by relevance (hybrid)

Document Retrieval

Question Answering

Performance Optimization

Tuning Parameters

Caching

Batch Processing

Comparison: Hybrid vs. Single Method

✅ Use hybrid search when:
  • You need both semantic and exact matching
  • Queries contain technical terms or proper nouns
  • You want robust results across query types
  • Handling diverse user queries

When to Use Vector Search Only

✅ Use vector search when:
  • Semantic similarity is more important than keywords
  • Working with multilingual content
  • Queries are questions or natural language
  • Handling paraphrases and synonyms

When to Use Keyword Search Only

✅ Use keyword search when:
  • Exact term matching is critical
  • Searching for codes, IDs, or specific phrases
  • Working with structured data
  • Speed is the priority

Troubleshooting

Poor Hybrid Results

No BM25 Results

Ensure collection has enough documents and diverse vocabulary:

Slow Hybrid Queries