Practice 3 — Compare 3 models in your terminal
Duration: ~15 min Prerequisites: Practice 2 — Slash commands and ~10 GB of free disk space
Three small downloads, six minutes of prompts, one big lesson: model choice is not arbitrary. Size, family and specialty change the experience in ways you have to feel to remember.
This practice is the hands-on version of chapter 05b — Choosing a local model and the catalogue annex. After it, the model choices in the demos will feel obvious.
The trio
Section titled “The trio”| Model | Size on disk | Family | Specialty |
|---|---|---|---|
gemma3:4b | ~2.5 GB | Google Gemma 3 | Generalist, small and fast |
llama3.1:8b | ~4.7 GB | Meta Llama 3.1 | Generalist, balanced (the course default) |
qwen2.5-coder:7b | ~4.4 GB | Alibaba Qwen 2.5 | Code-specialised |
We pick these three because they cover three axes at once:
- size: 4B vs 7-8B
- family: Gemma vs Llama vs Qwen (different chat templates, different training data)
- purpose: pure generalist vs code-specialist
Step 1 — Pull the trio
Section titled “Step 1 — Pull the trio”In a PowerShell window:
ollama pull gemma3:4bollama pull llama3.1:8bollama pull qwen2.5-coder:7bTotal download: ~11.6 GB. Depending on your bandwidth this takes 5 to 25 minutes. If llama3.1:8b is already there from practice 1, Ollama skips it.
Then check:
ollama listYou should see all three models with their sizes. Take note of how gemma3:4b is roughly half the size on disk of the other two — the parameter count nearly halves and so does the file.
Step 2 — Generalist prompt on each model
Section titled “Step 2 — Generalist prompt on each model”Same prompt, three runs. The prompt:
“Explain photosynthesis in exactly two sentences, suitable for a 10-year-old.”
Run it on each model:
ollama run gemma3:4b>>> Explain photosynthesis in exactly two sentences, suitable for a 10-year-old.[answer]>>> /bye
ollama run llama3.1:8b>>> Explain photosynthesis in exactly two sentences, suitable for a 10-year-old.[answer]>>> /bye
ollama run qwen2.5-coder:7b>>> Explain photosynthesis in exactly two sentences, suitable for a 10-year-old.[answer]>>> /byeRecord your impressions in a small table:
| Model | Time-to-first-token | Total time | Clarity (1-5) | Instruction following (1-5) |
|---|---|---|---|---|
gemma3:4b | your obs | your obs | your obs | your obs |
llama3.1:8b | your obs | your obs | your obs | your obs |
qwen2.5-coder:7b | your obs | your obs | your obs | your obs |
What you should typically observe:
gemma3:4bis the fastest (first token in ~1 second, full answer in 3 to 5 seconds) but sometimes ignores the “exactly two sentences” constraint and produces three or four short ones.llama3.1:8bis the most balanced: clear, follows the constraint, takes 4 to 8 seconds.qwen2.5-coder:7banswers correctly but its phrasing is sometimes drier — it is trained primarily on code, not pedagogy.
Step 3 — Code prompt on each model
Section titled “Step 3 — Code prompt on each model”This is where you see why we use qwen2.5-coder for the agent demos and not just a generic model. The prompt:
“Write a Python function
reverse_linked_list(head)that reverses a singly linked list iteratively. Include a small example of usage.”
Run it on each model the same way as step 2.
What you should typically observe:
gemma3:4bproduces working code most of the time, but with simpler examples and occasionally an off-by-one in the loop.llama3.1:8bproduces correct, idiomatic code. Good but not great on edge cases.qwen2.5-coder:7bproduces the most production-ready answer: correct edge cases (empty list, single node), type hints, a docstring, sometimes even a small test. This is what the code fine-tune of Qwen buys you.
This is exactly why Demo 3 (the agent that writes Java) lists qwen2.5-coder:7b as the validated code alternative to llama3.1:8b.
Step 4 — Inspect what is loaded with ollama ps
Section titled “Step 4 — Inspect what is loaded with ollama ps”While one model is open in ollama run, open another PowerShell window and run:
ollama psYou will see something like:
NAME ID SIZE PROCESSOR UNTILqwen2.5-coder:7b ... 5.2 GB 100% GPU 4 minutes from nowWhat this tells you:
- Only one model is loaded in VRAM at a time (typically). When you
ollama runa different model, Ollama unloads the previous one to make room. - The size column shows the runtime footprint (~5 GB for a 4.4 GB model — the weights expand a bit when loaded, plus the KV cache for the context window).
- The
UNTILcolumn shows the TTL: Ollama keeps the model warm for 5 minutes by default, then unloads it.
Try this experiment:
ollama run gemma3:4b>>> Hello>>> /bye
# Immediately, in the other window:ollama ps# you see gemma3:4b loaded, ~3 GB
ollama run qwen2.5-coder:7b>>> Hello>>> /bye
ollama ps# now you see qwen2.5-coder:7b loaded, ~5 GB# gemma3:4b is gone — Ollama unloaded it to fit the new oneThis is the same dance the comparator in Demo 2 does in parallel, except the demo loads three at once when your VRAM permits.
Trade-off matrix
Section titled “Trade-off matrix”After running steps 2 and 3, you can fill this table with your own values. Typical observations on a mid-range laptop:
| Aspect | gemma3:4b | llama3.1:8b | qwen2.5-coder:7b |
|---|---|---|---|
| Disk size | ~2.5 GB | ~4.7 GB | ~4.4 GB |
| VRAM at runtime (loaded) | ~3 GB | ~5 GB | ~5 GB |
| Tokens per second (typical) | 40-60 | 25-45 | 25-45 |
| Time-to-first-token | ~1 s | ~2 s | ~2 s |
| Generalist quality | OK | Good | Good |
| Code quality | Weak | Good | Excellent |
| Tool calling reliability | OK | Excellent (validated in the demos) | Needs a fallback parser (see ch 09) |
| Use it for… | quick chat on a small laptop | the default for every demo of this course | code-heavy work, especially demo 3 |
Which model will the demos use
Section titled “Which model will the demos use”- Demos 0, 1, 2, 4:
llama3.1:8bas the default. Good general behaviour, reliable tool calling. - Demo 3 (agent that writes Java):
llama3.1:8bas default;qwen2.5-coder:7bvalidated as the code-specialised alternative (with a fallback parser for its tool-call format — see the chapter 09 explanation). gemma3:4bis not used by any demo by default, but you can switch any demo to it by editing one line if you want to test on a small machine.
Now that you have felt these models in your terminal, the choices in the demos will feel obvious instead of arbitrary.
What you just proved
Section titled “What you just proved”- Size is not everything.
qwen2.5-coder:7bis smaller thanllama3.1:8bbut writes better code. - Family matters. Different families format conversations differently, train on different data, and produce different replies.
- Only one model fits in VRAM at a time on typical hardware.
ollama psshows the active one. - The tokens-per-second metric, visible with
--verbose, is the cheapest possible benchmark on your specific machine.
Next: launch full coding agents from Ollama itself
Section titled “Next: launch full coding agents from Ollama itself”You now master ollama run with a model. The final practice shows that Ollama can also launch other people’s coding agents (Continue, OpenCode, Codex-style CLIs) wired to your local model, with one command from the Ollama desktop app.