🤖 Local AI with Ollama
Ollama runs large language models (LLMs) on your own computer. Nothing you type leaves your machine, it works offline, and it costs nothing per question. I use it for quick questions and for code.
1. Install
curl -fsSL https://ollama.com/install.sh | sh
This installs ollama and a systemd service that listens on http://localhost:11434. With an NVIDIA or AMD graphics card it uses the GPU automatically.
systemctl status ollama
ollama --version
2. Get a model and talk to it
ollama pull qwen3:8b # download a model (about 5 GB)
ollama run qwen3:8b # chat in the terminal; /bye to stop
ollama run qwen3:8b "Explain what a TOTP code is in two sentences."
ollama list # models on disk
ollama ps # models in memory, and whether they run on the GPU
ollama rm ministral-3:3b # remove a model
3. Which model fits?
The model has to fit in your video memory (VRAM), otherwise it runs (much slower) on the CPU. A rough guide for the usual 4-bit models:
| VRAM | Model size | Examples |
|---|---|---|
| 4 GB | 3–4B | ministral-3:3b, llama3.2:3b |
| 8 GB | 7–8B | qwen3:8b, qwen2.5-coder:7b, llama3.1:8b |
| 16 GB | 12–14B | qwen3:14b, gemma3:12b |
| 24 GB+ | 27–32B | qwen3:32b, gemma3:27b |
ollama ps shows 100% GPU when the whole model fits. My laptop has an 8 GB GPU, so I use 7–8B models:
- qwen3:8b for text,
- qwen2.5-coder:7b for code,
- ministral-3:3b when it has to be fast,
- nomic-embed-text for embeddings (search by meaning).
Qwen3 “thinks” before it answers. That gives better answers to hard questions, but is slow for simple jobs; type /set nothink in a chat to turn it off.
4. The API
Every program on your computer can use the model through a simple HTTP API:
curl -s http://localhost:11434/api/chat -d '{
"model": "qwen3:8b",
"stream": false,
"think": false,
"messages": [{"role": "user", "content": "Translate to Dutch: good morning"}]
}' | jq -r .message.content
From Python, without extra packages:
import json, urllib.request
def ask(question, model="qwen3:8b"):
data = json.dumps({"model": model, "stream": False, "think": False,
"messages": [{"role": "user", "content": question}]}).encode()
with urllib.request.urlopen("http://localhost:11434/api/chat", data) as r:
return json.load(r)["message"]["content"]
print(ask("What is the capital of the Netherlands?"))
5. Can it translate this website?
I tried to let a local model make the Dutch versions of this site. The build script first protects everything that must not change (code blocks, inline code, link addresses and formulas are replaced by placeholders such as ⟦C3⟧), cuts the text at headings into pieces of about 1,800 characters, has qwen3:8b translate each piece at a low temperature, checks that every placeholder came back, and then puts the code back in place.
Technically that works, but the Dutch was too poor: wrong articles (“de installatieprogramma”), made-up words (“snelkoppels”, “Werkingseinstellingen”) and sentences that clearly read as translated from English. An 8B model is simply too small for that. So I make the translations on this site with a larger model; local translation is switched off in the script, and can be turned back on when a better local model comes along (NOTES_AI_TRANSLATE=1).
6. Optional: use it from other computers
By default Ollama only listens on your own computer. To use it from your network:
sudo systemctl edit ollama
# add:
# [Service]
# Environment="OLLAMA_HOST=0.0.0.0:11434"
sudo systemctl restart ollama
⚠️ Ollama has no login or password. Only do this on a network you trust, or put it behind a firewall rule or a reverse proxy with authentication.
Want a ChatGPT-like web interface? Open WebUI connects to Ollama and runs in Docker.