CertSafari
    Databricks Certified Generative AI Engineer Associate· Lessons

    Domain 2 · Lesson 13/56

    Advanced chunking strategies for RAG retrieval

    Design retrieval systems using advanced chunking strategies

    13 min read
    1.75% of exam
    2 sources
    Published 22 Oct 2026
    Docs as of 17 Oct 2026

    What you will be able to do

    • Pick a chunking strategy that matches a document set's structure: header-based, paragraph-based, semantic or fixed-size
    • Use chunk overlap to fix facts that get split across chunk boundaries, and rule out changes that don't help
    • Design parent-child (small-to-big) chunking and store the link from each child to its parent in the source table

    Key concept

    Chunk boundary — A chunk boundary is the place where a document is cut into retrievable units. Good boundaries follow the document's own topics, so each chunk makes sense alone. Bad boundaries mix unrelated topics into one chunk or split one fact across two chunks.

    1.Why chunk boundaries decide what retrieval can find

    A retriever can only return the chunks you created. If a chunk mixes two topics, its embedding sits halfway between them and matches neither topic well. If an answer is split across two chunks, no single retrieved chunk holds the whole answer. Chunking is one of the first places to optimise a RAG application, because every later stage only works with what the chunker produced.

    Chunk size is a trade-off with no universal answer. Smaller chunks pin down specific facts but lose the context around them. Larger chunks keep more context but make the relevant passage harder to locate, and they cost more to process. Retrieval also returns several chunks per query, and all of them must fit in the LLM's context window together. Common starting points to test are 256 tokens for precise fact retrieval, 512 as a balanced middle and 1024 for more context per chunk.

    Size is rarely the biggest lever, though. Clean parsing, metadata extracted for filtering, and semantic metadata such as document summaries and section headers usually do more for retrieval than fine-tuning a size. Clean input is also a precondition for any of these strategies: if headers, footers and page numbers survive parsing, they end up inside the chunks and dilute every embedding. That cleanup step is taught in Removing boilerplate and noise during parsing.

    Checkpoint 1 of 8· Check yourself

    A team's RAG application returns weak matches. The parsing is already clean. They plan to spend the next sprint tuning chunk size. According to the guidance, which change usually does more for retrieval than tuning the size?

    Sources12

    2.Splitting on document structure: headers and paragraphs

    Choose the strategy that uses whatever structure the documents actually have. Markdown and HTML pages give you headers for free. Tools such as LangChain's MarkdownHeaderTextSplitter, or HTML splitters that cut by header or section, turn those headers into chunk boundaries. The heading text can then travel with the chunk. Metadata such as the source document name, section heading or product name helps match retrieval queries to chunks, so a chunk from 'Troubleshooting > Network errors' still says where it came from after it has been cut out of the page.

    Paragraph-based chunking, for example LangChain's RecursiveCharacterTextSplitter, is the next best option when paragraphs are the only structure available. Paragraphs usually hold related information, so the chunks stay reasonably coherent. Used on a header-organised document, though, it drops the section hierarchy and can merge the end of one section with the start of the next. Fixed-size chunking cuts after a set number of characters or tokens. It is quick to set up but ignores meaning, and it rarely works for production-grade applications.

    Chunking strategies, the signal each one cuts on, and when it wins
    StrategyBoundary signalWins when
    Fixed-size (CharacterTextSplitter)A set number of characters or tokensQuick prototyping; rarely good enough for production
    Paragraph-based (RecursiveCharacterTextSplitter)Natural paragraph breaksProse with paragraphs but no reliable headers
    Format-specific (MarkdownHeaderTextSplitter, HTML header/section splitters)Markdown headers or HTML sectionsDocuments with consistent header structure
    Semantic (SemanticChunker)Topic shifts found from the content itselfText that changes topic with no headers or paragraph markers

    Checkpoint 2 of 8· Match them up

    Four corpora need a chunker. Match each chunking strategy to the corpus where it is the best fit.

    Tap a term, then the definition that fits it.

    Checkpoint 3 of 8· Exam question

    A team is building a RAG chatbot over internal engineering documentation written in Markdown, where every page uses consistent H1/H2/H3 headers to organize topics such as installation, configuration, and troubleshooting. Which chunking strategy is best suited to this document set to preserve topical boundaries?

    Sources1

    3.Semantic chunking when the text has no markers

    Header and paragraph splitters only work if the markers exist. Consider a compiled FAQ page that covers several unrelated subtopics as one continuous block of text, with no headings and no paragraph breaks. A header splitter has nothing to cut on. A fixed-size splitter, with or without overlap, cuts every N tokens wherever that lands, so one chunk can end up holding half of two different subtopics.

    Semantic chunking finds the boundaries from the content itself. It groups sentences by how similar they are, not by a fixed size, and uses embeddings to find the natural breaks. In practice, you embed consecutive sentences and start a new chunk where similarity between neighbours drops sharply, because that drop marks a change of topic. Topic modelling is another way to find these breaks. These methods take more work than basic splitters, but they keep related ideas together and preserve context better. LangChain's SemanticChunker is one implementation.

    Checkpoint 4 of 8· Check yourself

    An internal FAQ export is one continuous block of text. It covers billing, password resets and API limits, with no headings or paragraph breaks. Which chunking approach keeps each subtopic in its own chunks, and where does it cut?

    Checkpoint 5 of 8· Exam question

    A support knowledge base consists of long compiled FAQ articles where a single page can cover several unrelated subtopics with no headers or paragraph markers to indicate where one topic ends and another begins. Which chunking approach directly addresses this document characteristic?

    Sources21

    4.Overlap for facts that straddle a boundary

    Even good boundaries sometimes fall in the middle of a fact. If a sentence that names a setting lands at the end of chunk 7 and the sentence giving its value lands at the start of chunk 8, neither chunk answers the question alone. Overlap fixes this. Each chunk repeats a window of the previous chunk's trailing text, so content near the boundary appears in both chunks. LangChain's character splitters set this with chunk_overlap. A sample configuration uses chunk_size=100 and chunk_overlap=20.

    The other likely fixes miss the cause. Shrinking chunks creates more boundaries, so more facts get split, and each chunk loses more of its context. Switching to a fixed-character splitter makes the boundaries more uniform but less meaningful. Retrieving more chunks per query is not a chunking change at all: it may bring both halves back, but they still arrive as separate pieces, and every extra chunk takes room in the LLM's context window.

    Checkpoint 6 of 8· Check yourself

    Users ask for a timeout setting's value and get incomplete answers. You find that the sentence naming the setting ends one chunk and the sentence giving its value starts the next one. Which change fixes the cause?

    Checkpoint 7 of 8· Exam question

    During evaluation, a RAG engineer notices that answers referencing information near a chunk boundary are frequently incomplete, because the fact needed to answer the question is split across two adjacent chunks. Which change to the chunking configuration best addresses this specific problem?

    Sources1

    5.Parent-child chunking: search small, return big

    The size trade-off has one structural way out: use one size for matching and another for answering. In parent-child chunking, also called small-to-big retrieval, each document is cut into large parent chunks, and each parent is cut again into small child chunks. Only the children are embedded and searched. A 512-token child holds one focused idea, so it matches a precise query well. The 2048-token parent is what the LLM receives, so the answer comes with its surrounding context.

    The link from child to parent is stored as a column on the child's row. Each row in the source table holds the child text in text, which is the column that gets embedded, and the full parent text in parent_text. At query time, the similarity search runs over the children and requests both columns back. The application then passes parent_text to the LLM. No second lookup is needed because the parent travels with every child.

    Recording child and parent chunks together, then searching children and returning parentspython
    # Record child and parent chunks in your source table
    for parent_chunk in create_chunks(doc, size=2048):  # Large for context
        for child_chunk in create_chunks(parent_chunk, size=512):  # Small for precision
            source_table.append({"text": child_chunk, "parent_text": parent_chunk})
    
    # Search children, return parents
    results = index.similarity_search(
        query_text="Is attention all you need?",
        num_results=10,
        columns=["text", "parent_text"]
    )

    Checkpoint 8 of 8· Fill the gap

    This small-to-big retrieval sample searches the small child chunks, but the LLM must receive the large parent chunk. Which value completes the columns list?

    # Record child and parent chunks in your source table
    for parent_chunk in create_chunks(doc, size=2048):  # Large for context
        for child_chunk in create_chunks(parent_chunk, size=512):  # Small for precision
            source_table.append({"text": child_chunk, "parent_text": parent_chunk})
    
    # Search children, return parents
    results = index.similarity_search(
        query_text="Is attention all you need?",
        num_results=10,
        columns=["text",  ? ]
    )

    Sources2

    Sources

    (2)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Smaller chunks may focus on specific details but lose some surrounding contextual information.”
      ↩︎ Why chunk boundaries decide what retrieval can find
      “Relevant metadata, such as the source document name, section heading, or product names, can improve retrieval.”
      ↩︎ Splitting on document structure: headers and paragraphs
      “Use the natural paragraph boundaries in the text to define chunks.”
      ↩︎ Splitting on document structure: headers and paragraphs
      “determine the most appropriate chunk boundaries based on topic shifts”
      ↩︎ Semantic chunking when the text has no markers
      “To ensure that important information is not lost when splitting the data into chunks, consider including some overlap between adjacent chunks.”
      ↩︎ Overlap for facts that straddle a boundary
      “aim to create semantically coherent chunks that contain related information but can stand independently as a meaningful unit of text”
      ↩︎ Key concept
      “This approach rarely works for production-grade applications.”
      ↩︎ Exam trap 1
      “Overlapping can ensure continuity and context preservation across chunks and improve the retrieval results.”
      ↩︎ Exam trap 2
      “Formats such as Markdown or HTML have an inherent structure that can define chunk boundaries (for example, markdown headers).”
      ↩︎ Prediction
      “These approaches analyze the content or structure of each document to determine the most appropriate chunk boundaries based on topic shifts.”
      ↩︎ Checkpoint
    2. 2.
      “Context limits: Must fit within LLM context window when retrieving multiple chunks.”
      ↩︎ Why chunk boundaries decide what retrieval can find
      “Semantic metadata: Add document summaries and section headers to chunks.”
      ↩︎ Why chunk boundaries decide what retrieval can find
      “Group sentences by similarity rather than fixed size.”
      ↩︎ Semantic chunking when the text has no markers
      “Parent-child chunking (small-to-big retrieval):”
      ↩︎ Parent-child chunking: search small, return big
      “Instead of over-optimizing chunk size, focus on:”
      ↩︎ Exam trap 3
      “More impactful optimizations: Instead of over-optimizing chunk size, focus on:”
      ↩︎ Checkpoint

    Continue to part 2 of 2

    Context-enriched chunks and ai_prep_search

    Spotted a mistake, or was something unclear? Tell us.