GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • LangChain Reference home page
  • GitHub
  • Main Docs
  • Deep Agents
  • LangChain
  • LangGraph
  • Integrations
  • LangSmith
  • langchain-text-splitters
  • base

This view

  • Original page
  • New address

GeezerVison is showing reference.langchain.com — TextSplitter | langchain_text_splitters

  • Overview
  • MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    Menu

    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Class●Since v0.0

    TextSplitter

    Copy
    TextSplitter(
      self,
      chunk_size: int = 4000,
      chunk_overlap: int = 200,
      length_function:

    Bases

    BaseDocumentTransformerABC

    Constructors

    Methods

    Inherited fromBaseDocumentTransformer(langchain_core)

    Methods

    Matransform_documents
    View source on GitHub
    Callable
    [
    [
    str
    ]
    ,
    int
    ]
    =
    len
    ,
    keep_separator
    :
    bool
    |
    Literal
    [
    'start'
    ,
    'end'
    ]
    =
    False
    ,
    add_start_index
    :
    bool
    =
    False
    ,
    strip_whitespace
    :
    bool
    =
    True
    )

    Parameters

    NameTypeDescription
    chunk_sizeint
    Default:4000

    Maximum size of chunks to return

    chunk_overlapint
    Default:200

    Overlap in characters between chunks

    length_functionCallable[[str], int]
    Default:len
    keep_separatorbool | Literal['start', 'end']
    Default:False
    add_start_indexbool
    Default:False
    strip_whitespacebool
    Default:True
    constructor
    __init__
    NameType
    chunk_sizeint
    chunk_overlapint
    length_functionCallable[[str], int]
    keep_separatorbool | Literal['start', 'end']
    add_start_indexbool
    strip_whitespacebool
    method
    split_text

    Split text into multiple components.

    method
    create_documents

    Create a list of Document objects from a list of texts.

    method
    split_documents

    Split documents.

    method
    from_huggingface_tokenizer

    Text splitter that uses Hugging Face tokenizer to count length.

    method
    from_tiktoken_encoder

    Text splitter that uses tiktoken encoder to count length.

    method
    transform_documents

    Transform sequence of documents by splitting them.

    Interface for splitting text into chunks.

    Function that measures the length of given chunks

    Whether to keep the separator and where to place it in each corresponding chunk (True='start')

    If True, includes chunk's start index in metadata

    If True, strips whitespace from the start and end of every document

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.