
Summary
Key points of this document
- Where are the design challenges?
- How to define boundaries
- Details effective in implementation
Overview
RAG answer quality is not determined by the model alone. If the document chunking method and metadata passed to the search are poor, the evidence will be misaligned no matter how good the generative model is. The quality of vector search largely depends not only on model selection but also on how documents are segmented into meaningful units and what metadata is retained.
Where are the design challenges?
Simply splitting documents by a fixed number of characters can result in cutting off meaning mid-sentence or losing the relationship with headings. Even if the search results yield text similar to the query, essential prerequisites for the answer might be missing.
Smaller chunks lead to more granular searches but lack context. Larger chunks retain context but increase noise. Adjustments are necessary based on document type, query granularity, and the model's context length.
When RAG search quality is poor, it's tempting to suspect the generative model, but often the cause lies in chunk segmentation. Chunks that are too small lose context, while chunks that are too large blur the search focus.
How to define boundaries
Preserve document structure as much as possible, segmenting with awareness of headings, chapters, tables, bullet points, etc. Each chunk should have a document ID, version, heading hierarchy, permissions, creation date, and update date to allow filtering during search.
In design, instead of ignoring document structure and splitting by fixed character count, consider headings, paragraphs, tables, bullet points, and version control. Chunks should include parent headings and document types to allow context restoration after search.
Details effective in implementation
During ingestion, store original text, normalized text, chunks, and embeddings separately. When documents are updated, detect changed chunks using hashes and re-embed only the necessary parts. Ensure that deleted items or those with changed permissions are excluded from search targets.
In PostgreSQL and vector DBs, store chunktext, embedding, documentid, sectionpath, pagenumber, validfrom, accessscope, and embedding_version. During search, filter not only by vector similarity but also by document type and permissions, and re-rank if necessary.
- For tables and procedure manuals, avoid simple character-count splitting; instead, ensure that rows or procedural units are not broken.
- Save the splitter_version during chunk generation to allow comparison of the impact of re-segmentation.
- Return not only the score but also the original document position and surrounding context in search results.
Observe failure modes
In validation, we check if the expected chunks rank high for each question. When an answer is incorrect, we distinguish whether it's a generative model issue or a failure to retrieve evidence from the search.
In validation, we compare differences in segmentation size, overlap, and metadata filters using the same question set. By checking not only the correctness of the answer but also whether the expected chunks fall within top-k, we can isolate the search quality before generation.
Discarded options and trade-offs
Advanced segmentation increases implementation costs. It's realistic to start with a combination of heading units and character limits, then adjust based on evaluation results. Trying to create perfect segmentation upfront will hinder progress.
Smaller chunks may increase search precision but raise the cost of gathering context during answer generation. Larger chunks retain context but increase search noise. It is more realistic to vary the segmentation strategy by document type than to use a single setting.
Decision criteria for practical application
For RAG improvements, you should examine the search materials before changing the generative model. By designing chunks and metadata, you can consistently retrieve the evidence for answers.
In vector search, you need to design how documents are segmented before considering the model. Treating chunks and metadata as design assets makes RAG improvements reproducible.


