Pedram Agand
← Projects
Project

AI Tutor: End-to-End Adaptive Learning System

llmragpythonfastapibayesianeducation-techchromadb

FastAPI-backed AI tutoring system with RAG, Bayesian Knowledge Tracking, and adaptive hint selection — designed to provide proactive, personalized learning assistance.

Most AI tutors are chatbots with a system prompt. This project builds something closer to an actual pedagogical system: a backend that tracks what a learner knows (and doesn't), decides when to intervene proactively, and adapts its hint style based on whether previous hints actually worked.

The system has completed formal evaluation through an LLM-as-a-Student framework — running simulated students through the tutor and measuring whether the interventions improved learning outcomes.

Core Components

RAG Pipeline: Course PDFs are ingested into ChromaDB. When a student asks a question, the system retrieves relevant document chunks and builds a context-aware prompt — grounding answers in the actual course material rather than the LLM's training data.

Bayesian Knowledge Tracker (BKT): Each student has a per-skill mastery estimate maintained in PostgreSQL. BKT updates the estimate after every interaction using the four standard parameters (learn rate, forget rate, slip, guess). When mastery on a skill drops below a threshold, the Intervention Controller flags it for a proactive hint — delivered before the student asks.

Adaptive Hint Selection: An epsilon-greedy algorithm balances exploiting hint styles that have worked well for a student historically vs. exploring new styles. The feedback loop combines explicit ratings (thumbs up/down) with implicit signals (BKT state change after a hint).

API

uvicorn app.main:app --host 127.0.0.1 --port 8000 --reload

Key endpoints:

  • POST /questions — retrieve a question with context
  • POST /hints — get a personalized hint (RAG + user history)
  • POST /answer — submit answer; triggers BKT update + feedback loop
  • GET /user/profile — current mastery estimates per skill

Supports multiple LLM backends: Ollama (local), OpenAI, Google Gemini — switchable via .env.

Evaluation Results

Formal evaluation used an LLM-as-a-Student framework: a simulated student interacts with the tutor across multiple sessions. Key findings:

  • Proactive intervention threshold was too aggressive in the initial configuration — firing hints before students had a chance to attempt problems
  • Hint prompts needed more Socratic phrasing (guiding questions, not answer leaks)

Both are documented in the repo and queued as the next iteration before the UI layer (Stage 6) is built.

Setup

git clone <repo>
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env  # configure LLM_PROVIDER + API keys
uvicorn app.main:app --port 8000

I write about this kind of work — reliability, uncertainty, building things that work in production. One email per month.