Skip to content
All posts

· 5 min read · Muhammad Shah

Building an AI tutor that stays on-syllabus with RAG

At Alkhidmat I built a RAG-based AI tutor for Banoqabil LMS, a learning platform serving thousands of users, on the OpenAI and Gemini APIs. The goal was simple: students should get answers from the course they're actually studying, not from the open internet.

Why a plain chatbot isn't enough

A general-purpose model answers confidently, but it doesn't know your syllabus, your terminology or what the instructor emphasised. It can be right in general and still wrong for the exam. For learning, "on-syllabus" matters more than "clever".

How retrieval-augmented generation fixes it

RAG adds a step before the model answers: find the most relevant pieces of the course material, then ask the model to answer using only those pieces. The answer becomes grounded in your content, and you can show students where it came from.

  • Prepare the content: split lessons, notes and transcripts into small, self-contained chunks.
  • Index it: store each chunk with an embedding so it can be found by meaning, not just keywords.
  • Retrieve: for every question, pull the few chunks that best match it.
  • Generate: give the model those chunks with clear instructions to stay within them.

Guardrails that matter in education

  • Say "I don't know" when the course doesn't cover the question, instead of guessing.
  • Keep answers at the student's level and point back to the lesson for depth.
  • Treat the student's message as data, so instructions hidden in it can't change the tutor's rules.
  • Log questions the tutor couldn't answer: they show instructors where the material has gaps.

Measure it with real questions

Before launch, collect real student questions and check the answers against the course. That tells you far more than any benchmark. After launch, keep reviewing a sample every week; retrieval quality drifts as new content is added.

If you're planning an AI assistant for your own courses, the same approach works for any platform with structured content. I'm happy to talk it through.