LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-coredocumentscompressorBaseDocumentCompressor
    Class●Since v0.1

    BaseDocumentCompressor

    Base class for document compressors.

    This abstraction is primarily used for post-processing of retrieved documents.

    Document objects matching a given query are first retrieved.

    Then the list of documents can be further processed.

    For example, one could re-rank the retrieved documents using an LLM.

    Note

    Users should favor using a RunnableLambda instead of sub-classing from this interface.

    Copy
    BaseDocumentCompressor()

    Bases

    BaseModelABC

    Methods

    method
    compress_documents

    Compress retrieved documents given the query context.

    method
    acompress_documents

    Async compress retrieved documents given the query context.

    View source on GitHub