Zero-DB AI Study Assistant — Choose your model, upload PDFs, and get AI-powered cheatsheets and interactive tutoring.
gemma-4-31b-itvia Google AI Studio — fast, text-basednvidia/nemotron-3-nano-omni-30b-a3b-reasoningvia NVIDIA NIM — multimodal, PDF rendered as images- Automatic fallback: if Nemotron fails, gracefully switches to Gemma
- Drag & Drop Upload: Upload PDFs directly in your browser
- Gemma path: PDF → pypdf text extraction → text sent to model
- Nemotron path: PDF → PyMuPDF renders each page as PNG image → sent to model as image content blocks
- Multi-Page Support: All pages rendered and sent for full document understanding
- 4-Zone Structure: Automatically generates comprehensive study guides:
- Zone A: Concept Deep-Dive
- Zone B: Real-World Analogies
- Zone C: Worked Problems
- Zone D: Exam Traps & Strategy
- Markdown Export: Download cheatsheets as
.mdfiles for Obsidian, Notion, or any app
- Document-Aware: Chat remembers everything from your uploaded PDFs
- Conversation History: Multi-turn dialogues with context retention
- Step-by-Step Teaching: AI tutor explains concepts rather than just answering
- Zero Database: No user data stored anywhere
- Session Isolation: Each browser tab is isolated
- One-Click Wipe: Refresh the page to clear all data
The app ships with two model options, selectable via the UI:
| Model | Provider | Document Processing |
|---|---|---|
gemma-4-31b-it |
Google AI Studio | PDF → pypdf text extraction → text |
nvidia/nemotron-3-nano-omni-30b-a3b-reasoning |
NVIDIA NIM | PDF → PNG images (150 DPI) → multimodal |
Nemotron calls retry up to 2 times with a 2-second delay on failure. If all retries fail, the request automatically falls back to Gemma — no data loss.
| Component | Technology |
|---|---|
| Web Framework | FastAPI |
| Frontend | Vanilla HTML/CSS/JS |
| AI Models | Gemma 4 31B IT (Google AI Studio) + Nemotron 3 Nano (NVIDIA NIM) |
| SDK | OpenAI Python SDK (both endpoints are OpenAI-compatible) |
| PDF Text Extraction | pypdf |
| PDF Image Rendering | PyMuPDF (fitz) |
| Markdown Rendering | marked.js |
- A Google AI Studio API key (
GEMINI_API_KEY) — free tier available - A NVIDIA NIM API key (
NVIDIA_API_KEY) — available at build.nvidia.com - Python 3.12+ or Docker
-
Clone the repository:
git clone https://github.com/mingnatthakitt/ScratchLM.git cd ScratchLM -
Set up environment variables:
export GEMINI_API_KEY="your_google_api_key_here" export NVIDIA_API_KEY="your_nvidia_api_key_here"
-
Run with Docker:
docker build -t scratchlm . docker run -p 7860:7860 \ -e GEMINI_API_KEY=$GEMINI_API_KEY \ -e NVIDIA_API_KEY=$NVIDIA_API_KEY \ scratchlm
Or run without Docker:
pip install -r requirements.txt python app.py
-
Open in browser: Navigate to
http://localhost:7860
- Fork the Space: Clone it to your account
- Add Secrets: Go to Space Settings → Repository secrets → Add
GEMINI_API_KEYandNVIDIA_API_KEY - Done: The Space will automatically build and run
Use the dropdown in the sidebar to choose:
- Gemma 4 — text-based extraction, good for fast responses
- Nemotron 3 — renders PDF pages as images for full document understanding
Drag and drop a PDF onto the upload area, or click to browse.
Click ⚡ Extract to process the document. For Gemma, text is extracted. For Nemotron, pages are rendered as images.
- ✨ Generate: Create a 4-zone study guide from your PDF
- 💬 Chat: Ask questions about your PDF with full context awareness
- 📥 Download .md: Save the cheatsheet as a Markdown file
GNU Affero General Public License v3.0 (AGPL-3.0)
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/agpl-3.0.en.html.
- Google AI for Gemma models via AI Studio
- NVIDIA for Nemotron models via NIM
- Hugging Face for Spaces infrastructure
- FastAPI for the excellent web framework
