RAG Chunking Strategies: How to Fix Poor Retrieval After Document Ingestion

    This article explains why RAG systems often return weak answers even when the source material is solid, tracing the problem to document parsing and chunking rather than the generation model. It covers four common causes of over-fragmentation after Markdown conversion, five core chunking principles, a practical configuration baseline with separators, length limits and overlap, a pre-ingestion structure cleanup step, metadata-based context handling, and a small evaluation loop for measuring retrieval quality. Readers will learn how to restore document structure, choose chunk boundaries, and iterate with measurable metrics instead of guesswork.

    RAG Chunking Strategies: How to Fix Poor Retrieval After Document Ingestion

    1. The Symptom: Retrieval Quality Drops After Ingestion

    When building a retrieval-augmented generation (RAG) question answering system, one frequent and easily underestimated problem is this: the source material itself is fine, yet answer quality clearly degrades once the documents are ingested. Typical signs include retrieved snippets that contain only one or two sentences with no surrounding context; a user asking about the conditions under which a clause applies and receiving the clause title or half a definition; and a single passage split into several fragments that match different chunks, producing a final answer that contradicts itself.

    The root cause is usually not the generation model but the document parsing and chunking stage. Chunking determines the “smallest retrievable semantic unit” in the vector store. Once those units are cut at the wrong granularity, swapping the embedding model or raising Top-K only patches the problem at the wrong level.

    One basic point needs to be clear: chunking is not simple string splitting. It is an engineering decision that trades off semantic completeness, retrieval precision, and context cost.

    2. Root Cause Analysis: Four Reasons Chunks End Up Too Short After Markdown Conversion

    2.1 Layout conversion strips structural hierarchy

    When layout-based documents such as web pages and PDFs are converted to Markdown, converters often keep only visible text and lose heading levels, list membership, and table boundaries. The output is full of isolated short lines: a standalone bold line, bullet points broken apart, sentences truncated at line breaks. A chunker that splits by line or by punctuation treats each of these short lines as a separate paragraph.

    2.2 Separators do not match the actual document structure

    Most chunking modes recursively split on separators such as paragraph breaks, periods, and heading markers. If the document is actually organized as chapter, section, clause, but only generic punctuation is configured as separators, the split points fall out of alignment with the logical structure. Conversely, separators that are too coarse (splitting only on top-level headings) produce oversized chunks that dilute the vector semantics and lower the retrieval hit rate.

    2.3 No minimum chunk length

    Setting only a maximum length and no minimum length is a direct cause of fragmentation. Short chunks carry thin semantics once vectorized, offer little separation in similarity against a query, and easily trigger many near-duplicate matches and ranking instability.

    2.4 Structured content handled as plain text

    Tables, numbered lists, and block quotes in regulations, news, and technical documents carry strong structural semantics. Processed as a plain text stream, a table gets flattened into a meaningless long string and numbering gets separated from the body text, so at retrieval time the content can neither be matched nor correctly cited.

    3. Core Principles for Chunk Design

    1. Semantics first: split at natural semantic boundaries rather than at a fixed character count. A length limit is a constraint, not the goal.
    2. Self-contained units: each chunk should be understandable on its own, with heading paths added when context is needed.
    3. Layered granularity: long documents should use a two-level structure of coarse-grained location plus fine-grained excerpt, balancing recall and precise citation.
    4. Traceable: chunks must carry metadata such as source, section, and position so answers can be traced back.
    5. Measurable: any change to chunking parameters must be quantitatively validated rather than tuned by feel.

    4. A Practical Chunking Configuration

    4.1 General parameter baseline

    For explanatory and clause-style text, the following baseline is a reasonable starting point, to be fine-tuned based on evaluation results:

    1. Chunking mode: recursive splitting on custom separators
    2. Separator priority: \n## → \n### → \n\n → \n → 。(last level as fallback only)
    3. Maximum chunk length: 400~800 tokens
    4. Chunk overlap: 10%~15% of the maximum length
    5. Minimum chunk length: 80~120 tokens (merge with an adjacent chunk below the threshold)

    Overlap prevents information spanning a boundary from being cut off entirely; the minimum length threshold removes fragments. Both must be configured together, since tuning only one has limited effect.

    4.2 Fix the structure during parsing before working on chunking

    Chunking quality is capped by parsing quality. A structure cleanup pass is recommended before ingestion:

    • Merge isolated short lines by semantics to restore paragraphs interrupted by conversion;
    • Normalize heading levels so level markers are continuous and never skip a level;
    • Linearize tables into field-value descriptions, or keep them as standalone blocks with a heading;
    • Remove noise such as headers, footers, navigation text, and copyright notices;
    • Add a heading path to each logical block, for example Chapter 3 > 3.2 Applicability Conditions.

    Illustrative cleanup logic:

    1. def normalize(blocks):
    2. merged, buf = [], []
    3. for b in blocks:
    4. if is_heading(b) or is_table(b) or len(buf) >= MIN_LEN:
    5. if buf:
    6. merged.append(join_with_context(buf))
    7. buf = []
    8. merged.append(b)
    9. else:
    10. buf.append(b)
    11. if buf:
    12. merged.append(join_with_context(buf))
    13. return merged

    4.3 Use metadata instead of stuffing context into the body

    Writing the section, document type, publication date, and source ID into metadata and filtering on it at retrieval time costs fewer tokens than repeatedly stacking titles in the body text, and it also supports permission and scope control.

    4.4 Handle Q&A content and clause content differently

    Q&A material fits a chunk per question-answer pair, keeping each question independently retrievable. Clause material fits a chunk per clause, with the clause number preserved. Applying one parameter set to both usually produces mediocre results on both sides.

    5. Closing the Loop: Making Chunking Optimization Measurable

    Tuning chunking without evaluation is blind tuning. Build a minimal evaluation set: collect 30~50 real questions, annotate where the source text that should be retrieved lives, then track three metrics.

    1. Hit rate: whether the correct chunk appears in the retrieved results;
    2. Hit position: the rank of the correct chunk in the ordering, which reflects ranking quality;
    3. Answer consistency: whether repeated runs of the same question yield stable answers.

    The recommended tuning order is: fix parsing structure first, then set separators and lengths, and only then adjust the retrieval count and similarity threshold. If the retrieved chunks do not contain the answer at all, raising the similarity threshold only makes the system give up on retrieval sooner, which is a step in the wrong direction.

    6. Common Pitfalls

    • Chasing smaller chunks: the shorter the chunk, the less complete its vector semantics, and the higher the share of noisy matches.
    • Only increasing the retrieval count: a larger Top-K pulls in more weakly related content that interferes with generation, so it needs to be paired with reranking.
    • Ignoring update and rebuild cost: a change to the chunking strategy usually means rebuilding the index in full, so validate on a small sample before running the full rebuild.
    • Treating chunking as a one-time configuration: when document formats change (new tables, a layout revision), the chunking needs to be revalidated.

    7. Summary

    Chunking is the highest return-on-effort optimization point in a RAG system. Faced with unreliable paragraph recognition after Markdown conversion, the right path is to restore the document structure first, then split with a combination of separators, minimum and maximum length, and overlap, using metadata and layered granularity to preserve semantic completeness, and finally drive iteration with a small evaluation set. If you use a cloud-hosted setup, you can rely on object storage to keep the original documents, a container platform to run parsing and rebuild jobs, and logging and monitoring services to track changes in retrieval quality, turning chunking optimization from a matter of experience into a sustainable engineering process.