Week 23 • Day 3Week 23

Day 3:Embedding the "Ask the AI Mentor" RAG Chatbot

Battle-tested daily lesson note • 100% runnable code, interview Q&A, test suite & interactive quiz

Day 3: Embedding the "Ask the AI Mentor" RAG Chatbot

1. Executive Overview & Product Vision

A static course website is passive; an interactive learning platform is an active, conversational mentor. By embedding a floating "Ask the AI Mentor" widget powered by our Hybrid RAG Retrieval Engine (Month 3) and Streaming Microservice (Month 5), visitors to your website can ask technical questions:

"What is the mathematical difference between LoRA and QLoRA?" "How does vLLM's PagedAttention solve KV cache fragmentation?" "Which week covers Model Context Protocol (MCP) servers?"

The AI Mentor answers with grounded explanations, code examples, and direct clickable citations to the exact curriculum day and source code file!

Architecture Flow Diagram
Learner as Website Learner
Widget as Floating React/JS Chat Widget
Gateway as FastAPI Mentor RAG Service
Index as Hybrid Vector + BM25 Curriculum Index
>Widget: Explain how LoRA matrix initialization works
>Gateway: POST /api/mentor/chat {query: ...}
>Index: Hybrid Retrieval (Top 3 Curriculum Chunks
>Gateway: Chunks: Week 21 Day 3 (LoRA Math) + Week 21 Day 7 (LoRA Mini-Project
>Gateway: Grounded Generation with Citations
>Widget: Streams explanation with markdown citation links: [Week 21 Day 3](...
>Learner: Renders interactive KaTeX math and clickable course links

2. Technical Architecture: Grounded Curriculum Index

  1. Deterministic Indexing:
    • The knowledge base indexes all 168 daily modules: week title, daily topic, theoretical equations, and code summaries.
  2. Hybrid Retrieval:
    • Combines BM25 lexical token matching with dense vector semantics, ensuring exact keyword queries (e.g., LoRALinear, NF4, Q4_K_M) match perfectly alongside conceptual queries.
  3. Citation Guarantee:
    • Every claim in the synthesized response is mapped to an authoritative file path in the repository.

In Simple English: Grounded "Ask the AI Mentor" Search Assistant

Adding a helpful mentor chatbot onto your course website without hallucinations follows 3 golden steps:

  1. Chunk every lesson by section (h1/h2) tagged with url_slug & day_id.
  2. Retrieve Top 3 lesson sections with Hybrid BM25 + Vector Search.
  3. Force inline clickable citations ([Week 7 Day 1](/ai/roadmap/w07-d01)) so students click straight to the exact chapter!