Courses · The Ambush Method

Pick your exam.

Every guide follows the same method: short daily sessions, the traps each topic sets, and exam-style questions with an explanation for every option.

  • 100% free · no paywalls, subscriptions or ads
  • 30–60 min a day
  • Exam-style questions
  • Taught in English

Chunking Strategies for Databricks RAG (and the Silent Truncation Trap)

Chunking strategy for RAG on Databricks: cut along document structure, respect the embedding window, retrieve small and serve the parent

Picking a chunking strategy for RAG on Databricks looks like a settings question. Choose a number, 500 tokens maybe, and move on. That’s exactly how the Generative AI Engineer Associate exam catches people. The chunking questions don’t reward a favorite number. They reward knowing which of three separate decisions the scenario is really about, and one of those decisions hides a failure that never throws an error: text that gets embedded as if it were never written. I call it the silent truncation trap, and by the end of this post you’ll see it coming.

If you’re new here, my Databricks Generative AI Engineer Associate study guide has the full map of the exam. This post zooms into the chunking part of it, which touches more of the exam than most people expect.

Why chunking shows up all over the exam

On the official exam page, Data Preparation carries 14% and Application Development carries 30%. Chunking lives in both. Data Preparation asks you to apply a chunking strategy for a given document structure and model constraints, and to design retrieval with advanced chunking strategies. Application Development asks you to select a chunking strategy based on model and retrieval evaluation.

Read those three objectives again and notice the different verbs: apply, design, select. They’re not three ways of saying the same thing. They’re three different steps, and the exam writes wrong answers that do the right work at the wrong step. That’s the ambush.

The model I use: chunking is three decisions, not one number

In my book I call this the chunking cascade. Where you cut a document is decided at three levels, stacked top to bottom, and each level narrows the one below it:

  • Document structure decides where a clean cut can fall.
  • Model constraints decide how large a piece is allowed to be.
  • Retrieval granularity decides how the pieces get used: what you match on and what you hand the model.

This is why there’s no universal chunk size. A contract, a chat log and a product manual can’t share one number, because they disagree at the very first level. Anyone who gives you a single value has quietly squashed three decisions into one.

Level 1: let the document’s shape pick the splitter

Most documents already tell you where they want to come apart. Markdown has headings. HTML has tags. Contracts have numbered clauses. Cut along those lines and each chunk still reads as a complete section. Cut across them at a blind character count and you get pieces that end mid-clause and start mid-thought, with their heading stranded somewhere behind them.

Here’s how I run the menu as one decision:

  • Explicit structure (Markdown, HTML, clearly sectioned docs): a header-based splitter. It cuts at the headings and keeps them as metadata, so each chunk knows which section it came from.
  • Ordinary prose (articles, transcripts, flowing policies): a recursive character splitter. It tries paragraphs first, then sentences, then words, only falling back to a hard cut when nothing better fits. It’s the sensible default when you’re unsure.
  • Prose with hidden topic shifts: semantic chunking. It embeds sentences and cuts where the meaning changes. It’s the most expensive option, so it earns its place only when the structure is real but unmarked.
  • Fixed-size: the baseline the others improve on. Fine when the text has no structure worth keeping and speed matters more than precision.

Trap: fixed-size on a structured document

When a scenario takes the time to describe a document’s structure (“Markdown docs with clear headings”, “an HTML knowledge base”), that description is the answer. The fixed-size option sounds neutral and safe, but it throws away the boundaries the scenario just handed you. If the question names the structure, cut along it.

Trap: “semantic” chunking is not semantic search

Same tool, different job, different moment. Semantic chunking uses embeddings at prep time to decide where to split. Semantic search uses embeddings at query time to find a chunk. If the question is about how to divide a document, an answer about retrieval is off target, and the other way around.

Structure picks the primary boundaries, but it doesn’t replace the size limit. A long section can still be too big for the embedding model, so in practice a header splitter is usually followed by a size-capped splitter for anything oversized. In LangChain that’s a few lines:

