Configuration
On this page
Configuration is driven by two dataclasses, both defined with Python's @dataclass decorator: RAGConfig (pipeline-wide) and RerankerConfig (re-ranking-specific). RAGSystem builds a RerankerConfig internally from the rerank_* fields of RAGConfig — you normally only need to construct RAGConfig.
RAGConfig fields
Chunking
Retrieval
Reranking
[!WARNING] Weights must sum to ~1.0
RAGConfig.validate()raisesValueErrorifrerank_original_weight + rerank_llm_weight + rerank_diversity_weight + rerank_length_weightis outside[0.99, 1.01].
Prompt routing
Context
Retrieval cache
Batch ingestion
RAGConfig.validate()
Raises ValueError (not a core.exceptions subclass) if:
chunk_size <= 0overlap < 0top_k <= 0overlap >= chunk_sizererank_mode not in ("heuristic", "llm", "hybrid")- The four
rerank_*_weightfields don't sum to ~1.0
BaseRAGSystem.__init__ calls self.config.validate() automatically, so invalid configs fail fast at construction time.
from zerda.rag.core import RAGConfig
cfg = RAGConfig(chunk_size=1000, overlap=1200) # overlap >= chunk_size
cfg.validate()
# ValueError: ❌ overlap must be smaller than chunk_size
RerankerConfig fields
Constructed internally by RAGSystem from the rerank_* RAGConfig fields, or directly if you use Reranker standalone.
__post_init__ raises ValueError if the four weight fields don't sum to [0.99, 1.01] — the same check as RAGConfig.validate(), applied automatically at construction time (dataclasses call __post_init__ after __init__).
RerankMode enum
class RerankMode(Enum):
HEURISTIC = "heuristic" # fast, no LLM
LLM = "llm" # accurate, uses LLM
HYBRID = "hybrid" # combination
effective_weights(mode)
RerankerConfig.effective_weights(mode) returns a Dict[str, float] with keys orig, llm, len, div. In HEURISTIC mode, llm_score_weight is folded into orig (since there is no LLM call to weight), and llm is returned as 0.0. In LLM/HYBRID mode, weights are returned unchanged. Reranker calls this method internally rather than reading the raw config fields directly — see Reranker internal workflow.
Recommended configurations
Fast, offline-friendly (default-ish)
RAGConfig(
enable_reranking=False,
enable_prompt_routing=True,
enable_retrieval_cache=True,
)
Highest quality, LLM-heavy
RAGConfig(
enable_reranking=True,
rerank_mode="hybrid",
rerank_original_weight=0.3,
rerank_llm_weight=0.5,
rerank_diversity_weight=0.1,
rerank_length_weight=0.1,
)
No caching (always fresh results — e.g. rapidly changing corpus)
RAGConfig(enable_retrieval_cache=False)
See also: RerankerConfig best practices and RetrievalCache.