Cohere Rerank Retriever
The Cohere Rerank Retriever is a specialized retriever that uses Cohere’s reranking capabilities to improve the relevance of retrieved documents. It works by first retrieving documents from a base vector store retriever, then reranking these documents based on their semantic relevance to the query using Cohere’s AI models.
Node Details
-
Name: cohereRerankRetriever
-
Type: Cohere Rerank Retriever
-
Version: 1.0
-
Category: Retrievers
Input Parameters
-
Vector Store Retriever (required)
-
Type: VectorStoreRetriever
-
Description: The base retriever to fetch initial documents from a vector store.
-
-
Model Name (optional)
-
Type: Options
-
Default: “rerank-english-v2.0”
-
Options:
-
rerank-english-v2.0
-
rerank-multilingual-v2.0
-
-
Description: The Cohere model to use for reranking.
-
-
Query (optional)
-
Type: string
-
Description: Specific query to retrieve documents. If not provided, the user’s question will be used.
-
-
Top K (optional)
-
Type: number
-
Default: Inherits from base retriever, or 4 if not specified
-
Description: Number of top results to fetch after reranking.
-
-
Max Chunks Per Doc (optional)
-
Type: number
-
Default: 10
-
Description: Maximum number of chunks to produce internally from a document.
-
Outputs
-
Cohere Rerank Retriever
-
Type: BaseRetriever
-
Description: The configured Cohere Rerank Retriever object.
-
-
Document
-
Type: Document[]
-
Description: Array of retrieved and reranked document objects, containing metadata and page content.
-
-
Text
-
Type: string
-
Description: Concatenated string of page content from all retrieved and reranked documents.
-
Credentials
-
Credential Name: cohereApi
-
Required Parameters: cohereApiKey
How It Works
-
The node first initializes a base retriever (usually a vector store retriever).
-
It then creates a CohereRerank compressor using the provided API key, model, and parameters.
-
A ContextualCompressionRetriever is created, combining the base retriever and the Cohere reranker.
-
When queried, it retrieves documents from the base retriever and reranks them using Cohere’s AI.
-
The output can be the retriever itself, the reranked documents, or the concatenated text of the documents.
Use Cases
-
Improving relevance of document retrieval in question-answering systems.
-
Enhancing search results by considering semantic similarity.
-
Creating more accurate document summaries by focusing on the most relevant parts.
Notes
-
This node requires a Cohere API key to function.
-
The effectiveness of the reranking depends on the quality of the initial retrieval and the chosen Cohere model.
-
Consider the trade-off between retrieval speed and accuracy when adjusting the Top K and Max Chunks Per Doc parameters.
Was this page helpful?