Ollama Cheat Sheet (commands, API, env vars)
A one-page reference for running models locally with Ollama. Tested on Ollama 0.40.13, Windows, CPU-only (no discrete GPU). Chinese version of the site: irubik.cn.
Basic commands
| Command | What it does |
|---|---|
ollama list | List installed models and their size |
ollama pull <model> | Download / update a model |
ollama run <model> | Start an interactive chat |
ollama ps | Show models currently loaded in memory |
ollama stop <model> | Unload a running model |
ollama serve | Start the local API server (usually runs automatically) |
ollama rm <model> | Delete a model |
Useful flags for ollama run: --verbose prints timing statistics after each answer.
Local API
The server listens on http://127.0.0.1:11434 by default.
# generate
curl http://127.0.0.1:11434/api/generate -d "{\"model\":\"qwen2.5:3b\",\"prompt\":\"hello\",\"stream\":false}"
# embeddings
curl http://127.0.0.1:11434/api/embed -d "{\"model\":\"bge-m3\",\"input\":\"some text\"}"
# loaded models and memory usage
curl http://127.0.0.1:11434/api/psTiming fields in a /api/generate response:
| Field | Meaning |
|---|---|
load_duration | Time spent loading the model (nanoseconds) |
prompt_eval_count / prompt_eval_duration | Prompt tokens and time |
eval_count / eval_duration | Generated tokens and time |
Tokens per second = eval_count / (eval_duration / 1e9). Add "keep_alive": 0 to unload the model after the request.
Environment variables
| Variable | Purpose |
|---|---|
OLLAMA_HOST | Address the server binds to (e.g. 0.0.0.0) |
OLLAMA_MODELS | Where model files are stored |
OLLAMA_KEEP_ALIVE | How long a model stays loaded after a request |
OLLAMA_NUM_PARALLEL | Number of parallel requests |
OLLAMA_MAX_LOADED_MODELS | How many models may stay loaded |
HTTPS_PROXY | Proxy used when downloading models |
Set them before starting ollama serve; on Windows use setx or the system environment settings.
Measured on a CPU-only machine
Intel i5-12400, 32 GB RAM, no discrete GPU, Ollama 0.40.13, one prompt, 80 generated tokens:
| Model | Size | Cold start | Speed | Peak memory |
|---|---|---|---|---|
| qwen2.5 3B | 1.9 GB | 2.31 s | 17.0 tok/s | ~2.5 GB |
| qwen2.5 7B | 4.7 GB | 5.07 s | 7.76 tok/s | ~5.5 GB |
| deepseek-coder 6.7B | 3.8 GB | 8.33 s | 9.16 tok/s | ~11.7 GB |
All three ran purely on CPU (size_vram was 0). Full write-up (in Chinese): running local models without a GPU.
Embedding models
| Model | Output dimension | 150-character input |
|---|---|---|
bge-m3 | 1024 | ~340 ms |
nomic-embed-text | 768 | ~143 ms |
Both are fast enough to embed a personal knowledge base on CPU; the bottleneck in a RAG setup is usually generation, not embedding.
Notes
- First answer after loading is always slower; the model stays in memory for a while, so back-to-back questions are faster.
- Memory usage is not the same as model file size — a 3.8 GB model can take 11.7 GB of RAM once loaded.
- If memory is tight, lower the context length or use a smaller model instead of forcing a bigger one.