02. Cohere Reranker

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.

# 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

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

# API KEY load information
load_dotenv()
 True 
# LangSmith set up tracking. https://smith.langchain.com
# !pip install langchain-teddynote
from langchain_teddynote import logging

# Enter a project name.
logging.langsmith("Reranker")

Usage

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

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!

Last updated