For running AI locally on a laptop with 8GB RAM, you'll need to be strategic about model selection since memory is quite limited. Here are the best options for each of your use cases:
All-in-One Solutions (Best Starting Point)
Ollama - This is probably your best bet for getting started:
- Pros: Easy setup, handles model downloading/management, supports many quantized models
- Recommended models for 8GB RAM:
- Llama 3.2 3B (code generation + general Q&A)
- Codestral 7B (specialized for coding)
- Phi-3 Mini (3.8B parameters, very efficient)
- Memory usage: 2-4GB per model when quantized
- Setup: Download Ollama, then
ollama pull llama3.2:3b
LM Studio - User-friendly interface with good model management:
- Similar to Ollama but with a GUI
- Good for beginners who prefer visual interfaces
- Supports the same quantized models
Specific Use Case Recommendations
1. Code Generation
Best Options:
- CodeLlama 7B (4-bit quantized) - ~4GB RAM usage
- Codestral 7B (quantized) - ~4GB RAM usage
- DeepSeek Coder 6.7B - ~4GB RAM usage
Performance Reality: Expect slower generation than cloud AI, but still quite usable for code completion and simple functions.
2. Text to Audio (TTS)
Coqui TTS - Best local option:
- Memory usage: 1-2GB
- Setup:
pip install coqui-tts
- Quality: Very good, multiple voice options
- Command:
tts --text "Hello world" --out_path output.wav
Alternative: Bark (if you have GPU acceleration available)
3. Audio to Text (STT)
OpenAI Whisper - Industry standard:
- Model sizes for 8GB RAM:
- Whisper Base (~1GB) - Good balance of speed/accuracy
- Whisper Small (~2GB) - Better accuracy
- Setup:
pip install openai-whisper
- Usage:
whisper audio.mp3 --model base
4. PDF/Book Q&A (RAG)
This is the most complex task. You'll need a combination of tools:
Recommended Stack:
- Document Processing:
pypdf or langchain
- Embeddings:
sentence-transformers (all-MiniLM-L6-v2)
- Vector DB:
chromadb or faiss
- LLM: Llama 3.2 3B or Phi-3 Mini
Pre-built Solutions:
- PrivateGPT - Handles the entire pipeline
- LocalGPT - Similar to PrivateGPT
- Quivr - More user-friendly interface
Realistic Performance Expectations
With 8GB RAM, you'll need to manage your memory carefully:
Memory Budget:
- System + OS: ~2-3GB
- One LLM running: ~3-4GB
- Other applications: ~1-2GB
This means:
- You can run ONE AI model at a time effectively
- Switch between models for different tasks
- Consider closing other applications when using AI
Hardware Optimization Tips
-
Enable GPU acceleration if you have a decent GPU (even integrated):
- For Ollama: It auto-detects GPU
- For others: Install appropriate CUDA/ROCm libraries
-
Use quantized models (4-bit or 8-bit):
- Much smaller memory footprint
- Slightly reduced quality but still very usable
-
Increase virtual memory (swap file):
- Set to 16-32GB if you have storage space
- Helps with memory overflow situations
Recommended Setup Workflow
-
Start with Ollama for general use:
# Install Ollama
curl -fsSL https://ollama.ai/install.sh | sh
# Install a good general model
ollama pull llama3.2:3b
# Install a coding model
ollama pull codestral:7b-q4_0
-
Add Whisper for audio:
pip install openai-whisper
-
Add Coqui TTS for text-to-speech:
pip install coqui-tts
-
Set up PrivateGPT for PDF Q&A:
git clone https://github.com/imartinez/privateGPT
# Follow their setup instructions
Alternative: Cloud-Local Hybrid
Given your RAM limitations, consider this approach:
- Use local models for privacy-sensitive tasks
- Use cloud APIs (GPT-4, Claude) for complex tasks requiring more power
- Use local Whisper for audio processing (works great locally)
Best Single Recommendation
If you want the simplest setup that covers most of your needs:
Ollama + Llama 3.2 3B + Whisper Base + Coqui TTS
This combination will give you:
- Decent code generation and Q&A
- Good audio-to-text conversion
- Reasonable text-to-speech
- Total memory usage: ~6-7GB when running simultaneously
The performance won't match cloud-based solutions, but it's completely private and free to run once set up.