langchain.retrievers.ensemble.EnsembleRetriever¶
class langchain.retrievers.ensemble.EnsembleRetriever[source]¶
Bases: BaseRetriever
Retriever that ensembles the multiple retrievers.
It uses a rank fusion.
Parameters
retrievers – A list of retrievers to ensemble.
weights – A list of weights corresponding to the retrievers. Defaults to equal
weighting for all retrievers.
c – A constant added to the rank, controlling the balance between the importance
of high-ranked items and the consideration given to lower-ranked items.
Default is 60.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
param c: int = 60¶
param metadata: Optional[Dict[str, Any]] = None¶
Optional metadata associated with the retriever. Defaults to None
This metadata will be associated with each call to this retriever,
and passed as arguments to the handlers defined in callbacks.
You can use these to eg identify a specific instance of a retriever with its
use case.
param retrievers: List[langchain.schema.retriever.BaseRetriever] [Required]¶
param tags: Optional[List[str]] = None¶
Optional list of tags associated with the retriever. Defaults to None
These tags will be associated with each call to this retriever,
and passed as arguments to the handlers defined in callbacks.
You can use these to eg identify a specific instance of a retriever with its
use case.
param weights: List[float] [Required]¶
async abatch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) → List[Output]¶