Skip to main content
Prerequisites: To use hybrid search with sparse embeddings, you must first configure a sparse vector index in your collection schema. See Sparse Vector Search Setup for configuration instructions.

Understanding RRF

Reciprocal Rank Fusion combines multiple rankings by using rank positions rather than raw scores. This makes it effective for merging rankings with different score scales.

RRF Formula

RRF combines rankings using the formula: score=iwik+ri\text{score} = -\sum_{i} \frac{w_i}{k + r_i} Where:
  • wiw_i = weight for ranking i (default: 1.0)
  • rir_i = rank position from ranking i (0, 1, 2, …)
  • kk = smoothing parameter (default: 60)
The score is negative because Chroma uses ascending order (lower scores = better matches).
Important: The legacy query API outputs distances, whereas RRF uses scores

Rrf Parameters

RRF vs Linear Combination

The return_rank Requirement

RRF requires rank positions (0, 1, 2…) not distance scores. Always set return_rank=True on all Knn expressions used in RRF.

Weight Configuration

The k Parameter

The k parameter controls how much emphasis is placed on top-ranked results:
  • Small k (e.g., 10): Heavy emphasis on top ranks
  • Default k (60): Balanced emphasis (standard in literature)
  • Large k (e.g., 100+): More uniform weighting across ranks

Common Use Case: Dense + Sparse

The most common RRF use case is combining dense semantic embeddings with sparse keyword embeddings.

Edge Cases and Important Behavior

Component Ranking Behavior

Each Knn component in RRF operates on the documents that pass the filter. The number of results from each component is the minimum of its limit parameter and the number of filtered documents. RRF handles varying result counts gracefully - documents from any ranking are scored.

Minimum Requirements

  • At least one ranking expression is required
  • All rankings must have return_rank=True
  • Weights (if provided) must match the number of rankings

Document Selection with RRF

Documents must appear in at least one component ranking to be scored. To include documents that don’t appear in a specific Knn’s results, set the default parameter on that Knn:

RRF as a Convenience Wrapper

Rrf is a convenience class that constructs the underlying ranking expression. You can manually build the same expression if needed:

Complete Example

Here’s a practical example showing RRF with filtering and result processing:
Example output:

Tips and Best Practices

  • Always use return_rank=True for all Knn expressions in RRF
  • Set appropriate limits on component Knn expressions (usually 100-500)
  • Consider the k parameter - default of 60 works well for most cases
  • Test different weights - start with equal weights, then tune based on results
  • Use default values in Knn if you want documents from partial matches

Next Steps