Lecture: 4, RAG Foundations and the Decision Matrix Duration: 35 minutes Difficulty: Beginner
By the end of this lab you will:
| Requirement | How to Check |
|---|---|
| Python 3.10+ | python --version |
| Dependencies | pip install openai rich python-dotenv tiktoken |
| Ollama + model | ollama list (should show at least one model) |
# Pull different quantizations to compare (optional)
ollama pull deepseek-r1:8b # Default
ollama pull llama3.2:3b # Smaller model
ollama pull qwen2.5:7b # Alternative
cd lab_03_benchmarking
python lab_03_benchmarking.py
| File | Description |
|---|---|
lab_03_benchmarking.py |
Main benchmark script with TODO section |
lab_03_benchmarking.ipynb |
Jupyter notebook version |
solutions.py |
Complete solutions |
data/test_prompts.json |
20 test prompts across 5 categories |
The script auto-discovers all Ollama models and DeepSeek API. Observe the list.
The script sends 5 test prompts to each model and measures:
Find score_quality() and implement keyword-based scoring.
Use the results to answer: which model would you pick for each scenario?
A comparison table showing speed, quality, and cost across all models.
| Issue | Solution |
|---|---|
| No models found | Pull models with ollama pull <model> |
| Streaming error | Some models donβt support streaming β script handles this |
| DeepSeek rate limit | Reduce n_prompts or add a delay between calls |