Overview
RetrievalConfig controls how documents are retrieved and processed during the RAG query pipeline.
Definition
Fields
Number of chunks to retrieve initially from the vector store
Number of chunks to keep after reranking
Whether to generate query variations for better retrieval
Whether to rerank retrieved chunks for relevance
Whether to use hybrid search (semantic + BM25 keyword search)
RRF (Reciprocal Rank Fusion) constant for hybrid search result combination
Usage
Basic Usage
Complete Configuration
Configuration Strategies
Fast and Focused
For quick, focused answers:Comprehensive
For thorough, well-sourced answers:Hybrid Search
For queries with specific keywords or technical terms:Semantic Only
For purely conceptual queries:Parameter Guidelines
top_k
Number of chunks to retrieve initially:- 5-10: Fast, focused answers
- 10-15: Balanced (recommended default)
- 15-25: Comprehensive, thorough answers
- >25: May include noise, slower
rerank_top_k
Number of chunks to keep after reranking:- 2-3: Concise answers
- 3-5: Balanced (recommended)
- 5-10: Detailed answers with multiple sources
- Should always be ≤
top_k
use_query_rewriting
Generate query variations for better retrieval:- True: Better recall, finds more relevant content (recommended)
- False: Faster, uses only original query
use_reranking
Rerank retrieved chunks by relevance:- True: Higher quality results (recommended)
- False: Faster, relies on initial ranking
use_hybrid_search
Combine semantic and keyword search:- True: Better for specific terms, technical content
- False: Faster, semantic-only search (default)
rrf_k
RRF fusion constant for hybrid search:- 20-40: More weight to top results
- 60: Balanced (default)
- 70-80: More even distribution
Runtime Override
You can override config values when querying:Performance Trade-offs
| Configuration | Speed | Quality | Cost |
|---|---|---|---|
| top_k=5, no rewriting | ⚡⚡⚡ | ⭐⭐ | 💰 |
| top_k=10, with reranking | ⚡⚡ | ⭐⭐⭐⭐ | 💰💰 |
| top_k=20, full features | ⚡ | ⭐⭐⭐⭐⭐ | 💰💰💰 |
Complete Example
See Also
LLMConfig
Configure language model
RerankerConfig
Configure reranking
Hybrid Search
Learn about hybrid search
