langchain.retrievers.bm25.BM25Retriever¶
class langchain.retrievers.bm25.BM25Retriever[source]¶
Bases: BaseRetriever
BM25 retriever without Elasticsearch.
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 docs: List[langchain.schema.document.Document] [Required]¶
List of documents.
param k: int = 4¶
Number of documents to return.
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 preprocess_func: Callable[[str], List[str]] = <function default_preprocessing_func>¶
Preprocessing function to use on the text before BM25 vectorization.
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 vectorizer: Any = None¶
BM25 vectorizer.
async abatch(inputs: List[Input], config: Optional[Union[RunnableConfig, List[RunnableConfig]]] = None, *, return_exceptions: bool = False, **kwargs: Optional[Any]) → List[Output]¶
Default implementation of abatch, which calls ainvoke N times.
Subclasses should override this method if they can batch more efficiently.