RAG Customer Support Agent
Chunk a tiny product handbook, retrieve with cosine similarity over bag-of-words vectors, answer with citations, and refuse when retrieval is weak.
Outcome: A support agent that answers only from retrieved handbook chunks, cites chunk ids, and refuses when similarity is below a threshold.
intermediate · 6–8 hours
- 01
Overview and Architecture
Separate index-time chunking from query-time retrieval and generation, and state the refusal rule before you write cosine similarity.
- 02
Chunk the Handbook
Split a small handbook into overlapping chunks with stable ids, headings carried into the chunk text, and no empty slices.
- 03
Bag-of-Words Vectors and Cosine Retrieve
Build a vocabulary, vectorize chunks and queries as lists of floats, and retrieve top-k by cosine similarity without NumPy.
- 04
Answer with Citations
Generate a support reply only from retrieved chunks, attach chunk ids, and keep a fake model from using non-retrieved facts.
- 05
Refusal, Thresholds, and Evals
Tune tau, refuse adversarial and out-of-scope questions, and score a support eval set including mug-vs-API lexical traps.