FREE STUDY NOTES · DBX-GENAI

Matching a chunking method to document structure

Which chunking method suits which kind of document.

From Ultra Transcenders DBX-GENAI by Tony Rough (coming December 2026)

Databricks states that there is no one-size-fits-all approach: the right method is iterative and depends on the use case and the data. The structure already in the document is the best first guide.

Method Where boundaries come from Named tool on the Databricks page Fits Breaks when
Fixed-size A set number of characters or tokens LangChain CharacterTextSplitter Quick baselines and a hard guard against a token limit Boundaries fall mid-thought; Databricks says it rarely works for production-grade applications
Paragraph-based Natural paragraph breaks LangChain RecursiveCharacterTextSplitter Prose where a paragraph holds one idea Paragraph lengths vary widely, or a single idea runs across several paragraphs
Format-specific Markup such as Markdown or HTML headers LangChain MarkdownHeaderTextSplitter, HTML header or section splitters Documentation, wikis, web pages Source has lost its structure during parsing
Semantic Topic shifts or similarity between sentences LangChain SemanticChunker Long content with no reliable markup More effort to build and run than the basic approaches

Some decision rules follow from that table:

A token-counted split is still useful as a safety net beneath a structural method, or for a first baseline. The Databricks example notebook uses this pattern with tiktoken, here with a smaller limit than the notebook’s 8192:

import tiktoken

max_chunk_tokens = 512
encoding = tiktoken.get_encoding("cl100k_base")

def chunk_text(text):
    tokens = encoding.encode(text)
    chunks = []
    while tokens:
        chunk_tokens = tokens[:max_chunk_tokens]
        chunks.append(encoding.decode(chunk_tokens))
        tokens = tokens[max_chunk_tokens:]
    return chunks

This loop has no overlap and no regard for sentences, so it is a guard rather than a finished strategy. It also needs a new unique chunk ID for each piece: the same notebook builds one from the source ID and a counter, as in f"{row['id']}_{chunk_no}".

Common trap: Reading “recursive” splitters as a form of semantic chunking - the Databricks page lists RecursiveCharacterTextSplitter under paragraph-based chunking, and its fixed-size example also uses that class with chunk_size=100 and chunk_overlap=20. The page groups it with LangChain’s character splitters, while SemanticChunker is its semantic example.

Get the whole book

This note is one section of Ultra Transcenders DBX-GENAI: Databricks Generative AI Engineer Associate, an independent study guide that explains every topic the exam covers by technology, with comparison tables, diagrams and the common traps, plus a glossary linked to the Databricks documentation.

Amazon.co.ukKindle: coming soonPaperback: coming soon
Amazon.comKindle: coming soonPaperback: coming soon

Due on Amazon in December 2026, in Kindle and paperback editions.

About the book · DBX-GENAI terms in the glossary · All DBX-GENAI study notes

More DBX-GENAI study notes