Chunking

BytapaScript

In a nutshell

Splitting documents into smaller pieces before embedding.

What it means

Breaking large documents into smaller pieces of information.

💡 Dividing a textbook into chapters and sections so a topic can be found quickly.

Code example

import { RecursiveCharacterTextSplitter } from "langchain/text_splitter";
const splitter = new RecursiveCharacterTextSplitter({
  chunkSize: 500,
  chunkOverlap: 50,
});
const chunks = await splitter.splitText(longDocument);

Why it matters

Smaller chunks make retrieval more focused and provide relevant context without sending entire documents to the model.

When to use it

  • Preparing documents for RAG
  • Splitting long text for indexing

Related terms

Learn Full Stack

with tapaScript

By clicking Sign Up you re confirming that you agree with our Terms and Conditions.

newsletter

Don't forget to connect with us on