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-classicretrieversensembleEnsembleRetriever
    Class●Since v1.0

    EnsembleRetriever

    Copy
    EnsembleRetriever()

    Bases

    BaseRetriever

    Attributes

    Methods

    Inherited fromBaseRetriever(langchain_core)

    Attributes

    Amodel_configAtagsAmetadata

    Inherited fromRunnableSerializable(langchain_core)

    Attributes

    View source on GitHub
    A
    name
    Amodel_config

    Methods

    Mto_jsonMconfigurable_fieldsMconfigurable_alternatives

    Inherited fromSerializable(langchain_core)

    Attributes

    Alc_secretsAlc_attributesAmodel_config

    Methods

    Mis_lc_serializableMget_lc_namespaceMlc_idMto_jsonMto_json_not_implemented

    Inherited fromRunnable(langchain_core)

    Attributes

    AnameAInputTypeAOutputTypeAinput_schemaAoutput_schema

    Methods

    Mget_nameMget_input_schemaMget_input_jsonschemaMget_output_schemaMget_output_jsonschemaM

    Parameters

    NameTypeDescription
    retrievers*unknown

    A list of retrievers to ensemble.

    weights*unknown

    A list of weights corresponding to the retrievers. Defaults to equal weighting for all retrievers.

    c*unknown

    A constant added to the rank, controlling the balance between the importance of high-ranked items and the consideration given to lower-ranked items.

    id_key*unknown

    The key in the document's metadata used to determine unique documents. If not specified, page_content is used.

    attribute
    retrievers: list[RetrieverLike]
    attribute
    weights: list[float]
    attribute
    c: int
    attribute
    id_key: str | None
    attribute
    config_specs: list[ConfigurableFieldSpec]

    List configurable fields for this runnable.

    method
    invoke
    method
    ainvoke
    method
    rank_fusion

    Rank fusion.

    Retrieve the results of the retrievers and use rank_fusion_func to get the final result.

    method
    arank_fusion

    Rank fusion.

    Asynchronously retrieve the results of the retrievers and use rank_fusion_func to get the final result.

    method
    weighted_reciprocal_rank

    Perform weighted Reciprocal Rank Fusion on multiple rank lists.

    You can find more details about RRF here: https://plg.uwaterloo.ca/~gvcormac/cormacksigir09-rrf.pdf.

    Retriever that ensembles the multiple retrievers.

    It uses a rank fusion.

    config_schema
    Mget_config_jsonschema
    Mget_graph
    Mget_prompts
    Mpipe
    Mpick
    Massign
    Mbatch
    Mbatch_as_completed
    Mabatch
    Mabatch_as_completed
    Mstream
    Mastream
    Mastream_log
    Mastream_events
    Mtransform
    Matransform
    Mbind
    Mwith_config
    Mwith_listeners
    Mwith_alisteners
    Mwith_types
    Mwith_retry
    Mmap
    Mwith_fallbacks
    Mas_tool