from langchain_text_splitters import (
    MarkdownHeaderTextSplitter,
    RecursiveCharacterTextSplitter,
)

# Level 1: cut along the structure the author already drew
header_splitter = MarkdownHeaderTextSplitter(
    headers_to_split_on=[("#", "h1"), ("##", "h2"), ("###", "h3")]
)
sections = header_splitter.split_text(markdown_doc)  # headings kept as metadata

# Level 2: any section that is still too long gets sub-divided to fit
sizer = RecursiveCharacterTextSplitter(chunk_size=2000, chunk_overlap=200)
chunks = sizer.split_documents(sections)

The sizes in that snippet are placeholders, not a recommendation. Which brings us to the level where the trap lives.

Level 2: model constraints and the silent truncation trap

Two limits force you to chunk at all, and the exam likes candidates who think they’re the same limit.

The first is the LLM’s context window: how many tokens the model can read in one call. It’s the reason you retrieve a few passages instead of whole documents. The second is quieter: the embedding model’s own input limit. Every chunk has to be embedded before it can be indexed, and the embedding model has a much smaller window than the LLM that reads the answer.

On Databricks this is very concrete. The supported models page lists databricks-gte-large-en with an embedding window of 8,192 tokens and databricks-bge-large-en with a window of just 512 tokens. Both produce 1024-dimension vectors. Same output size, wildly different input limits.

Here’s the trap. If a chunk is longer than the embedding window, the part past the limit doesn’t make it into the vector. It’s cut off before embedding, and depending on how your pipeline is set up, nothing fails loudly. The chunk sits in your table looking complete, the index syncs fine, and the tail of every long chunk is unsearchable. Pair 2,000-token chunks with a 512-token embedding model and roughly three quarters of each chunk never influences retrieval.

So the rule I keep in my head is: the context window is why you cut; the embedding window is how large you may cut. Size chunks only for the LLM and you can lose text at the index without a single error message.

The record count arithmetic (and the other trap at this level)

The second model-and-index constraint is capacity. A Vector Search endpoint holds a limited number of vectors (I covered endpoint sizing in my post on Databricks Vector Search), and your chunking decides how many vectors you produce.

The math is simple. The number of chunks is roughly your corpus length divided by (chunk size minus overlap). Take a 10 million token corpus:

  • 1,000-token chunks, no overlap: about 10,000 chunks.
  • 1,000-token chunks, 200 tokens of overlap: about 12,500 chunks.
  • 500-token chunks, no overlap: about 20,000 chunks.

Bigger chunks mean fewer records. More overlap means more records. Overlap isn’t waste, though: it’s insurance that a sentence sitting on a boundary survives whole in at least one chunk. Just don’t overdo it, or your retriever starts returning near-duplicates of the same passage.

Trap: record count vs record size

When a scenario says the index is over capacity, one option will be to switch to a smaller embedding model with fewer dimensions. It sounds technical and smart. It’s wrong for this problem. Fewer dimensions make each vector lighter, which helps memory and cost, but you still have exactly the same number of vectors. Only two dials change the count: larger chunks and less overlap. Change the cut, not the model.

Level 3: retrieve small, serve big

This is the level that separates a RAG app that finds text from one that answers questions. Most people assume the chunk you retrieve and the chunk you give the model must be the same piece of text. They don’t have to be.

Small chunks match precisely but often arrive without enough context to be useful. A sentence like “set the timeout to 30 seconds” can be the perfect match and still useless, because the sentence that says which service it applies to sits right above it. Big chunks carry context but blur the match. With one chunk doing both jobs, every size is a compromise.

