Retrieval-Augmented Generation — The part most people do badly
Everyone can build a RAG demo in an afternoon. Almost nobody can tell you why theirs returns the wrong chunk. The difference between those two people is this track — and the eval set at the end of it.
Track 2 of the AI engineering roadmap by K Laxman — about 10 hours across 3 stages.
RAG properly — all fifteen techniques
You can name, and choose between, the retrieval strategies. Not just 'embed, store, search'.
indexing · retrieval · generation · multi-query · RAG-Fusion · query decomposition · step-back prompting · HyDE · routing · query construction · multi-representation indexing · RAPTOR · ColBERT · CRAG · adaptive RAG
In short:
- Three stages, three failure points. Indexing (split and embed), retrieval (find the right chunks) and generation (answer from them). A wrong answer came from exactly one of them.
- Most techniques fix the query or the index. Multi-query, HyDE, step-back and decomposition rewrite the question; multi-representation indexing and RAPTOR change what gets stored. Each fixes a specific miss.
- Corrective and adaptive RAG add judgement. Grade the retrieved chunks before answering, and re-retrieve or fall back when they are weak, instead of generating from whatever came back.
- Learn RAG From Scratch — LangChain / freeCodeCamp (video, free, ~2.2h, rated 10/10). The reason this beats every 'build a RAG bot in 10 minutes' video is the list of concepts on the left. It goes well past embed-and-retrieve into routing, decomposition, HyDE, RAPTOR and CRAG — the techniques you reach for when the naive version is returning garbage.
- langchain-ai/rag-from-scratch — LangChain (repo, free, ~4h, rated 9/10). Run every notebook. Watching RAG is not learning RAG — the chunking decisions only become real when your own document set makes them go wrong.
Build this — RAG over your own notes — plus a 30-question eval set. The bot is the easy half. The assignment is the eval set: thirty real questions with known answers, and a score you can quote. Without it you have a demo, and you will not be able to tell whether tomorrow's change helped.
You're done when: Given a wrong answer, you can separate retrieval failure from generation failure in under a minute.
Common traps:
- Stacking techniques before measuring. Every one adds latency and cost; add one only when a measured failure calls for it.
- Blaming the model when the right chunk was never retrieved. Look at what was retrieved first.
Check yourself:
- An answer is wrong. What is the one-minute test that tells you where? Answer: Look at the retrieved chunks. If the answer isn't in them, it's a retrieval failure. If it is and the model still got it wrong, it's a generation failure.
- When does HyDE help? Answer: When questions are short and phrased very differently from the documents. Embedding a hypothetical answer lands closer to real answers than the bare question does.
Put to work in: CAMS Lens — SEBI-grounded compliance intelligence · Agentic Research & Decision Intelligence Assistant
Chunking — the decision that quietly decides everything
You can explain why your chunk size is what it is, instead of because a tutorial said 512.
fixed vs semantic splitting · overlap · chunk size vs recall · metadata on the chunk · contextual retrieval
Interactive explainer on the live page: context budget — You can explain why your chunk size is what it is, instead of because a tutorial said 512.
In short:
- The chunk is the unit of retrieval. You can only retrieve what you stored. If the answer is split across two chunks, or buried in a huge one, retrieval can't deliver it cleanly.
- Size is a trade-off. Small chunks match precisely but lose context; large chunks keep context but dilute the embedding. Overlap reduces boundary losses at the cost of duplication.
- Give each chunk its context. Prepending the document title, section heading or a short generated summary (contextual retrieval) makes a chunk findable on its own.
- Introducing Contextual Retrieval — Anthropic (article, free, ~0.75h, rated 9/10). The single change with the best effort-to-payoff ratio in RAG: prepend a sentence of document context to each chunk before embedding it. Measured, with the failure rate reported rather than a vibe. Read this the day your naive retrieval starts missing.
- Chunking Strategies for LLM Applications — Pinecone (article, free, ~0.5h, rated 7/10). Vendor content, and worth it anyway — it is the clearest side-by-side of the splitting strategies. Take the taxonomy, ignore the product.
Build this — Same questions, four chunkings. Take the eval set from the stage above and run it against four indexes: 256 fixed, 512 fixed, 512 with overlap, and semantic. One table, four scores. You will never again accept a chunk size on faith, and you now own a number you can quote in an interview.
You're done when: You can name the chunk size you use, the one you tried before it, and the score difference between them.
Common traps:
- Choosing a chunk size once and never testing it. It is a parameter to measure on your own eval set.
- Splitting through tables and code blocks. Split on the document's own structure — headings, paragraphs, rows — before falling back to character counts.
Check yourself:
- Your chunks say "the policy above applies" and retrieval returns them useless. What is the fix? Answer: Add context to each chunk — document and section titles, or a generated one-line summary — so it stands on its own when retrieved.
- How do you choose between 300-token and 1,000-token chunks? Answer: Index both and run the same questions against each. Compare recall@k and answer quality; pick with numbers, not intuition.
Put to work in: CAMS Lens — SEBI-grounded compliance intelligence
When retrieval is the bug
You can tell a retrieval problem from a generation problem before you touch the prompt.
hybrid search · reranking · recall@k · query rewriting · the missing-document case
In short:
- Measure recall@k first. For a set of questions with known source documents, how often is the right one in the top k results? Until you know that, prompt tweaks are guesses.
- Hybrid search covers both kinds of miss. Keyword search (BM25) catches exact terms and identifiers; vectors catch paraphrase. Combining them fixes misses either one makes alone.
- Rerank a wide net. Retrieve 50 cheaply, then let a cross-encoder reranker pick the best 5. The reranker reads query and chunk together, which is far more precise.
- Rerank — overview — Cohere (docs, free, ~0.5h, rated 8/10). Retrieve twenty, rerank, keep four. It is one extra call and it is the cheapest quality jump available to you — usually larger than swapping the generation model, which is where people reach first.
Build this — Measure recall@k before you tune anything. For each question in your eval set, record whether the answer-bearing chunk appeared in the top k at all. If it didn't, no prompt on earth was going to save that answer. Split your failures into 'never retrieved' and 'retrieved and ignored' — they have completely different fixes.
You're done when: You have a recall@k number for your own corpus, and you fixed retrieval before you touched the prompt.
Common traps:
- Tuning the prompt to fix answers whose source was never retrieved.
- Not handling the missing-document case. When nothing relevant exists, the system should say so, not answer from the nearest irrelevant chunk.
Check yourself:
- Users search for error code "E4031" and get nothing useful. Why, and what fixes it? Answer: Embeddings don't represent exact identifiers well. Add keyword search (hybrid) so exact matches get found.
- Recall@5 is 60% but recall@50 is 95%. What do you add? Answer: A reranker. The right documents are being found; they just aren't ranked high enough. Rerank the top 50 down to 5.
Put to work in: CAMS Lens — SEBI-grounded compliance intelligence · Agentic Research & Decision Intelligence Assistant
Explore more
- Home — overview, skills and a built-in AI assistant
- Experience — roles at Think360 AI (CAMS), CAMS Mutual Funds and IIT Delhi
- Projects — GenAI, LLM, RAG and full-stack builds
- Education — IIT Delhi, M.Tech & B.Tech Computer Science
- Learn — a working AI engineer's roadmap: LLMs, RAG, agents, evals, production
- GitHub Activity — open-source contributions
- Contact / Hire me