This repository contains a Three-Tier LLM System designed to efficiently answer questions from PDF documents using local language models for edge devices like Raspberry PI. The system is optimized to run on a Raspberry Pi 4 with 8GB RAM and uses a tiered approach to balance accuracy and performance. This was done and built for a thesis purpose : Benchmarking and Deploying Local Language Models for Social Educational Robots using Edge Devices. this thesis and repository is part of a big project called RSC (Robot study companion), you can find all the necessary information on : rsc.ee
- Recommended: Raspberry Pi 4 with 8GB RAM (or any Linux/Windows/macOS system)
- Minimum: 6GB available RAM
- Storage: ~10GB free space (for models and data)
- Python: 3.8 or
clone the repository
git clone <repository-url>
cd LocalLM_RSCOllama is required to load the model, dowload ollama using :
Linux/macOS:
curl -fsSL https://ollama.com/install.sh | shWindows: Download and install from https://ollama.com/download
ollama serveKeep this running in a separate terminal.
Create the data directories:
mkdir -p data/documents
mkdir -p data/vector_dbyou need : ollama chromadb numpy pymupdf sentence-transformers
pip install ollama chromadb numpy pymupdf sentence-transformersDownload the language models using Ollama:
# Embedding model (required)
ollama pull nomic-embed-text
# Small model for Tier 2 (required)
ollama pull gemma3:1b-it-qat
# Large model for Tier 3 (required)
ollama pull granite4:tiny-h
Place PDF documents in the data/documents/ directory:
cp your-document.pdf data/documents/Start the main application:
python LocalLM.pyOn the first run, the system will:
- Initialize the vector database
- Verify all models are available
- Process all PDFs in
data/documents/ - Generate questions for the cache (if
AUTO_GENERATE_QUESTIONS = True) - Start the interactive query interface
Once running, you can use these commands:
- Ask questions: Simply type your question
stats- Show database statisticstier-stats- Show tier usage statisticsgenerate- Generate more questions for cachehelp- Show help messagequitorexit- Exit the program