Skip to main content
This example combines three techniques for optimal retrieval:
  1. Agentic RAG: Agent decides when to search the knowledge base
  2. Hybrid search: Combines vector similarity with keyword matching
  3. Reranking: Reorders results using a dedicated ranking model

Why Combine These Techniques

Together, these provide better retrieval accuracy than any single technique alone.

How Reranking Works

After hybrid search returns initial results, the reranker:
  1. Takes the query and candidate documents
  2. Scores each document for relevance using a cross-encoder model
  3. Reorders results so the most relevant appear first
Cohere’s rerank-v3.5 is trained specifically for this task and significantly improves result quality.

Example

agentic_rag.py

Usage

1

Set up your virtual environment

2

Install dependencies

3

Export your API keys

4

Run Agent

Configuration Options

Different Rerankers

Adjusting Results

Next Steps

Hybrid Search

Learn more about combining search types

Embedders

Choose the right embedding model