MixedbreadAIReranker
Defined in: .build/typescript/packages/providers/mixedbread/src/MixedbreadAIReranker.ts:78
Node postprocessor that uses MixedbreadAI’s rerank API.
This class utilizes MixedbreadAI’s rerank model to reorder a set of nodes based on their relevance to a given query. The reranked nodes are then used for various applications like search results refinement.
Examples
Section titled “Examples”const reranker = new MixedbreadAIReranker(\{ apiKey: 'your-api-key' \});const nodes = [\{ node: new BaseNode('To bake bread you need flour') \}, \{ node: new BaseNode('To bake bread you need yeast') \}];const query = "What do you need to bake bread?";const result = await reranker.postprocessNodes(nodes, query);console.log(result);
const reranker = new MixedbreadAIReranker(\{ apiKey: 'your-api-key', model: 'mixedbread-ai/mxbai-rerank-large-v1', topK: 5, rankFields: ["title", "content"], returnInput: true, maxRetries: 5\});const documents = [\{ title: "Bread Recipe", content: "To bake bread you need flour" \}, \{ title: "Bread Recipe", content: "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);
Implements
Section titled “Implements”BaseNodePostprocessor
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new MixedbreadAIReranker(
params
):MixedbreadAIReranker
Defined in: .build/typescript/packages/providers/mixedbread/src/MixedbreadAIReranker.ts:89
Constructor for MixedbreadRerank.
Parameters
Section titled “Parameters”params
Section titled “params”Partial
<MixedbreadAIRerankerParams
>
An optional object with properties to configure the instance.
Returns
Section titled “Returns”MixedbreadAIReranker
Throws
Section titled “Throws”If the API key is not provided or found in the environment variables.
Properties
Section titled “Properties”requestParams
Section titled “requestParams”requestParams:
RerankingRequestWithoutInput
Defined in: .build/typescript/packages/providers/mixedbread/src/MixedbreadAIReranker.ts:79
requestOptions
Section titled “requestOptions”requestOptions:
RequestOptions
Defined in: .build/typescript/packages/providers/mixedbread/src/MixedbreadAIReranker.ts:80
Methods
Section titled “Methods”postprocessNodes()
Section titled “postprocessNodes()”postprocessNodes(
nodes
,query?
):Promise
<NodeWithScore
<Metadata
>[]>
Defined in: .build/typescript/packages/providers/mixedbread/src/MixedbreadAIReranker.ts:142
Reranks the nodes using the mixedbread.ai API.
Parameters
Section titled “Parameters”NodeWithScore
<Metadata
>[]
Array of nodes with scores.
query?
Section titled “query?”MessageContent
Query string.
Returns
Section titled “Returns”Promise
<NodeWithScore
<Metadata
>[]>
A Promise that resolves to an ordered list of nodes with relevance scores.
Throws
Section titled “Throws”If query is undefined.
Example
Section titled “Example”const nodes = [\{ node: new BaseNode('To bake bread you need flour') \}, \{ node: new BaseNode('To bake bread you need yeast') \}];const query = "What do you need to bake bread?";const result = await reranker.postprocessNodes(nodes, query);console.log(result);
Implementation of
Section titled “Implementation of”BaseNodePostprocessor.postprocessNodes
rerank()
Section titled “rerank()”rerank(
nodes
,query
,options?
):Promise
<RankedDocument
[]>
Defined in: .build/typescript/packages/providers/mixedbread/src/MixedbreadAIReranker.ts:187
Returns an ordered list of documents sorted by their relevance to the provided query.
Parameters
Section titled “Parameters”A list of documents as strings, DocumentInterfaces, or objects with a pageContent
key.
BaseNode
<Metadata
>[] | string
[] | Record
<string
, unknown
>[]
string
The query to use for reranking the documents.
options?
Section titled “options?”RerankingRequestWithoutInput
Optional parameters for reranking.
Returns
Section titled “Returns”Promise
<RankedDocument
[]>
A Promise that resolves to an ordered list of documents with relevance scores.
Example
Section titled “Example”const nodes = ["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(nodes, query);console.log(result);