Module 2 - Prompting, RAG & Agents revision

Revision guide · ~35 min · dense bullets, not full lessons

Chapters 2.1–2.9. Skim headings; drill weak spots in full lessons.

2.1–2.2 LLMs, decoding, APIs, structured outputs

2.3–2.5 Evals, safety, advanced prompting, security

Evals

Prompt patterns

Security

2.6–2.8 RAG fundamentals to production

What RAG is

RAG (retrieval-augmented generation) = find relevant text first, add it to the prompt, then let the LLM answer from that evidence.

query → embed → retrieve top-k → (rerank) → pack into prompt → generate (+ cite)

Chunking

Problem Plain-English idea
Too big Noisy context; one chunk mixes many topics
Too small Loses meaning; answer spans get cut off
Overlap (10–20%) Facts near chunk boundaries appear in two chunks
Metadata source, section, date, tenant—enables filters and citations

Search types

Type Plain-English idea Good for
BM25 (keyword) Match exact words with smart scoring Error codes, SKUs, names
Dense (semantic) Match meaning via embeddings Paraphrases, synonyms
Hybrid Run both; merge with RRF or weighted fusion Production default

Indexes (know the tradeoffs)

Index Plain-English idea Trade-off
Flat / brute force (KNN) Compare query to every vector Exact; slow at scale
IVF (inverted file index) Cluster vectors; search nprobe buckets Faster; approximate—tune recall vs latency
PQ (product quantization) Compress vectors into short codes Huge memory win; more approximation error
HNSW (hierarchical navigable small world) Layered graph of neighbors Strong recall/speed; RAM-heavy

Knobs: IVF nprobe and HNSW efSearch both spend more query time for better recall.

Production RAG

2.9 Agentic AI & multi-agent

30-minute drill

  1. Draw IVF vs HNSW in one sentence each + one failure mode.
  2. Write a 5-line system prompt that blocks tool use on untrusted pasted text.
  3. List three RAG metrics you'd put on a dashboard before launch.