What I Built
A local exam-prep tutor for my friend Nishant. He [his real problem, e.g. "studies from scattered notes and web pages and has no way to test himself"] before [course/exam]. Paste URLs or upload PDFs, then either ask questions (answered only from his notes, with sources shown) or get quizzed and graded on his own answers.
Demo
[video link]
Code
Exam Tutor
Local RAG study partner built for my friend Nishant. Paste URLs or upload notes, then ask questions or get quizzed. Everything runs on-device with open-weight models via Ollama. No API key, no internet needed after setup, notes never leave the laptop.
Setup
# 1. install Ollama: https://ollama.com
ollama pull qwen2.5:3b
ollama pull nomic-embed-text
# 2. run
pip install -r requirements.txt
streamlit run app.py
Use
- Sidebar: paste URLs (web pages or PDFs) or upload files, click Ingest.
- Ask mode: question gets answered only from the ingested notes, with sources shown.
- Quiz me mode: enter a topic, get an exam-style question, answer it, get graded.
Sample sources to try (data structures):
https://en.wikipedia.org/wiki/Binary_search_tree
https://en.wikipedia.org/wiki/AVL_tree
https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
How it works
- Chunk text (900 chars, 150 overlap)
- Embed chunks with
nomic-embed-text(Ollama) - Cosine similarity over numpy matrix, top 4 chunks
-
qwen2.5:3banswers using only retrieved chunks - Swap model: edit
CHAT_MODELinapp.py
Stack
…How I Built It
- Chat model: Qwen2.5 3B via Ollama, runs on a laptop CPU/GPU.
- Embeddings: nomic-embed-text via Ollama.
- Retrieval: notes chunked (900 chars, 150 overlap), embedded, cosine similarity over a numpy matrix, top 4 chunks fed to the model.
- Grounding: system prompt restricts answers to retrieved notes; if notes don't cover it, it says so.
- Quiz mode: model writes one exam-style question from retrieved chunks, then grades the student's answer against them.
- UI: Streamlit. Ingestion via trafilatura (web) and pypdf (PDFs).
- Whole thing is ~150 lines, one file.
Why Does Open Innovation Matter?
- Offline: works with bad hostel wifi. After model pull, zero internet needed.
- Private: his notes never leave his laptop.
- Free: no API key, no per-query cost, no rate limit during exam week.
-
Swappable: changing the model is one line (
CHAT_MODEL). [Add your real 3B vs 7B comparison, or delete this sentence.] - A closed API would need billing, a key, and a connection, which is exactly what a student doesn't want the night before an exam.
Top comments (0)