Skip to content

latent.rag.research_agent

RAG Research — pipeline composition optimizer.

Two-phase approach: Search phase: Optuna Bayesian optimization over the full component space. Pre-indexes wiki with each chunk size variant once, then explores query-time params (k, reranker, post-retrieval, etc.) instantly per trial. Zero LLM cost for the optimizer itself. Eval phase: Validates top N configs from search with a caller-supplied RAGEvalFn (full end-to-end evaluation).

Classes

Experiment

Experiment(label: str, config: dict[str, Any], score: float, phase: str, eval_report: dict[str, Any] | None = None, error: str | None = None)

A single optimization trial.

RAGResearchResult

RAGResearchResult(best_pipeline_config: dict[str, Any], best_score: float, best_eval_report: dict[str, Any] | None, experiments: list[Experiment], phase: str)

Result of a RAG research agent optimization run.