Constructor for MixedbreadAIReranker.
Optional
params: Partial<MixedbreadAIRerankParams>An optional object with properties to configure the instance.
If the API key is not provided or found in the environment variables.
const reranker = new MixedbreadAIReranker({
apiKey: 'your-api-key',
model: 'mixedbread-ai/mxbai-rerank-large-v1',
maxRetries: 5
});
Compress documents using Mixedbread AI's reranking API.
A list of documents to compress.
The query to use for compressing the documents.
A Promise that resolves to a list of compressed documents.
const documents = [{ pageContent: "To bake bread you need flour" }, { pageContent: "To bake bread you need yeast" }];
const query = "What do you need to bake bread?";
const result = await reranker.compressDocuments(documents, query);
console.log(result);
Reranks a list of documents based on their relevance to a query using the Mixedbread AI API. Returns an ordered list of documents sorted by their relevance to the provided query.
A list of documents as strings, DocumentInterfaces, or objects with a pageContent
key.
The query to use for reranking the documents.
Optional
options: RerankingRequestWithoutInputOptional parameters for reranking.
A Promise that resolves to an ordered list of documents with relevance scores.
const documents = ["To bake bread you need flour", "To bake bread you need yeast"];
const query = "What do you need to bake bread?";
const result = await reranker.rerank(documents, query);
console.log(result);
Generated using TypeDoc
Document compressor that uses Mixedbread AI's rerank API.
This class utilizes Mixedbread AI's reranking model to reorder a set of documents based on their relevance to a given query. The reranked documents are then used for various applications like search results refinement.
Example
Example