norboten · cheat sheet
Ollama on a server — a model is a service, a file, a cache and a timer — cheat sheet
ollama, ai-services
# service
systemctl cat ollama; systemctl show -p Environment ollama
sudo systemctl edit ollama # drop-in: Environment="OLLAMA_…"
sudo systemctl daemon-reload && sudo systemctl restart ollama
sudo ss -ltnp | grep 11434 # 127.0.0.1 only
# models
ollama list # on disk (GET /api/tags)
ollama ps # loaded, until when (GET /api/ps)
ollama show NAME --modelfile | --parameters # definition (POST /api/show)
ollama create NAME -f Modelfile # build from a Modelfile
ollama stop NAME # unload now
ollama rm NAME # delete
# requests
curl -s 127.0.0.1:11434/api/generate -d '{"model":"M"}' # preload
curl -s 127.0.0.1:11434/api/generate -d '{"model":"M","keep_alive":-1}' # keep loaded
curl -s 127.0.0.1:11434/api/chat -d '{"model":"M","stream":false,"messages":[{"role":"user","content":"…"}],
"options":{"num_ctx":4096,"temperature":0.2,"num_predict":200},"format":{…schema…}}'
curl -s 127.0.0.1:11434/api/embed -d '{"model":"all-minilm","input":["a","b"]}'
curl -s 127.0.0.1:11434/v1/chat/completions -d '{"model":"M","messages":[…]}' # OpenAI-compatible
# durations are nanoseconds; tokens/s = eval_count / (eval_duration / 1e9)
# prompt_eval_count < expected → truncated: journalctl -u ollama | grep 'truncating input'
# memory
systemctl show ollama -p MemoryMax -p MemoryPeak -p NRestarts
sudo journalctl -u ollama -o cat | grep -E 'projected to use|n_ctx|insufficient memory|oom-kill'
# Modelfile
FROM qwen2.5:0.5b
PARAMETER num_ctx 4096
PARAMETER temperature 0.2
SYSTEM """…"""