Skip to content
AI Skills Central

Type to search Agent Skills, workflows, tutorials, tools and the glossary.

Chunking

Definition

Splitting documents into pieces sized for embedding and retrieval, ideally along natural boundaries such as sections or paragraphs.

In more detail

Chunks that are too small lose context; chunks that are too large dilute the match and waste prompt space. Keeping headings with their text and storing the source location with each chunk makes answers easier to cite.

Common approaches are fixed-size chunks with some overlap, splitting on document structure such as headings and paragraphs, and splitting where the topic changes. Structure-aware splitting usually works best for manuals and policies; code is better split by function or class.

There is no universally right chunk size. Build a small golden set of questions, try two or three settings and compare context recall and answer quality. Store each chunk's document title and section path in its metadata so you can filter and cite.

  • Contextual retrieval

    Adding a short, model-written note on where each chunk sits in its source document before embedding and indexing the chunk.

  • Document parsing

    Converting PDFs, Office files, scans and web pages into clean text with structure, such as headings and tables, before indexing.

  • Embedding

    A vector representation of text or other data that places items with similar meaning close together, so they can be searched by similarity.

  • Retrieval-augmented generation (RAG)

    Retrieving relevant documents and adding them to the prompt before the model generates an answer from them.

  • Vector database

    A database designed to store embeddings and quickly find the nearest neighbours to a query vector, often with metadata filtering.

  • Metadata filtering

    Narrowing a vector or keyword search with structured fields, such as date, language or access rights, before or during the search.

  • Chunking strategies for RAG, tested

    Compare fixed-size, heading-based and semantic chunking on the same documents and questions, measure retrieval hit rate, and pick a strategy with evidence.

    TutorialIntermediate1 h

  • RAG fundamentals: retrieval before generation

    What RAG is and how retrieval-augmented generation works, when it beats long context or fine-tuning, and a minimal working pipeline in about 80 lines of Python.

    TutorialBeginner30 min

  • Evaluate RAG answers with a golden dataset

    Set up RAG evaluation with a golden dataset and promptfoo: score retrieval, correctness and grounding for every question, and fail CI when answer quality drops.

    WorkflowIntermediate2 h6 steps