| Chunk | A passage of text stored and retrieved as one unit. |
| Overlap | Repeated text between chunks to avoid cutting a thought in half. |
| Metadata filter | A constraint such as product, language or date applied at query time. |
- Documents have headings, tables or mixed formats.
- Users filter by date, product, region or permission.
- Citations must point back to an exact location.
- 01Parse structure first: headings, tables, lists.
- 02Split on semantic boundaries rather than fixed character counts.
- 03Attach title, path, version, date and access scope to every chunk.
- 04Store a stable chunk ID and test retrieval on real queries.
Product manual with tables and versions
- Context
- A billing manual contains tables, headings and several revisions.
- Problem
- Plain-text splitting turns tables into gibberish and loses the section context.
- Approach
- Parse structure first, keep tables intact and store title, path and version with each chunk.
- Outcome
- Retrieved passages remain readable and cite the exact section and version.
Multi-tenant knowledge base
- Context
- Several customer tenants share one document index.
- Problem
- A search for one tenant can surface another tenant's policies.
- Approach
- Attach tenant and access scope to every chunk and filter at query time.
- Outcome
- No cross-tenant leakage and simpler permission audits.
Chunk a product manual
{
"id": "manual-v4-billing-02",
"title": "Lease billing guide",
"section_path": "Billing > Refunds",
"version": "v4",
"effective_from": "2026-10-01",
"access_scope": ["support", "billing"],
"text": "Billing > Refunds: A security deposit is returned within 14 days..."
}Put the section heading inside the chunk text and give each chunk a stable, versioned ID for citations.
Filter at query time
SELECT id, content FROM chunks
WHERE tenant_id = :tenant
AND product = :product
AND access_scope && :caller_scopes
ORDER BY embedding <=> :query_vector LIMIT 8;Never mix access levels in one chunk; permissions must be enforceable with a filter at retrieval time.
Fixed-size chunks
Up: Simple and predictable
Down: Breaks sentences and tables
Semantic chunks
Up: Better coherence
Down: Needs more parsing logic
Heavy metadata
Up: Precise filtering
Down: More storage and index complexity
| Option | Upside | Cost |
|---|---|---|
| Fixed-size chunks | Simple and predictable | Breaks sentences and tables |
| Semantic chunks | Better coherence | Needs more parsing logic |
| Heavy metadata | Precise filtering | More storage and index complexity |
- Keep tables intact where possible.
- Include the section heading in each chunk's text.
- Never mix access levels in one chunk.
- Version chunk IDs when source content changes.
| Key | Typical value | Note |
|---|---|---|
| chunk_overlap | 10–15% | Enough to preserve context. |
| min_chunk_size | 100 tokens | Avoid tiny, useless passages. |
| metadata_fields | explicit schema | Validate on ingest. |
| Symptom | Cause | Fix |
|---|---|---|
| Tables retrieved as gibberish | Plain-text parsing | Use a structure-aware parser. |
| Cross-tenant results | Missing access metadata | Apply permission filters at query time. |
What chunk size is best?
It depends on document structure. Start around 300–800 tokens and measure retrieval recall on real queries.
Should chunks overlap?
A small overlap helps, but excessive overlap duplicates content and skews ranking.
More in RAG & knowledge
RAG pipeline end to end
The six stages of retrieval-augmented generation and where each one most often fails.
Hybrid search and reranking
Combine lexical and semantic retrieval, then use a reranker to improve precision before generation.
RAG evaluation: retrieval and answer quality
Separate the two halves of RAG quality so you know whether to fix retrieval or generation.