Skip to content

latent.rag.config

Declarative retrieval configuration.

One typed source of truth for retrieval hyperparameters, so consumers stop threading a dozen individual booleans/floats through every factory layer (and stop drifting when only some are set). Load from a TOML section or a plain mapping (e.g. an eval params dict); unknown keys are ignored so a broader config blob can be passed through.

Defaults are framework-generic — application-specific tuned values (Hebrew BM25 params, grid-searched fusion weights, whether HyDE helps a given corpus) belong in the consumer's own config, not here.

Classes

RetrievalConfig

RetrievalConfig(backend: str = 'hybrid', enable_hyde: bool = False, enable_query_expansion: bool = False, hyde_model: str | None = None, k: int = 8, alpha: float = 0.5, rrf_k: int = 60, bm25_k1: float = 1.5, bm25_b: float = 0.75, bm25_tokenizer: str = 'en', embedding_provider: str = 'voyage', embedding_model: str | None = None, high_relevance_threshold: float | None = None, medium_relevance_threshold: float | None = None)

Methods

RetrievalConfig.from_mapping

from_mapping(m: dict[str, Any] | None) -> RetrievalConfig

Build from a mapping, ignoring keys that aren't config fields.

RetrievalConfig.from_toml

from_toml(path: str | Path, section: str = 'retrieval') -> RetrievalConfig

Load from [section] of a TOML file (defaults when absent).

RetrievalConfig.load

load(section: str = 'retrieval') -> RetrievalConfig

Discover the project's latent config file (config/latent.toml etc.) and load [section] from it; returns defaults when none is found.

RetrievalConfig.merge

merge(overrides: dict[str, Any] | None) -> RetrievalConfig

Return a copy with the given field overrides applied (for per-run experiment tweaks layered over a shared base config).