Basics of NLP and RAG · Lesson 2
Building Blocks of RAG
A RAG system has two phases. Indexing: load documents, clean them, split them into chunks, embed each chunk and store vectors with metadata. Querying: embed the question, retrieve the top-k similar chunks, build a prompt with them, and generate the answer.
Chunking matters a lot. Chunks that are too small lose context; too large dilute relevance. Common starting points are 300–800 tokens with 10–20% overlap, ideally split on headings or paragraphs.
Store metadata (source, page, date, section) with each chunk so you can filter results and show citations.
Key points
- Indexing: load → chunk → embed → store
- Querying: embed question → retrieve → augment → generate
- Chunk size and overlap strongly affect quality
- Keep metadata for filters and citations