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?
Changing the size only moves the trade-off between precision and context. Semantic metadata such as document summaries and section headers, along with clean parsing and extracted metadata, usually improves retrieval more than tuning the size.
“More impactful optimizations: Instead of over-optimizing chunk size, focus on:”Source: docs.databricks.com
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.
| Strategy | Boundary signal | Wins when |
|---|---|---|
| Fixed-size (CharacterTextSplitter) | A set number of characters or tokens | Quick prototyping; rarely good enough for production |
| Paragraph-based (RecursiveCharacterTextSplitter) | Natural paragraph breaks | Prose with paragraphs but no reliable headers |
| Format-specific (MarkdownHeaderTextSplitter, HTML header/section splitters) | Markdown headers or HTML sections | Documents with consistent header structure |
| Semantic (SemanticChunker) | Topic shifts found from the content itself | Text 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.
Pick the splitter that uses the strongest structure the documents actually have. Headers come first, then paragraphs. Topic-shift detection is for text with neither. Fixed-size cuts ignore meaning, so they are only suitable for prototypes.
“Formats such as Markdown or HTML have an inherent structure that can define chunk boundaries (for example, markdown headers).”Source: docs.databricks.com
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?
Correct answer: C — Split files at H1, H2 and H3 headings, carrying the parent heading path into each chunk as added context.
- A. Overlap softens a cut but does not decide where it falls. Fixed-size windows still start and end at arbitrary characters, so one chunk can mix the tail of an installation section with the start of a configuration section. The chunk boundaries ignore the headings that already mark where topics change.
- B. Similarity-based breakpoints are inferred from embeddings and can land mid-section or merge neighbouring sections. They are also costlier to compute. The pages already carry consistent H1/H2/H3 headings, which mark topic changes exactly, so inferring boundaries gives less precise chunks and gains nothing.
- C. Cutting at each H1, H2 and H3 heading gives one chunk per topic, matching how the pages are already organised. Attaching the parent heading path means a chunk from a troubleshooting subsection still carries its page and section names, which helps retrieval and keeps topical boundaries intact.
- D. H1 headings mark only the page level. Installation, configuration and troubleshooting sit at H2 and H3, so cutting at H1 alone puts several topics in one chunk. Adding the page title does not separate them, so the topical boundaries the pages already encode are lost.
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?
With no headers or paragraphs, the boundaries have to come from the content. Semantic chunking embeds consecutive sentences and cuts where similarity drops sharply, because a sharp drop marks a change of topic. Overlap still cuts every N tokens wherever that lands, and paragraph splitting has no markers to cut on.
“These approaches analyze the content or structure of each document to determine the most appropriate chunk boundaries based on topic shifts.”Source: docs.databricks.com
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?
Correct answer: C — Split each article where embedding similarity between neighboring sentences drops sharply, keeping sentences whole.
- A. Overlapping windows repeat some text around each cut, but the cuts still fall at fixed token counts. They ignore where one subtopic ends and the next begins. A window can still straddle two unrelated FAQ answers, so the overlap does nothing about the missing topic boundaries.
- B. A recursive splitter works only when the text contains paragraph or line separators that match topic changes. These articles have no paragraph markers, so the splitter falls through to spaces. It then cuts at arbitrary positions once the size limit is reached, and it can join or break unrelated subtopics.
- C. Semantic chunking compares embeddings of adjacent sentences and cuts where similarity falls sharply. That marks a change of subject. It needs no headers or paragraph markers, so it fits articles that run several unrelated subtopics together. It also keeps each sentence in one piece.
- D. Splitting on heading tags needs headings in the markup. These articles have no headers, so there are few or no tags to split on. Each article would stay a single large section, or a few sections that still mix subtopics. Merging short sections only joins more unrelated material.
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?
With overlap, text near a boundary appears in both adjacent chunks, so one chunk can hold the whole fact. Smaller chunks add more boundaries and remove context. Retrieving more chunks still returns the halves as separate pieces and uses up context window. A fixed-character splitter makes the boundaries uniform but less meaningful.
“To ensure that important information is not lost when splitting the data into chunks, consider including some overlap between adjacent chunks.”Source: docs.databricks.com
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?
Correct answer: B — Set a chunk overlap of a few sentences, so the next chunk starts with the closing text of the previous one
- A. Top-k is a retrieval setting, not a chunking setting. A larger value may bring in the neighbouring chunk, but only if it ranks high enough. It adds noise and prompt cost, and the stored chunks still cut the fact in two.
- B. Chunk overlap repeats the last sentences of one chunk at the start of the next. A fact that straddles the join then appears whole in at least one chunk, which directly fixes the incomplete answers at chunk edges.
- C. A fixed-character splitter gives uniform lengths but adds no continuity between chunks. It cuts at arbitrary character counts, often mid-sentence, so facts are still divided between chunks, just at different points.
- D. Smaller chunks mean more joins in the document. Each join is another place where a fact can be cut in two, so the problem becomes more likely rather than less.
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.
# 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"]
)The same parent text four times. Each child row carries its own copy of the parent, so you should deduplicate the parents before building the prompt, or those repeats take up context-window space that other parents could have used.
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", ? ]
)Only the children in text are embedded and searched. Each child row also stores its full parent in parent_text, so asking for that column returns the parent with every child match, and the application passes it to the LLM without a second lookup.
Sources2
Sources
(2)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.https://docs.databricks.com/aws/en/agents/tutorials/ai-cookbook/quality-data-pipeline-ragOfficial docs
“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.
“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