LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • MCP Adapters
    • Overview
    • Agents
    • Callbacks
    • Chains
    • Chat models
    • Embeddings
    • Evaluation
    • Globals
    • Hub
    • Memory
    • Output parsers
    • Retrievers
    • Runnables
    • LangSmith
    • Storage
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    MCP Adapters
    OverviewAgentsCallbacksChainsChat modelsEmbeddingsEvaluationGlobalsHubMemoryOutput parsersRetrieversRunnablesLangSmithStorage
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-classicretrieversdocument_compressorscohere_rerankCohereRerank
    Classā—Since v1.0Deprecated

    CohereRerank

    Copy
    CohereRerank()

    Bases

    BaseDocumentCompressor

    Used in Docs

    • Cohere reranker integration

    Attributes

    Methods

    Inherited fromBaseDocumentCompressor(langchain_core)

    Methods

    Macompress_documents
    View source on GitHub
    attribute
    client: Any

    Cohere client to use for compressing documents.

    attribute
    top_n: int | None

    Number of documents to return.

    attribute
    model: str

    Model to use for reranking.

    attribute
    cohere_api_key: str | None

    Cohere API key. Must be specified directly or via environment variable COHERE_API_KEY.

    attribute
    user_agent: str

    Identifier for the application making the request.

    attribute
    model_config
    method
    validate_environment

    Validate that api key and python package exists in environment.

    method
    rerank

    Returns an ordered list of documents ordered by their relevance to the provided query.

    method
    compress_documents

    Compress documents using Cohere's rerank API.

    Document compressor that uses Cohere Rerank API.