RAG Chunking Strategies: A Practical Guide to Fixing Fragmented Knowledge Base Content
This article explains why RAG knowledge bases often end up with fragmented, semantically incomplete chunks, and how to fix it. It covers pre-ingestion document cleanup, four common chunking modes and when to use each, key parameters such as chunk size, overlap, and context enrichment, plus embedding and reranking practices. It also outlines a repeatable evaluation loop and common mistakes to avoid. The core takeaway: most retrieval problems trace back to document structure governance and chunk boundaries, not parameter tuning alone.
1. Problem: Why Your Knowledge Base Chunks Fall Apart
When building a Retrieval-Augmented Generation (RAG) system, a common issue appears: you upload well-structured documents, but after ingestion they are split into many short fragments with incomplete meaning. Typical symptoms include table-of-contents entries each becoming a separate chunk, numbered headings separated from their body text, and a single sentence cut into two records. The root cause is usually not a weak splitting capability, but missing or misplaced structural signals in the source document, which forces the splitter to fall back to mechanical delimiter-based cutting.
The common causes fall into three groups:
- Format conversion loss: When converting from web pages or rich text to markup text, structural information such as heading levels, list indentation, and paragraph blank lines is lost, leaving only a continuous stream of text.
- Delimiters that do not match semantic boundaries: Splitters prioritize symbols like line breaks, blank lines, and heading markers. When these symbols are misused, the cut points land in the middle of a semantic unit.
- Unreasonable parameter configuration: A chunk size limit that is too small or an overlap ratio that is too low fragments the context and leaves pieces isolated from each other.
2. Document Governance Before Ingestion: Restore the Structure
Chunk quality is capped by data quality. It is recommended to run a normalization pass before uploading:
- Unify heading markers: Make sure level-1, level-2, and level-3 headings use consistent marker syntax, and keep a blank line between a heading and its body text so the splitter can reliably detect hierarchy boundaries.
- Remove noise content: Strip table-of-contents pages, headers and footers, navigation leftovers, and repeated copyright notices. TOC entries are one of the main sources of over-fragmentation and should be removed before ingestion.
- Merge broken paragraphs: Rejoin sentences that were split by hard line breaks. A workable rule is: if the previous line does not end with sentence-ending punctuation, merge it with the next line.
- Preserve table and code block integrity: Add explicit boundary markers around tables and code blocks so they are not cut like ordinary text.
Illustrative preprocessing logic (pseudocode):
def normalize(md_text):md_text = drop_toc_and_boilerplate(md_text) # Remove TOC, headers, and footersmd_text = merge_broken_lines(md_text) # Rejoin sentences cut by hard line breaksmd_text = normalize_heading_levels(md_text) # Unify heading levelsmd_text = protect_code_and_tables(md_text) # Protect code blocks and tablesreturn md_text
3. Choosing a Chunking Mode: Split by Semantic Hierarchy, Not Character Count
The chunking modes commonly used in the industry can be abstracted into four types, each with its own fit:
| Mode | Splitting basis | Suitable material | Main risk |
|---|---|---|---|
| Fixed-length chunking | Fixed character/token count | Plain text with very weak structure | Semantics hard-truncated |
| Delimiter chunking | Line breaks, blank lines, heading markers | Well-structured, standardized documents | Misused delimiters cause fragments |
| Hierarchical recursive chunking | Split by top-level headings first, then subsections, then paragraphs, level by level | Regulations, manuals, tutorials | Degrades when hierarchy is missing |
| Q&A pair chunking | One question-answer pair per chunk | FAQs, training question banks | Poor recall when question references are missing |
For material with clear hierarchy such as regulations, news, and technical manuals, prefer hierarchical recursive chunking: first split into large blocks by level-1 headings; if a block is still too long, split it further by level-2 headings; only split by paragraphs if it is still too long. This preserves the “TOC - chapter - body” attribution relationship.
4. Key Parameters: Length, Overlap, and Index Enrichment
- Chunk length: Use “covering one complete knowledge point” as the criterion. A few hundred tokens is usually a safe range; too short loses context, while too long dilutes the vector semantics and lowers retrieval precision.
- Overlap window: Keep a certain proportion of overlap between adjacent chunks (commonly 10-20% of the chunk length). This mitigates information being cut at boundaries, but excessive overlap causes index redundancy and duplicate recall.
- Pre-chunk enrichment: Prepend the chapter heading path (for example, “Chapter 4 > 4.2 Chunking Strategies”) to each chunk, which significantly improves the distinguishability of vector matching.
- Post-chunk enrichment: Add summaries or keyword metadata to chunks, and combine with metadata filtering (by document source, chapter, time) to narrow the retrieval scope.
5. Embedding and Reranking: Getting the Right Content to the Top
Chunking decides “what gets recalled”; vectorization decides “how it matches”. Choose a general-purpose embedding model oriented to Chinese semantics, map chunks to vectors, and write them into a vector index. At retrieval time, first do a coarse recall of several candidates, then use a reranking model to score the candidates for fine-grained relevance, and pass the top results to the generation model. Engineering recommendations:
- Tune the recall count and similarity threshold jointly: a threshold that is too high misses recall, while one that is too low introduces noise.
- Lower the threshold appropriately for short chunks and raise it appropriately for long chunks.
- Build an evaluation set from a set of real questions, and iterate using “whether the answer is covered by Top-K” as the core metric.
6. Validation and Iteration Loop
Establish a repeatable validation process: prepare 20-50 questions with reference answers, covering three categories: single-point facts, cross-chunk synthesis, and negation and boundary cases. After each adjustment to the chunking strategy or parameters, rerun the evaluation and record hit rate and answer accuracy. If a certain category of questions keeps failing, go back and check the source document structure first rather than repeatedly tuning parameters - the vast majority of recall problems ultimately point to data governance and chunk boundaries.
7. Summary of Common Mistakes
- Treating chunking as a pure parameter problem while ignoring document structure governance.
- Failing to clean up TOCs, headers, and footers, resulting in many meaningless short chunks.
- Relying only on fixed-length chunking for strongly hierarchical material.
- Having no overlap and no heading-path enrichment, so cross-chunk information is permanently lost.
- Lacking an evaluation set, so optimization relies entirely on subjective impressions.
Proceed in the order of “governance - mode selection - parameter tuning - enrichment - evaluation”, and knowledge base chunking can move from “usable” to “reliable”, laying a solid foundation for the quality of the Q&A layer above it.
