Skip to content

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 ​

CommandWhat it does
ollama listList installed models and their size
ollama pull <model>Download / update a model
ollama run <model>Start an interactive chat
ollama psShow models currently loaded in memory
ollama stop <model>Unload a running model
ollama serveStart 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/ps

Timing fields in a /api/generate response:

FieldMeaning
load_durationTime spent loading the model (nanoseconds)
prompt_eval_count / prompt_eval_durationPrompt tokens and time
eval_count / eval_durationGenerated tokens and time

Tokens per second = eval_count / (eval_duration / 1e9). Add "keep_alive": 0 to unload the model after the request.

Environment variables ​

VariablePurpose
OLLAMA_HOSTAddress the server binds to (e.g. 0.0.0.0)
OLLAMA_MODELSWhere model files are stored
OLLAMA_KEEP_ALIVEHow long a model stays loaded after a request
OLLAMA_NUM_PARALLELNumber of parallel requests
OLLAMA_MAX_LOADED_MODELSHow many models may stay loaded
HTTPS_PROXYProxy 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:

ModelSizeCold startSpeedPeak memory
qwen2.5 3B1.9 GB2.31 s17.0 tok/s~2.5 GB
qwen2.5 7B4.7 GB5.07 s7.76 tok/s~5.5 GB
deepseek-coder 6.7B3.8 GB8.33 s9.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 ​

ModelOutput dimension150-character input
bge-m31024~340 ms
nomic-embed-text768~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.