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

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

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

    from_llm

    Copy
    from_llm(
      cls,
      llm: BaseLanguageModel,
      vectorstore: VectorStore,
      document_contents: str,
      
    View source on GitHub
    metadata_field_info
    :
    Sequence
    [
    AttributeInfo
    |
    dict
    ]
    ,
    structured_query_translator
    :
    Visitor
    |
    None
    =
    None
    ,
    chain_kwargs
    :
    dict
    |
    None
    =
    None
    ,
    enable_limit
    :
    bool
    =
    False
    ,
    use_original_query
    :
    bool
    =
    False
    ,
    **
    kwargs
    :
    Any
    =
    {
    }
    )
    ->
    SelfQueryRetriever

    Parameters

    NameTypeDescription
    llm*BaseLanguageModel

    The language model to use for generating queries.

    vectorstore*VectorStore

    The vector store to use for retrieving documents.

    document_contents*str

    Description of the page contents of the document to be queried.

    metadata_field_info*Sequence[AttributeInfo | dict]
    structured_query_translatorVisitor | None
    Default:None
    chain_kwargsdict | None
    Default:None
    enable_limitbool
    Default:False
    use_original_querybool
    Default:False
    **kwargsAny
    Default:{}

    Create a SelfQueryRetriever from an LLM and a vector store.

    Metadata field information for the documents.

    Optional translator for turning internal query language into VectorStore search params.

    Additional keyword arguments for the query constructor.

    Whether to enable the limit operator.

    Whether to use the original query instead of the revised query from the LLM.

    Additional keyword arguments for the SelfQueryRetriever.