Skip to content

Romainmlt123/Piscine-Intelligence-Lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽ“ Tuteur IA

AI-Powered Voice Tutor for French Students

Python FastAPI Ollama License

A multi-agent voice assistant that helps students learn Math, Physics, and English through natural conversation โ€” 100% local, privacy-first.

Features โ€ข Demo โ€ข Architecture โ€ข Installation โ€ข Performance


โœจ Features

Feature Description
๐ŸŽค Voice-First Speak naturally, get audio responses in real-time
๐Ÿง  Multi-Agent RAG Specialized agents for Math, Physics, English with dedicated knowledge bases
๐Ÿ” Hybrid Search Vector + BM25 retrieval achieving 80% hit rate
โšก Streaming Response Token-by-token text + progressive audio (TTFA ~3s)
๐Ÿ”’ 100% Local All processing on your machine โ€” no cloud, no API keys
๐Ÿ“š Source Citations Every answer shows the document chunks it used

๐ŸŽฌ Demo

๐ŸŽค "What is Ohm's Law?"
     โ”‚
     โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  ๐ŸŸข PHYSICS โ€ข llama3.2:1b                                   โ”‚
โ”‚                                                             โ”‚
โ”‚  Ohm's Law states that the voltage U across a conductor    โ”‚
โ”‚  equals the product of current I and resistance R.         โ”‚
โ”‚  Formula: U = R ร— I                                        โ”‚
โ”‚                                                             โ”‚
โ”‚  ๐Ÿ“š Sources: Livre troisiรจme 2017.pdf (chunks 42, 43, 45)  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
     โ”‚
     โ–ผ
๐Ÿ”Š Audio response plays automatically

๐Ÿ— Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                          TUTEUR IA v1.6.0                            โ”‚
โ”‚                     Multi-Agent RAG + Voice                          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                      โ”‚
โ”‚   ๐ŸŽค INPUT                    PROCESSING                   OUTPUT ๐Ÿ”Šโ”‚
โ”‚   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  โ”‚
โ”‚                                                                      โ”‚
โ”‚   Audio โ”€โ”€โ–ถ [Whisper] โ”€โ”€โ–ถ [Router] โ”€โ”€โ–ถ [Agent] โ”€โ”€โ–ถ [Piper] โ”€โ”€โ–ถ Audioโ”‚
โ”‚              (STT)      (Classify)   (RAG+LLM)     (TTS)            โ”‚
โ”‚                              โ”‚                                       โ”‚
โ”‚              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                      โ”‚
โ”‚              โ–ผ               โ–ผ               โ–ผ                      โ”‚
โ”‚        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                โ”‚
โ”‚        โ”‚   MATH   โ”‚    โ”‚ PHYSICS  โ”‚    โ”‚ ENGLISH  โ”‚                โ”‚
โ”‚        โ”‚          โ”‚    โ”‚          โ”‚    โ”‚          โ”‚                โ”‚
โ”‚        โ”‚ ChromaDB โ”‚    โ”‚ ChromaDB โ”‚    โ”‚ ChromaDB โ”‚                โ”‚
โ”‚        โ”‚ 994 docs โ”‚    โ”‚1640 docs โ”‚    โ”‚  6 docs  โ”‚                โ”‚
โ”‚        โ”‚          โ”‚    โ”‚          โ”‚    โ”‚          โ”‚                โ”‚
โ”‚        โ”‚ + BM25   โ”‚    โ”‚ + BM25   โ”‚    โ”‚ + BM25   โ”‚                โ”‚
โ”‚        โ”‚          โ”‚    โ”‚          โ”‚    โ”‚          โ”‚                โ”‚
โ”‚        โ”‚ qwen2.5  โ”‚    โ”‚ llama3.2 โ”‚    โ”‚  gemma   โ”‚                โ”‚
โ”‚        โ”‚  :1.5b   โ”‚    โ”‚   :1b    โ”‚    โ”‚   :2b    โ”‚                โ”‚
โ”‚        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                โ”‚
โ”‚                                                                      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Tech Stack

Component Technology Purpose
Backend FastAPI + Uvicorn WebSocket server, async streaming
STT OpenAI Whisper (base) Speech-to-text transcription
Embeddings sentence-transformers paraphrase-multilingual-MiniLM-L12-v2
Vector DB ChromaDB Persistent vector storage
Keyword Search rank-bm25 BM25 for hybrid retrieval
LLM Ollama Local inference (Qwen, Llama, Gemma)
TTS Piper Neural text-to-speech (French)
Frontend Vanilla HTML/CSS/JS ChatGPT-style interface

