LLM answers from training data → hallucination, knowledge cutoff, no domain specificity
With RAG
LLM answers from your curated knowledge → grounded, controllable, up-to-date
The RAG Pipeline
1. Embed the user query → query vector
2. Compare to knowledge base → find top K similar chunks
3. Build augmented prompt: system + context + question
4. LLM generates answer from context only
5. Return answer + sources to user
Interactive: Retrieve or Generate? (3–4 min)
Put each step in its phase.
The Critical RAG System Prompt
You are a knowledge base assistant.
Answer using ONLY the information in the context below.
If the context lacks the answer, say:
"I don't have enough information."
Do not use general training knowledge.
Do not invent facts.
Without this, the model will "help" by hallucinating from training data.
Evaluate Retrieval First
Before worrying about answer quality:
Are the top-K chunks actually relevant to the query?
Is the answer in the knowledge base at all?
Are chunks the right size?
Log retrieved chunks during development. Bad retrieval cannot be fixed by prompt engineering.
Interactive: Retrieval Quality (1/3)
True or false — cold-call, then tap.
Interactive: Retrieval Quality (2/3)
True or false — cold-call, then tap.
Interactive: Retrieval Quality (3/3)
True or false — cold-call, then tap.
Lab: Build the RAG Pipeline (1/2)
Gate:embeddings.json must exist — otherwise finish Session 8 first.
9.1:retrieveRelevantChunks — embed query, cosine-sort, top 3