RerankConfig#
- class langgraph.store.mongodb.base.RerankConfig[source]#
Configuration for native reranking via the $rerank aggregation stage.
Reranking runs entirely server-side on MongoDB Atlas — no Voyage AI SDK or client-side API key is required. Atlas calls the Voyage AI reranker API on your behalf using a key you configure in Atlas Project Settings.
- Prerequisites (all must be satisfied before results are reranked):
MongoDB Atlas cluster running MongoDB 8.3+.
Native Reranking enabled in Atlas Project Settings.
A Voyage AI API key configured in Atlas Project Settings.
If any prerequisite is missing,
search()will return constant scores (e.g.0.5987) for all documents rather than raising an error.- model#
Voyage AI reranking model (e.g.
"rerank-2.5-lite"). Omit to use the latest available model.- Type:
str
- num_docs_to_rerank#
Number of candidates passed from $vectorSearch to the reranker. Must be >= the
limitpassed tosearch()and <= 1000 (the MongoDB maximum for$rerank). Defaults tomin(limit * oversampling_factor, 1000), which satisfies both constraints as long aslimititself is <= 1000. Passinglimit > 1000with reranking enabled raises aValueErrorat search time.- Type:
int
- oversampling_factor#
Multiplier applied to
limitwhen computing the defaultnum_docs_to_rerank. Ignored whennum_docs_to_rerankis set explicitly. Defaults to 10.- Type:
int
- model: str#
- num_docs_to_rerank: int#
- oversampling_factor: int#