๐Ÿ“Š Performance

RAG Benchmark (20 test queries)

Metric Baseline After Optimization Improvement
Hit Rate 46.7% 80.0% +71% ๐Ÿš€
MRR 0.413 0.717 +74% ๐Ÿš€
Latency 25ms 27ms +2ms only

Optimization Journey

Iteration 1: Baseline vector search         โ†’ 46.7%
Iteration 2: Multilingual embeddings        โ†’ 53.3%
Iteration 3: Cleaned corrupted PDFs         โ†’ 60.0%
Iteration 4: Hybrid Search (BM25 + Vector)  โ†’ 80.0% โœ…

๐Ÿš€ Installation

Prerequisites

  • Python 3.10+
  • Ollama installed
  • ~8GB RAM recommended

1. Clone & Setup

git clone https://github.com/Romainmlt123/Piscine-Intelligence-Lab.git
cd Piscine-Intelligence-Lab

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

2. Download LLM Models

ollama pull qwen2.5:1.5b      # Math agent
ollama pull llama3.2:1b       # Physics agent
ollama pull gemma:2b          # English agent

3. Download TTS Model

mkdir -p models/piper
# Download from https://github.com/rhasspy/piper/releases
# Place fr_FR-upmc-medium.onnx in models/piper/

4. Run

./start.sh

Open http://localhost:8001 and click the microphone! ๐ŸŽค


๐Ÿ“ Project Structure

โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main.py              # FastAPI WebSocket server
โ”‚   โ”œโ”€โ”€ config.py            # Centralized configuration
โ”‚   โ”œโ”€โ”€ agents/
โ”‚   โ”‚   โ”œโ”€โ”€ orchestrator.py  # Multi-agent routing
โ”‚   โ”‚   โ””โ”€โ”€ llm_module.py    # Ollama wrapper
โ”‚   โ”œโ”€โ”€ rag/
โ”‚   โ”‚   โ”œโ”€โ”€ rag_module.py    # Hybrid RAG (Vector + BM25)
โ”‚   โ”‚   โ””โ”€โ”€ rag_benchmark.py # Performance testing
โ”‚   โ””โ”€โ”€ speech/
โ”‚       โ”œโ”€โ”€ stt_module.py    # Whisper STT
โ”‚       โ”œโ”€โ”€ tts_module.py    # Piper TTS
โ”‚       โ””โ”€โ”€ vad_module.py    # Voice Activity Detection
โ”œโ”€โ”€ static/
โ”‚   โ””โ”€โ”€ index.html           # ChatGPT-style frontend
โ”œโ”€โ”€ knowledge_base/
โ”‚   โ”œโ”€โ”€ math/                # 994 chunks (6รจme PDFs, Terminale)
โ”‚   โ”œโ”€โ”€ physics/             # 1640 chunks (3รจme-Terminale books)
โ”‚   โ””โ”€โ”€ english/             # Grammar basics
โ”œโ”€โ”€ docs/
โ”‚   โ”œโ”€โ”€ RAG_EVALUATION.md    # Benchmark methodology & results
โ”‚   โ”œโ”€โ”€ PRESENTATION_IO.md   # I/O architecture diagram
โ”‚   โ””โ”€โ”€ RAPPORT_RECHERCHE.md # Technical research report
โ””โ”€โ”€ models/
    โ””โ”€โ”€ piper/               # TTS voice models

๐Ÿ“– Documentation

Document Description
RAG Evaluation Benchmark methodology, 4 optimization iterations
I/O Presentation System architecture with diagrams
Research Report Technical deep-dive (French)
Model Choices LLM selection rationale

๐Ÿ”ฎ Future Improvements

  • Conversation Memory โ€” Multi-turn context retention
  • Tool Calling โ€” Calculator for math computations
  • Cross-encoder Reranking โ€” Further improve retrieval
  • More Languages โ€” Spanish, German agents

๐Ÿ‘จโ€๐Ÿ’ป Author

Romain Mallet


๐Ÿ“ License

MIT License โ€” feel free to use and modify!


โญ Star this repo if you find it useful!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors