02. Cohere Reranker

Cohere Is a Canadian startup that provides a natural language processing model that helps companies improve human-machine interaction.

This laptop retriever in Cohere rerank endpoint Shows how to use.

Copy

# installation
# !pip install -qU cohere

Cohere API key setting

  • .env To file COHERE_API_KEY Please put the API key in the key value.

Reference - Official document - Reranker Model List

Copy

# API KEY A configuration file for managing environment variables
from dotenv import load_dotenv

# API KEY load information
load_dotenv()

Copy

 True 

Copy

Copy

Usage

Copy

Cohere multilingual support model

  • Embedding: embed-multilingual-v3.0 , embed-multilingual-light-v3.0 , embed-multilingual-v2.0

  • Reranker: rerank-multilingual-v3.0 , rerank-multilingual-v2.0

Copy

Copy

Rearrangement using CohereRerank

Now the basics retriever for ContextualCompressionRetriever I'll wrap it up with. Rearrange returned results using the Cohere rearrangement endpoint CohereRerank Will add Note that it is essential to name the model in CohereRerank!

Copy

Copy

Last updated