Repository navigation
RAG 1 · Why your FAQ bot invents answers, and what naive retrieval fixes #23
akash-coded
started this conversation in
Exercises
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Exercise · RAG · Interim 1
Language: Python · Topics: embeddings, chunking, cosine retrieval, naive RAG · Level: Foundational
Scenario
TravelMind's FAQ bot keeps inventing refund rules that do not exist. Passengers get wrong answers about their PNR JX48Q2 cancellation. You are building the retrieval layer so the bot reads before it speaks.
Mental model: open-book exam. A closed book tests memory (bare model). An open book lets you look things up (RAG). Two separate phases:
flowchart LR subgraph OFFLINE [Index time, once] D[Docs] --> C[Chunk] --> E[Embed] --> V[(Vector store)] end subgraph ONLINE [Query time, every question] Q[Question] --> QE[Embed] --> S[Search] --> AUG[Augment] --> G[Generate] --> A[Answer + cite] end V -. serves .-> SSimilarity is geometry:
Reference snippets:
Part A · Why RAG (MCQ)
Q1. Why RAG rather than fine-tuning to give the bot current refund rules?
Q2. An embedding turns text into:
Q3. Cosine close to 1 means, and close to 0 means:
Part B · Read the retrieval code (MCQ)
Q4. In the
embedsnippet, the returned array shape is:(embedding_dim,)(len(texts), embedding_dim)(len(texts),)Q5. In
retrieve,np.argsort(-sims)[:k]gives:Part C · Predict from the bars
Q6. A query embeds and scores against three chunks:
With
k=1, which chunk doesretrievereturn, and what would the bot's answer be grounded in?Q7. Predict the print for this call given a corpus of 9 chunks with 1024-dim Titan vectors:
Part D · True or false (pick only)
Q8.
Part E · Multi-select
Q9. Symptoms of chunks that are TOO SMALL: (choose all)
Part F · Match the pipeline
Q10. Match each stage to its job. One is a distractor.
Part G · Spot the bug, pick the fix
Q11. This retrieval always returns nonsense. What is wrong, and which fix is correct?
docsmust be a single stringk=3stream=TruePart H · Trace the flow
Q12. Sort these into the correct order for naive RAG at query time:
Part I · Read the grounding prompt (MCQ)
Q13. The grounding prompt says: "Answer ONLY from the context. If the answer is not there, say you do not know." What does the "say you do not know" clause achieve?
Part J · Sort into two buckets
Q14. Label each as OFFLINE (index time) or ONLINE (query time):
Part K · Scenario
Q15. The bot confidently answered "pets under 5 kg fly free in cabin," but no such rule exists in the corpus. Which single fix addresses this, and why?
max_tokensPart L · Skeptic check
Q16. Naive RAG already passes your eyeball test on the refund questions. Give one reason to STOP here rather than adding reranking and query rewriting today.
All reactions