A reliable RAG application depends on more than choosing a vector database. This guide gives you a reusable checklist for splitting documents, attaching useful metadata, indexing content, and evaluating whether retrieval supplies the right evidence to an LLM.
Overview
Retrieval-augmented generation (RAG) combines search with language generation. A typical pipeline extracts source documents, divides them into chunks, creates embeddings, stores those embeddings with metadata, retrieves relevant chunks for a user question, and passes the selected context to a language model.
Chunking is the first major quality decision. Chunks that are too large may contain several unrelated subjects and consume unnecessary context. Chunks that are too small may lose definitions, conditions, or references needed to interpret an answer. There is no universally correct chunk size: the right choice depends on document structure, question types, embedding behavior, context limits, and the amount of evidence your application needs to return.
Evaluation should therefore measure retrieval separately from generation. An answer can be wrong because the retriever missed the relevant passage, because irrelevant passages crowded it out, or because the model misread adequate evidence. Testing these stages independently makes debugging more practical. For broader LLM prompt and response testing, see the LLM Prompt Testing evaluation framework.
Core indexing workflow
- Define the retrieval unit. Decide whether users need paragraphs, procedures, product sections, policy clauses, code blocks, or another meaningful unit.
- Ingest and normalize documents. Preserve headings, lists, tables, page references, URLs, and document identifiers where possible. Remove repeated headers, navigation text, and extraction artifacts.
- Choose a chunking strategy. Start with a method that respects the source structure, then create measurable alternatives for comparison.
- Attach metadata. Store fields that support filtering, citations, access control, debugging, and later reprocessing.
- Generate embeddings. Record the embedding model and configuration alongside the indexed collection so results remain reproducible.
- Store and index vectors. Confirm the vector dimension, distance metric, payload schema, and any limits imposed by the selected vector store.
- Retrieve candidates. Test top-k values, filters, hybrid search if applicable, and reranking independently.
- Evaluate with known questions. Compare retrieved chunks with expected evidence before judging the final generated answer.
Checklist by scenario
Fixed-size chunking
Fixed-size chunking divides text by a target number of tokens or characters, usually with overlap. It is easy to implement and provides a useful baseline for a first RAG prototype.
| Strengths | Risks | Use when |
|---|---|---|
| Simple, predictable, and fast | May split sentences, tables, or procedures | You need a baseline or documents have limited structure |
| Easy to compare across experiments | Overlap can duplicate content and increase index size | You are measuring the effect of chunk length systematically |
Use overlap only when it helps preserve continuity. Treat chunk length and overlap as experiment variables rather than permanent defaults.
Recursive chunking
Recursive chunking attempts larger separators first, such as headings or paragraphs, and falls back to smaller separators when a section exceeds the target. It is a practical general-purpose option for mixed prose.
| Strengths | Risks | Use when |
|---|---|---|
| Usually preserves natural text boundaries | Results vary with document formatting | Your corpus contains reasonably clean paragraphs and headings |
| Balances structure and size limits | Inconsistent source markup can reduce quality | You need a sensible default for varied business documents |
Sentence-based chunking
Sentence chunking groups complete sentences until a target size is reached. It reduces mid-sentence cuts and can work well for FAQs, support content, and explanatory prose.
| Strengths | Risks | Use when |
|---|---|---|
| Readable chunks with intact sentences | Sentence detection can struggle with abbreviations, code, or lists | Documents are primarily well-formed prose |
| Useful for citation-friendly answers | A single sentence may not contain enough context | Questions often target concise factual passages |
Semantic chunking
Semantic chunking groups text according to shifts in meaning rather than only length or punctuation. It can preserve topical boundaries, but its behavior depends on the segmentation method and thresholds.
| Strengths | Risks | Use when |
|---|---|---|
| Can align chunks with topic changes | More computation and more tuning variables | Long-form content has clear but irregular topic transitions |
| May reduce unrelated material in a result | Harder to debug than fixed rules | You have enough evaluation data to compare segmentation quality |
Parent-child chunking
Parent-child chunking stores smaller child chunks for precise retrieval while retaining a larger parent section for generation. The child helps match a query; the parent supplies surrounding context.
| Strengths | Risks | Use when |
|---|---|---|
| Combines precise matching with broader context | Requires relationships between records | Small passages need surrounding definitions or instructions |
| Supports richer citations and answer context | Returning full parents may increase prompt size | Documents contain nested sections or multi-step procedures |
Metadata field template
A consistent metadata schema makes filtering and diagnosis easier. Adapt the fields to your application rather than adding fields that will never be queried.
document_id: stable identifier for the source document.source_uri: canonical URL, file path, or repository reference.title: document or page title.section_path: headings leading to the chunk, such asGuide > Installation > Configuration.chunk_id: stable identifier for the chunk version.parent_id: related parent section when using parent-child retrieval.document_type: handbook, ticket, API reference, policy, or another controlled value.language: detected or declared language.versionandupdated_at: source revision information.access_scope: permission or tenant boundary used for filtering.content_hash: value for detecting unchanged content during re-indexing.
What to double-check
Retrieval evaluation worksheet
Create a test set of representative questions before tuning the pipeline. Each record should include the question, expected document or passage, permitted answer evidence, and any required metadata filter.
| Measure | Question to ask | How to record it |
|---|---|---|
| Recall | Did retrieval include the expected evidence in the top-k results? | Mark success when at least one relevant passage appears; also record the rank of the first relevant result. |
| Precision | How many returned results are relevant? | Label each retrieved chunk as relevant, partly relevant, or irrelevant, then calculate the relevant share for the selected k. |
| Context relevance | Does the selected context directly support the question? | Review the assembled context for duplication, topic drift, missing qualifiers, and unnecessary text. |
| Answer faithfulness | Does the generated answer stay supported by the retrieved evidence? | Compare claims in the answer with source passages and mark unsupported, contradicted, or properly supported claims. |
Keep retrieval and generation labels separate. If recall is poor, revise ingestion, chunking, metadata filters, query handling, or search settings. If recall is adequate but faithfulness is poor, inspect context assembly and the generation prompt. The LLM hallucination troubleshooting guide can help organize that second investigation.
Index and model checks
- Confirm every vector in a collection was created with the intended embedding model and version.
- Verify that the stored vector dimension matches the model output and collection configuration.
- Check the distance or similarity metric used by the index and keep it consistent with your embedding setup.
- Test metadata filters separately from semantic search so an overly restrictive filter is not mistaken for poor embeddings.
- Measure the final context size after deduplication, parent expansion, and reranking.
- Record chunking parameters, extraction code version, embedding configuration, and index creation date for each corpus build.
Common mistakes
- Choosing chunk size by convention. A common starting value is not evidence that it fits your documents. Compare alternatives against representative questions.
- Discarding document structure. Removing headings, table labels, or page references makes both retrieval and citations harder.
- Embedding noisy extraction output. Repeated navigation, broken columns, and duplicated headers can attract queries away from the useful passage.
- Returning too many chunks. More context can introduce contradictions and reduce the prominence of the relevant evidence.
- Evaluating only final answers. A fluent answer does not prove that retrieval was correct. Inspect retrieved chunks and evidence coverage.
- Ignoring access boundaries. Metadata filters for tenant, role, or document permissions should be applied as part of retrieval, not as an afterthought.
- Re-indexing without traceability. If old and new chunks cannot be distinguished, regressions become difficult to reproduce.
- Changing embeddings without a comparison run. A new model or dimension may require a new collection and a side-by-side evaluation before migration.
When to revisit
Revisit this checklist whenever the corpus, question mix, or retrieval stack changes. At minimum, review it before a major planning or release cycle and after any workflow change that affects extraction, chunking, metadata, embeddings, search, or answer generation.
Run a focused evaluation when you add a new document type, update source formatting, change chunk sizes, switch embedding models, alter vector-store settings, introduce reranking, or observe a drop in answer quality. Keep a small regression set that represents common questions, difficult questions, permission-filtered questions, and questions whose answers span multiple sections.
A practical maintenance loop is:
- Choose a documented corpus snapshot and evaluation set.
- Record the current indexing and retrieval configuration.
- Change one major variable at a time where possible.
- Compare recall, precision, context relevance, and answer faithfulness.
- Inspect failures manually and classify their cause.
- Promote the change only when it improves the target use cases without creating unacceptable regressions.
- Save the winning configuration and schedule the next review.
For production readiness beyond retrieval quality, pair this process with the LLM app production deployment checklist. Treat chunking and retrieval as versioned parts of the application, not one-time setup decisions.