Cookies

With your permission, we use Google Analytics cookies to measure visits and improve the site. Necessary cookies are always on. You can change your choice or withdraw consent anytime in the footer, under Cookie settings. Cookie Policy

Skip to content

RAG and Knowledge ·Intermediate

Math Tutor Agent – Agentic RAG with Feedback Loop

About this app

Architecture Flow <img width="465" alt="Screenshot 2025-05-04 at 3 45 58 PM" src="" /

  • Complete open-source code
  • Step-by-step tutorial

Technical sheet

Category
RAG and Knowledge
Difficulty
Intermediate
Models
OpenAI, Llama
Frameworks
LlamaIndex
Runs locally?
Needs cloud APIs
Required keys
OPENAI_API_KEYTAVILY_API_KEY

License Apache-2.0 · content curated and maintained by Doutor AI.

Full tutorial

This project implements an Agentic-RAG architecture to simulate a math professor that solves JEE-level math questions with step-by-step explanations. The system smartly routes queries between a vector database and web search, applies input/output guardrails, and incorporates human feedback for continuous learning.

📌 Features

  • ✅ Input Guardrails (DSPy): Accepts only academic math questions.
  • 📚 Knowledge Base Search: Uses Qdrant Vector DB with OpenAI Embeddings to match known questions.
  • 🌐 Web Fallback: Integrates Tavily API when no good match is found.
  • ✍️ GPT-4.1 Explanations: Generates step-by-step math solutions.
  • 🛡️ Output Guardrails: Filters for correctness and safety.
  • 👍 Human-in-the-Loop Feedback: Users rate answers (Yes/No), logged for future learning.
  • 📊 Benchmarking: Evaluated on JEEBench dataset with adjustable question limits.
  • 💻 Streamlit UI: Interactive dashboard with multiple tabs.

🚀 Architecture Flow

📚 Knowledge Base

  • Dataset: JEEBench (HuggingFace)
  • Vector DB: Qdrant (with OpenAI Embeddings)
  • Storage: Built with llama-index to persist embeddings and perform top-1 similarity search
  • Uses Tavily API for fallback search when the KB doesn't contain a good match
  • Fetched content is piped into GPT-4o for clean explanation

🔐 Guardrails

  • Input Guardrail (DSPy): Accepts only math-related academic questions
  • Output Guardrail (DSPy): Blocks hallucinated or off-topic content

👨‍🏫 Human-in-the-Loop Feedback

  • Streamlit UI allows students to give 👍 / 👎 after seeing the answer
  • Feedback is logged to a local JSON file for future improvement

📊 Benchmarking

  • Evaluated on 50 random JEEBench Math Questions
  • Current Accuracy: 66%
  • Benchmark results saved to: benchmark/results.csv

🚀 Demo

To run the app with Streamlit:

streamlit run app/streamlit.py

From the same category

RAG and KnowledgeIntermediate

Agentic RAG Embedding Gemma

This Streamlit app demonstrates an agentic Retrieval-Augmented Generation (RAG) Agent using Google's EmbeddingGemma for embeddings and Llama 3.2 as th…

  • Llama
  • local
RAG and KnowledgeIntermediate

Agentic RAG with GPT-5

An agentic RAG application built with the Agno framework, featuring GPT-5 and LanceDB for efficient knowledge retrieval and question answering.

  • OpenAI
RAG and KnowledgeIntermediate

Agentic RAG with Reasoning

A sophisticated RAG system that demonstrates an AI agent's step-by-step reasoning process using Agno, Gemini and OpenAI. This implementation allows us…

  • OpenAI
  • Gemini

Need a tailor-made solution?

Not sure where to start with AI in your business? Get a free assessment and a tailored plan - no commitment.

Save hours every week with AI, no hassle

Doutor AI gives you 1,859 ready-to-copy AI prompts, by industry and in plain English - plus a complete technical library for those who want to go further.

See plans