<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>M06: Retrieval-Augmented Generation (RAG) on Generative AI Boot Camp for Developers</title><link>https://genai-for-devs.agilebrainslabs.com/modules/m06-rag/</link><description>Recent content in M06: Retrieval-Augmented Generation (RAG) on Generative AI Boot Camp for Developers</description><generator>Hugo</generator><language>en-us</language><atom:link href="https://genai-for-devs.agilebrainslabs.com/modules/m06-rag/index.xml" rel="self" type="application/rss+xml"/><item><title>Lab</title><link>https://genai-for-devs.agilebrainslabs.com/modules/m06-rag/lab/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://genai-for-devs.agilebrainslabs.com/modules/m06-rag/lab/</guid><description>&lt;p&gt;&lt;strong&gt;Time:&lt;/strong&gt; ~25 min | &lt;strong&gt;Day 2 PM&lt;/strong&gt; (shared with M07)&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="learning-objectives"&gt;Learning Objectives&lt;/h2&gt;
&lt;p&gt;Build a RAG-based knowledge assistant. Ingest documents, query with grounding, and compare
RAG vs. non-RAG responses.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="concept-review-rag-in-practice"&gt;Concept Review: RAG in Practice&lt;/h2&gt;
&lt;h3 id="the-rag-pipeline"&gt;The RAG Pipeline&lt;/h3&gt;
&lt;div class="code-block"&gt;
 &lt;button class="code-copy" type="button" hidden aria-label="Copy code to clipboard"&gt;
 &lt;span class="code-copy-label" aria-hidden="true"&gt;Copy&lt;/span&gt;
 &lt;/button&gt;
 &lt;pre tabindex="0"&gt;&lt;code&gt;1. INGEST: Documents → chunks → embeddings → vector DB
2. QUERY: User question → embed → search vector DB → retrieve top-K chunks
3. AUGMENT: Build prompt with retrieved chunks as context
4. GENERATE: Send augmented prompt to LLM → grounded response&lt;/code&gt;&lt;/pre&gt;
 &lt;/div&gt;&lt;h3 id="key-components"&gt;Key Components&lt;/h3&gt;
&lt;table&gt;
	&lt;thead&gt;
			&lt;tr&gt;
					&lt;th&gt;Component&lt;/th&gt;
					&lt;th&gt;What It Does&lt;/th&gt;
					&lt;th&gt;Options&lt;/th&gt;
			&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tbody&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;strong&gt;Embedding Model&lt;/strong&gt;&lt;/td&gt;
					&lt;td&gt;Converts text to vectors&lt;/td&gt;
					&lt;td&gt;Chromadb built-in (onnx, free), OpenAI embeddings&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;strong&gt;Vector Database&lt;/strong&gt;&lt;/td&gt;
					&lt;td&gt;Stores and searches embeddings&lt;/td&gt;
					&lt;td&gt;ChromaDB (lightweight, pip install), Pinecone (cloud)&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;strong&gt;Chunking Strategy&lt;/strong&gt;&lt;/td&gt;
					&lt;td&gt;How you split documents&lt;/td&gt;
					&lt;td&gt;Fixed-size (200-500 tokens), sentence-based, semantic&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;strong&gt;Top-K Retrieval&lt;/strong&gt;&lt;/td&gt;
					&lt;td&gt;How many chunks to retrieve&lt;/td&gt;
					&lt;td&gt;Start with 3-5; more = broader context but higher token cost&lt;/td&gt;
			&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 id="why-rag-instead-of-fine-tuning"&gt;Why RAG Instead of Fine-Tuning?&lt;/h3&gt;
&lt;table&gt;
	&lt;thead&gt;
			&lt;tr&gt;
					&lt;th&gt;RAG&lt;/th&gt;
					&lt;th&gt;Fine-Tuning&lt;/th&gt;
			&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tbody&gt;
			&lt;tr&gt;
					&lt;td&gt;Dynamic — docs update instantly&lt;/td&gt;
					&lt;td&gt;Static — retrain when data changes&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;No model training needed&lt;/td&gt;
					&lt;td&gt;Requires training data and compute&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Works with any LLM&lt;/td&gt;
					&lt;td&gt;Tied to a specific model&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Provides citations (retrieved chunks)&lt;/td&gt;
					&lt;td&gt;No built-in provenance&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Cheaper and faster to implement&lt;/td&gt;
					&lt;td&gt;Better for consistent style/tone shifts&lt;/td&gt;
			&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 id="common-failure-modes"&gt;Common Failure Modes&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Retrieval misses relevant docs&lt;/strong&gt; → Chunks too large or too small; try different chunk size&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Irrelevant chunks confuse the LLM&lt;/strong&gt; → Lower top-K; add relevance threshold&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Context window overflow&lt;/strong&gt; → Too many chunks; reduce top-K or chunk size&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Stale data&lt;/strong&gt; → Vector DB not re-indexed; schedule regular ingestion&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="prerequisites"&gt;Prerequisites&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;LLM API access (for embeddings and generation)&lt;/li&gt;
&lt;li&gt;ChromaDB: &lt;code&gt;pip install chromadb&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Sample documents provided in &lt;code&gt;workshop/m06/docs/&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Using OpenCode or VS Code Chat:&lt;/strong&gt; Both work for this lab. OpenCode is good for
executing the Python scripts. VS Code Chat is good for explaining concepts as you go.&lt;/p&gt;</description></item></channel></rss>