Skip to main content
The search space defines the hyperparameter ranges and choices that the optimizer explores to find optimal RAG configurations.

Overview

RAGOpt uses a RAGSearchSpace to define all tunable parameters including:
  • Chunking parameters (size, overlap)
  • Retrieval settings (k, search type)
  • Model selections (LLM, embeddings, vector store, reranker)
  • Generation parameters (temperature)
Important: You typically don’t need to customize the search space manually. The default configuration or YAML-based config is sufficient for most use cases.

How It Works

Under the hood, the search space:
  1. Defines parameter types (continuous, categorical, boolean)
  2. Sets valid ranges and choices
  3. Handles encoding/decoding for Bayesian Optimization
  4. Manages component pricing information
The optimizer uses this to:
  • Sample configurations efficiently (Sobol, Random, QMC)
  • Convert between tensor representations and RAGConfig objects
  • Evaluate configurations during optimization

Default Configuration

RAGOpt provides sensible defaults out of the box:
Default ranges include:
  • chunk_size: 200-2000 tokens
  • chunk_overlap: 0-500 tokens
  • k: 1-20 retrieved documents
  • temperature: 0.0-2.0
  • search_type: similarity, mmr, bm25, hybrid
  • vector_stores: FAISS, Chroma, Pinecone, Weaviate
  • embeddings: OpenAI, HuggingFace, Sentence Transformers
  • llms: OpenAI GPT, Anthropic Claude

YAML Configuration

For custom configurations, define a YAML file:
Load it in the optimizer:

Parameter Types

Continuous Parameters

Numeric ranges for values like chunk_size, temperature:

Categorical Parameters

Discrete choices like models or search strategies:

Boolean Parameters

Binary decisions like enabling reranking:

Pricing Configuration

Include cost information for optimization:
This enables cost-aware optimization in multi-objective scenarios.

Sampling Methods

The search space supports multiple sampling strategies: