SHEN YIFull-Stack & AI

Paris • Singapore • Shanghai

RAG Formation · Reference

Chunking and document structure

A standalone cheat sheet for learning and testing RAG quality on this site.

$ reference --status
▸ course RAG Formation
▸ mode standalone reference
▸ status Complete
● learn → test → verify

Reference sheet

Chunking and document structure

The guided RAG Formation course content is complete; this reference is available for self-directed practice.

One-line rule

Change one window setting, measure whether the fact and source identity stay together, then test the hypothesis with a separate live retrieval evaluation.

Glossary

TermMeaning
Source windowA repeatable, bounded slice of synthetic Markdown used in the offline lab.
Chunk sizeThe maximum number of characters allowed in one source window.
Chunk-size profileNot one universal setting — Qdrant/Meilisearch index at ~500 tokens, LightRAG deliberately uses ~1200 for better entity extraction. --profile chunk/graph approximate the two in characters.
OverlapCharacters copied from the end of one window into the next.
Co-locationThe expected reference and every required fact term appear in the same window.
Proxy metricA directional signal—not a live retrieval or answer-quality result. The graph profile's rate looks better almost by construction, since a big enough window trivially fits the whole document.

Controlled experiment card

StepDoDon't claim
BaselineRun q24 with --profile chunk (~500 tokens, the Qdrant/Meilisearch size).That this is the best production setting.
One changeKeep everything else and rerun q24 with --profile graph (~1200 tokens, LightRAG's size).That several changes caused the result.
MeasureCompare the co-location count/rate and the readable window text.That the live index has improved, or that the bigger window is simply better.
VerifyReindex the isolated demo, then run the retrieval evaluation again.That a source-window proxy can replace evaluation.

Question map

QuestionWhy it is usefulSource(s)
q24Checks whether a revised deadline stays linked to the current procedure identity.PR-QA-MRD-009
q30Shows that one window may still not contain enough for an answer that needs two sources.PR-QA-MRD-001 + PR-QA-MRD-009
q52Checks a short factual answer against the continuity-plan identity.PR-EXM-MRD-014

Commands and conclusion frame

cd demo
python3 chunk_lab.py --question q24 --profile chunk --output-dir reports/lesson-06-chunk-profile
python3 chunk_lab.py --question q24 --profile graph --output-dir reports/lesson-06-graph-profile

Conclusion frame: “With the ___ profile (___ characters, ___ overlap), ___ of ___ windows kept the required fact and source identity together. This supports the hypothesis that ___. It does not prove live retrieval quality, and it does not mean the bigger window is simply better; next, I would weigh that against LightRAG's real extraction cost and reindex-plus-retrieval check.”

Local pointers

  • demo/chunk_lab.py
  • demo/eval_set.yaml
  • demo/corpus/md/

Continue learning: Open the matching standalone lesson · Course roadmap