-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: ABX
-
Not Needed
-
None
-
None
-
None
-
None
-
None
-
None
-
None
TL;DR
The @mastra/voyageai package ships a working Voyage reranker (VoyageRelevanceScorer), but it isn't mentioned anywhere in the docs. Add reranker documentation so users can discover it and wire it into Mastra retrieval. Voyage embeddings are already documented; reranking is the missing half.
Context
Mastra is a TypeScript framework for building AI agents. A common pattern is Retrieval-Augmented Generation (RAG): the app searches a vector database for text chunks related to a user's question, then feeds the best matches to the model.
Plain-language primer:
- Embedding: turning text into a list of numbers (a vector) so similar meanings sit close together. A vector search returns a rough first pass of relevant chunks.
- Reranking: a second, more accurate pass. A dedicated reranking model re-scores each candidate against the query and reorders them, pushing the truly relevant results to the top. It's slower but sharper than raw vector similarity.
- Voyage AI: an embedding and reranking model provider (owned by MongoDB). Mastra integrates it through the @mastra/voyageai package.
- RelevanceScoreProvider: the Mastra interface a reranker implements so it can plug into Mastra's reranking helpers.
The problem: @mastra/voyageai already implements a Voyage reranker (VoyageRelevanceScorer), exposes ready-to-use instances (e.g. voyage.reranker), and is covered by integration tests — yet no docs page shows it. The VoyageAI section of the embeddings page documents only embeddings, and the reranking guide/reference show only the Cohere, ZeroEntropy, and Mastra agent scorers. Users have no way to learn that Voyage reranking exists in Mastra without reading the source.
Task
Goals:
- Document that @mastra/voyageai provides a Voyage reranker and list the available reranking models.
- Show how to create a reranker (pre-configured instance, factory, and class) and its config options.
Where:
- Retrieval / re-ranking guide (add Voyage alongside the other scorers) — live: https://mastra.ai/docs/rag/retrieval — source: docs/src/content/en/guides/rag/retrieval.mdx
- rerankWithScorer() reference (note Voyage as an available provider) — live: https://mastra.ai/reference/rag/rerankWithScorer — source: docs/src/content/en/reference/rag/rerankWithScorer.mdx
Config options on VoyageRerankerConfig: model (required), apiKey (defaults to the VOYAGE_API_KEY env var), baseUrl (optional custom endpoint, e.g. a MongoDB-hosted Voyage endpoint https://ai.mongodb.com/v1), and truncation (defaults to true).
Examples:
Three equivalent ways to get a reranker:
import { voyage, createVoyageReranker, VoyageRelevanceScorer } from '@mastra/voyageai' const scorer = voyage.reranker // 1. pre-configured (rerank-2.5) const scorer2 = createVoyageReranker({ model: 'rerank-2.5-lite' }) // 2. factory const scorer3 = new VoyageRelevanceScorer({ model: 'rerank-2' }) // 3. class
Use it with rerankWithScorer() — object-form signature (scorer from @mastra/voyageai, helper from @mastra/rag):
import { rerankWithScorer as rerank } from '@mastra/rag' import { voyage } from '@mastra/voyageai' const reranked = await rerank({ results: vectorSearchResults, query: 'How do I deploy to production?', scorer: voyage.reranker, options: { topK: 5 }, })
Or let an agent's vector query tool rerank automatically:
import { createVectorQueryTool } from '@mastra/rag' import { voyage } from '@mastra/voyageai' const queryTool = createVectorQueryTool({ vectorStoreName: 'mongodb', indexName: 'docs', model: voyage, // embeddings reranker: { model: voyage.reranker, options: { topK: 5 } }, // reranking })
Acceptance Criteria
- The docs show at least one way to obtain a reranker: voyage.reranker, createVoyageReranker(), and VoyageRelevanceScorer.
- The config options (model, apiKey, baseUrl, truncation) and their defaults are documented.
- The reranking guide and the rerankWithScorer() reference link to the new Voyage reranker content.
- Docs changes follow the applicable styleguides and pass pnpm validate and pnpm lint:prose.
References (implementation)
- Reranker implementation: embedders/voyageai/src/reranker.ts
- Exports / pre-configured instances (voyage.reranker, reranker25, reranker25lite, reranker2, reranker2lite, voyage.createReranker): embedders/voyageai/src/index.ts
- Reranker types, models, config: embedders/voyageai/src/types.ts
- Vector query tool reranker handling: packages/rag/src/tools/vector-query.ts
- rerankWithScorer() definition (object-form signature): packages/rag/src/rerank/index.ts
- Caveat (important): the JSDoc example in embedders/voyageai/src/reranker.ts (lines ~26–40) shows a stale positional rerankWithScorer(results, query, scorer, options) signature. The real current API is the object form — rerankWithScorer takes a single object argument. Do not copy that JSDoc snippet verbatim.
- is related to
-
NODE-7761 [Mastra] Document the VoyageAI reranker
-
- Needs Triage
-