The advanced strategies remove the compromise:

  • Parent-document (small-to-big) retrieval: index small child chunks for matching, keep the larger parent passages they came from, and return the parent when a child matches.
  • Sentence-window retrieval: index single sentences, and when one matches, widen it to the sentences around it before passing it to the model.
  • Metadata-enriched chunks: store heading, section, date and source with each chunk. The model gets context, and the retriever gets filters (for example, only the latest version of a policy).
  • Contextual chunks: prepend a short generated line that situates the chunk in its document before embedding it, so a bare instruction embeds near the topic it actually belongs to. It costs a generation call per chunk, so save it for corpora that need it.

Trap: “increase the chunk size” to fix missing context

When a scenario says retrieval finds the right text but answers come out incomplete, the tempting answer is bigger chunks. It does give the model more context, and in the same move it makes the match fuzzier. You’ve just slid along the one dial you were stuck on. The answer that fixes the complaint without paying in precision keeps two units: retrieve small, serve big.

By the way, this is exactly the kind of judgment I train in my free Databricks Generative AI Engineer Associate course: not memorizing splitter names, but learning to spot which level a question is really testing.

How to choose a chunking strategy for RAG on Databricks: measure it

The first two levels you can settle by reading and arithmetic. The third you can’t, because the best granularity depends on how your real questions land on your real passages through your specific embedding model. Nobody can reason their way to that. You measure it.

The loop looks like this:

  • Start from the cut that structure and the embedding window already suggest.
  • Create a few candidate variants around it: different size, overlap or strategy, changing one variable at a time.
  • Build an index for each candidate and run the same retrieval evaluation set against all of them.
  • Compare retrieval metrics such as recall at k, and ship the variant that scores best.

There’s no button that sweeps chunking configurations for you. It’s a loop you run, one index per candidate, all scored on the same evaluation set so the comparison is fair. Log each variant’s numbers next to its configuration, so the decision is something you can defend and rerun later.

Trap: design vs evaluate

When the scenario says “based on evaluation”, an answer that reasons from document structure and token limits without running anything is wrong, even though the reasoning is sound. It’s doing the design step when the question asked for the selection step. And if the scenario has no evaluation set, the right first move is to build one.

Trap: re-chunking as a reflex

Chunking is one lever among several. When recall is poor, hybrid search or metadata filters can help more than a new chunk size, and when the right passage comes back but ranked low, re-ranking is the fix. Re-chunk when the evaluation points at the cut, not every time a number disappoints.

FAQ

What is the best chunk size for RAG on Databricks?

There isn’t one. The document’s structure sets where you can cut, the embedding model’s input window sets the maximum size, and retrieval evaluation picks the final size among the candidates that fit. Any single number offered as “the best” skips those steps.

Does Databricks truncate chunks that are longer than the embedding model’s limit?

Each embedding model has a fixed input window (8,192 tokens for databricks-gte-large-en, 512 for databricks-bge-large-en). Text beyond that window can’t be represented in the vector, so the safe habit is to size chunks under the window of the model you actually use instead of counting on an error to warn you.

How do I reduce the number of vectors in my index?

Use larger chunks, less overlap, or both. Switching to a smaller embedding model makes each vector smaller but doesn’t reduce how many there are.

When should I use parent-document retrieval?

When retrieval finds relevant text but the model lacks the surrounding context to answer well. Match on small chunks, return their larger parents, and you keep precision while feeding the model enough context.

Is semantic chunking the same as semantic search?

No. Semantic chunking decides where to split documents during data prep. Semantic search finds relevant chunks at query time. Both use embeddings, but for different jobs.

Study it the ambush way

Give chunking one focused 30 to 60 minute session. Say the three levels out loud (structure, model constraints, retrieval granularity), then for every practice scenario ask one question before you read the options: which level is this testing? Most chunking traps fall apart once you know the level. The wrong answers are usually correct ideas parked at the wrong step.

If you want the whole exam broken down this way, my guide on how to pass the Databricks Generative AI Engineer Associate exam without dumps walks through the daily routine I use, and my free Databricks Generative AI Engineer Associate course covers every topic with the traps called out before exam day finds them for you. No dumps, no leaked questions, just the material and the patterns.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *