Area 02 / 08 · RAG
RAG
Phase 2 · Weeks 7–10Make the model answer from your own documents instead of its memory.
Retrieval-augmented generation is the most common AI feature in real products: find the right pieces of your own data, put them in the prompt, and answer with citations. The first ten concepts get a working pipeline. The second ten are what separates a demo from a system people trust: better queries, smarter chunks, parsing, citations and retrieval metrics.
0 of 20 used in code
01–10 · The base
Learn these first.
- 01EmbeddingsTurn text into a list of numbers (a vector) so similar meanings end up close together.
- 02Cosine SimilarityScores how closely two vectors point the same way (1 = same). The usual way to compare embeddings.
- 03Chunking StrategiesSplit documents into pieces (by size, sentence or heading) small enough to retrieve precisely.
- 04Vector DatabasesDatabases built to store vectors and find the nearest ones fast (Qdrant, Pinecone, Weaviate, Chroma).
- 05pgvectorA Postgres extension that adds vector columns and similarity search to the database you already use.
- 06HNSW IndexesA graph-based index for approximate nearest-neighbour search. Fast even over millions of vectors.
- 07Metadata FilteringNarrow the search by fields like date, user or document type.
- 08BM25 Keyword SearchClassic keyword ranking. Catches exact names, codes and terms that embeddings miss.
- 09Hybrid SearchMerge keyword and vector results (for example with reciprocal rank fusion) to find more of the right chunks.
- 10RerankingA second model re-scores the top results so the best chunks go into the prompt.
11–20 · Production level
Come back after you have shipped something.
- 11Query RewritingLet the LLM rephrase or expand the user’s question before you search.
- 12HyDEHave the LLM write a hypothetical answer, embed that answer, and search with it.
- 13Contextual RetrievalUse an LLM to add a short note to each chunk saying where it sits in the document, then index it.
- 14Parent-Child ChunkingSearch small chunks for precision, then send their bigger parent section for context.
- 15Document ParsingGetting clean text, tables and structure out of PDFs, web pages and scans.
- 16CitationsAnswers point to the exact source chunks, so users can check them.
- 17GraphRAGBuild a graph of entities and their relations, and retrieve over it for connect-the-dots questions.
- 18Agentic RAGAn agent decides when to search, where, and how many times, instead of one fixed lookup.
- 19Recall@kOut of all the relevant chunks, how many showed up in the top k results.
- 20MRR and nDCGRanking metrics that reward putting the right chunk near the top of the list.
BUILD THIS
'Chat with your PDFs': parse, chunk, embed into pgvector, hybrid search + reranking, answers with citations. Measure Recall@5 on 30 test questions.
Project guide →