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

    ParentDocumentRetriever

    Copy
    ParentDocumentRetriever()

    Bases

    MultiVectorRetriever

    Attributes

    Methods

    Inherited fromMultiVectorRetriever

    Attributes

    Avectorstore: VectorStore
    —

    The underlying VectorStore to use to store small chunks

    Abyte_store: ByteStore | None
    —

    The lower-level backing storage layer for the parent documents

    Adocstore: BaseStore[str, Document]
    —
    View source on GitHub

    The storage interface for the parent documents

    Aid_key: str
    Asearch_kwargs: dict
    —

    Keyword arguments to pass to the search function.

    Asearch_type: SearchType
    —

    Type of search to perform (similarity / mmr)

    Inherited fromBaseRetriever(langchain_core)

    Attributes

    Amodel_configAtagsAmetadata

    Methods

    MinvokeMainvoke

    Inherited fromRunnableSerializable(langchain_core)

    Attributes

    AnameAmodel_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_schemaAconfig_specs

    Methods

    Mget_nameMget_input_schemaMget_input_jsonschemaMget_output_schemaMget_output_jsonschemaM
    attribute
    child_splitter: TextSplitter

    The text splitter to use to create child documents.

    attribute
    parent_splitter: TextSplitter | None

    The text splitter to use to create parent documents. If none, then the parent documents will be the raw documents passed in.

    attribute
    child_metadata_fields: Sequence[str] | None

    Metadata fields to leave in child documents. If None, leave all parent document metadata.

    method
    add_documents

    Adds documents to the docstore and vectorstores.

    method
    aadd_documents

    Adds documents to the docstore and vectorstores.

    Retrieve small chunks then retrieve their parent documents.

    When splitting documents for retrieval, there are often conflicting desires:

    1. You may want to have small documents, so that their embeddings can most accurately reflect their meaning. If too long, then the embeddings can lose meaning.
    2. You want to have long enough documents that the context of each chunk is retained.

    The ParentDocumentRetriever strikes that balance by splitting and storing small chunks of data. During retrieval, it first fetches the small chunks but then looks up the parent IDs for those chunks and returns those larger documents.

    Note that "parent document" refers to the document that a small chunk originated from. This can either be the whole raw document OR a larger chunk.

    config_schema
    Mget_config_jsonschema
    Mget_graph
    Mget_prompts
    Mpipe
    Mpick
    Massign
    Minvoke
    Mainvoke
    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