Create a self-querying retriever from an LLM, vector store, and document metadata.
This method does NOT create the vector search index. See example usage.
from_llm(
cls,
llm: BaseLanguageModel,
vectorstore: VectorStore,
document_contents: str,
metadata_field_info: Sequence[Union[AttributeInfo, dict]],
enable_limit: bool = False,
use_original_query: bool = False,
**kwargs: Any = {}
) -> SelfQueryRetrieverReturns: A retriever invoked by a text query.
| Name | Type | Description |
|---|---|---|
llm* | BaseLanguageModel | A Reasoning model that will produce the structured query. |
vectorstore* | VectorStore | MongoDBAtlasVectorSearch. |
document_contents* | str | Description of the data in the collection. |
metadata_field_info* | Sequence[Union[AttributeInfo, dict]] | Fields must be present in vector search index. |
enable_limit | bool | Default: FalseWhether to instruct the LLM to look for statements involving limits. |
use_original_query | bool | Default: FalseBy default, sentences defining filters and limits are removed from query. Set to True if you wish to include these in the text to embed. |
**kwargs | Any | Default: {}Additional arguments to pass to retriever constructor (e.g. search_kwargs) |