Stanford Online

RAG Explained: From BM25 to Agentic RAG | Stanford CS329Z Lecture 3 with Diyi Yang: summary

YouTube summary9 sectionsWatch on YouTube ↗

This is an AI-generated summary of the YouTube video "RAG Explained: From BM25 to Agentic RAG | Stanford CS329Z Lecture 3 with Diyi Yang" (Stanford Online), made with Samuraize and published by Samuraize. It condenses the YouTube video into 9 titled sections you can read in a couple of minutes, each linking to the moment in the video it covers.

1
Filed under💻 Technology0 comments🍱 Add to trayReport
Study this

RAG Explained: From BM25 to Agentic RAG | Stanford CS329Z Lecture 3 with Diyi Yang

Stanford Online

切

Project guidance 0:05

Pick a topic you care about and make it specific. The work should answer clear research questions, use data or APIs you can support, and say how you will evaluate the system. The course wants you to design, build, and judge agent systems, especially ones that use retrieval, tools, memory, multi-agent setups, optimization, safety, and careful evaluation.

切

RAG and retrieval 6:00

The lecture then turns to retrieval augmented generation, or RAG. A useful example is office hours: a model can guess, but with logged counts it can answer from evidence, such as Tuesday at 4:00 p.m. having 14 people and Thursday at 9:00 only 3. RAG keeps facts in an index instead of memory, so updates change the index, not the weights.

切

Indexing and chunking 23:30

Indexing starts with a unit that can be embedded, and the text is split so each chunk keeps enough context to be found. The lecture compares fixed-size splits, overlapping chunks, semantic breaks by sentence or paragraph, and richer chunks with added metadata. It also shows contextual retrieval, where a prompt adds missing company or date clues before indexing. That helps both embeddings and BM25, which together cut failed retrieval from 5.7 to 2.9.

切

Late and hierarchical indexes 34:31

Late chunking delays splitting until after the model has read the full document, so each piece carries document-level meaning. The gain is biggest when chunks are small. A further step is a tree index from Stanford called PeaKtor. It embeds chunks, summarizes and embeds the summaries, then keeps going upward. At query time, you search across levels, so detailed questions can hit leaf nodes and broader ones can match higher summaries.

切

Graph retrieval 38:01

Tree and graph layouts let you ask higher-level questions. A leaf node may answer a narrow lookup, but a question like who she is or what a happy ending means can require several layers of meaning. Graph RAG builds a knowledge graph at indexing time by extracting entities and relationships, then clusters communities and asks each cluster summary for an answer before merging them. This helps when one chunk or one document is not enough.

切

Retrieval tradeoffs 40:01

The same setup can reach across text, images, biology structures, molecules, social networks, citation networks, and knowledge graphs. That flexibility comes with cost. More advanced chunking and graph methods help with broader questions, but they are slower and can carry errors forward. For that reason, large QA systems often still use the earlier fast methods when they cover most questions well. The LM does not need to be state of the art, only capable enough for the tradeoff you choose.

切

Ranking metrics 56:32

NDCG at K compares relevance with rank. DCG discounts the top passages by position, while IDCG is the ideal ranking from the ground truth, then normalized to get the score. MRR looks at the rank of the first relevant result and averages it across queries. Recall checks whether the relevant passages appear in the top K.

切

Retriever choices 59:30

DPR can beat BM25 even with 1,000 annotated pairs, and multi-data training helps further. BM25 is good for exact matches, but it misses paraphrase. DPR handles meaning better, but can miss codes, numbers, and product IDs. Hybrid search combines both with reciprocal rank fusion, which merges ranks instead of scores.

切

Search pipeline risks 1:16:00

Prompt injection can enter the search process itself. Bad actors may add hostile text to the documents you retrieve, and that can attack the whole pipeline. These are the issues the lecture says it will mention later about Ragel. That closes the day’s material and leaves time for questions.

AI-generated summary. It can be wrong or incomplete - check anything that matters against the original.

Summarize your own YouTube video

Paste a YouTube link, article, PDF, ebook or slide deck and get a summary like this in seconds. Free to try, no sign-up needed.

⚔️ Try the YouTube summarizer

Discussion

Sign in to join the discussion. Sign in

More from the Bento Box

Browse the Bento Box →

With your OK, Microsoft Clarity and Google Analytics set cookies (data goes to the US) so we can see what breaks. Cookie details