Generative AI Course

Week 3: Fine-Tuning and RAG

Learn how to adapt models to domain data and ground outputs with retrieval for factual, high-precision generation.

Duration: 5 Sessions
Labs: 5
Project: Knowledge Copilot
DAY 1

Data Curation for Fine-Tuning

DAY 2

LoRA and QLoRA Workflows

python
# Pseudo setup for PEFT config
lora_r = 16
lora_alpha = 32
dropout = 0.05
batch_size = 4
grad_accum = 8
DAY 3

RAG Architecture and Retrieval Quality

ComponentDecisionImpact
Chunk Size500-900 tokensPrecision versus context coverage
Retriever Top-K4-8 docsCost and hallucination balance
RerankerCross-encoderHigher relevance, extra latency
DAY 4

Evaluation and Error Analysis

DAY 5

Build: Domain Knowledge Copilot

Week 3 Outcomes

  • Run fine-tuning experiments with PEFT methods
  • Build grounded RAG systems with source citations
  • Use evaluation loops to improve response quality
GUIDED PATH

Beginner Walkthrough: Make Answers More Accurate

When to use Fine-Tuning vs RAG (simple rule)

Daily action plan (2 to 3 hours/day)

  1. Day 1: Build a small, clean dataset of 100 to 300 high-quality instruction-answer pairs.
  2. Day 2: Run a basic LoRA fine-tune. Compare base model and tuned model on the same 20 test prompts.
  3. Day 3: Build a retrieval pipeline: chunk docs, create embeddings, and query top relevant chunks.
  4. Day 4: Add citation output and confidence checks. Reject answers when evidence is weak.
  5. Day 5: Integrate tuned style + RAG grounding into one knowledge copilot.

Quality checklist before moving to Week 4

Assignment to complete Week 3

Build a Knowledge Copilot for one domain (for example: HR policy, product docs, SOP manuals, or legal templates). The assistant must answer with citations and decline when confidence is low.

Scoring rubric

CategoryExpectationWeight
GroundednessAnswers map to source content without made-up facts35%
Style consistencyResponse format stays stable across prompts20%
Evaluation rigorYou track metrics and failure patterns clearly25%
Product readinessUsable UI/API with basic error handling20%