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-coreexample_selectors
    Module●Since v0.1

    example_selectors

    Example selectors.

    Example selector implements logic for selecting examples to include them in prompts. This allows us to select examples that are most relevant to the input.

    Functions

    function
    import_attr

    Import an attribute from a module located in a package.

    This utility function is used in custom __getattr__ methods within __init__.py files to dynamically import attributes.

    function
    sorted_values

    Return a list of values in dict sorted by key.

    Classes

    class
    BaseExampleSelector

    Interface for selecting examples to include in prompts.

    class
    LengthBasedExampleSelector

    Select examples based on length.

    class
    MaxMarginalRelevanceExampleSelector

    Select examples based on Max Marginal Relevance.

    This was shown to improve performance in this paper: https://arxiv.org/pdf/2211.13892.pdf

    class
    SemanticSimilarityExampleSelector

    Select examples based on semantic similarity.

    Modules

    module
    length_based

    Select examples based on length.

    module
    semantic_similarity

    Example selector that selects examples based on SemanticSimilarity.

    module
    base

    Interface for selecting examples to include in prompts.

    View source on GitHub