Logo Lanfrica

rayen012/tunisian-bac-math-rag

Domain:

educationnatural language processing

Record type:

software
Creator:
ray
Host:
Vertical AI tutor for Tunisian Baccalaureate Mathematics (RAG + Gemini) # Tunisian Bac Math RAG This repository contains the code developed for my Bachelor's thesis at the Technical University of Munich (TUM). The project implements an AI tutor for the Tunisian Baccalaureate mathematics examination (Section Mathématiques). Its purpose is to answer mathematics questions in a way that remains aligned with the official curriculum and with the style of Tunisian Bac corrections. The generated answers are written mainly in French and may include short motivational phrases in Tunisian Derja. ## Pipeline Overview ### End-to-End Pipeline ``` Scanned Exams (PDF/images) | v +-------------+ +-----------------+ | digitize.py | ----> | .tex files | | (Gemini OCR)| | (on GCS bucket) | +-------------+ +-----------------+ | v +---------------+ +------------------+ | build_db.py | ----> | ChromaDB | | (chunk+embed) | | (BGE-M3 vectors | +---------------+ | + metadata) | +------------------+ | +-------------------------+ | | | v v v +---------+ +---------+ +---------+ | RAG | | Prompt | | Hybrid | | Engine | | Only | | Engine | +---------+ +---------+ +---------+ | | | v v v +--------------------------------------+ | Gemini 2.5 Flash | | (answer generation, T=0.15) | +--------------------------------------+ | v Student Answer (French + Derja style) ``` ### Hybrid Engine Routing ``` Student Question | v Two-Stage Retrieval (via rag_engine) | v Best L2 Distance? | +--- distance Case A: use retrieved context directly | +--- distance Case B: retrieved context + curriculum prompt | +--- distance > 1.6 ---> Case C: prompt-only fallback (no retrieval) ``` ### Evaluation Pipeline ``` 20 questions (5 categories) | v run_evaluation.py ---> 3 systems x 20 questions = 60 answers | v generate_grading_sheets.py ---> anonymized (Systeme X/Y/Z) | v generate_teache …