Cheat Sheet

Ollama Cheat Sheet

Commands, model management, and API usage for local LLMs

Basic Commands

ollama serve              # Start server (default port 11434)
ollama list               # Show downloaded models
ollama pull <model>       # Download a model
ollama rm <model>         # Delete a model
ollama cp <src> <dst>     # Copy/rename a model
ollama show <model>       # Model details (params, template)
ollama --version          # Check version

Running Models

ollama run <model>        # Interactive chat
ollama run <model> "prompt"  # One-shot
ollama run <model> --verbose  # Show timing/stats

Common Models

| Model | Size | RAM | Use Case | |-------|------|-----|----------| | llama3.1:8b | 4.7GB | 8GB | General chat | | llama3.1:70b | 40GB | 48GB | Advanced reasoning | | qwen2.5:7b | 4.3GB | 8GB | Coding | | qwen2.5:32b | 19GB | 24GB | Complex coding | | mistral-nemo | 7.1GB | 12GB | Balanced | | phi3:14b | 7.5GB | 12GB | Fast inference | | codellama:7b | 3.8GB | 8GB | Code generation | | dolphin-mixtral:8x7b | 26GB | 32GB | Uncensored | | nomic-embed-text | 274MB | 2GB | Embeddings | | llava:7b | 4.5GB | 8GB | Vision/OCR |

API Usage

# Generate text
curl http://localhost:11434/api/generate -d '{
  "model": "llama3.1:8b",
  "prompt": "Hello!",
  "stream": false
}'
# Chat with history
curl http://localhost:11434/api/chat -d '{
  "model": "qwen2.5:7b",
  "messages": [
    {"role": "user", "content": "Write a python function"}
  ],
  "stream": false
}'

Model Files (Custom Modelfiles)

FROM llama3.1:8b
PARAMETER temperature 0.7
PARAMETER top_p 0.9
SYSTEM "You are a helpful coding assistant."

Build: ollama create my-coder -f Modelfile

Useful Flags

# Run with specific params
ollama run <model> \
  --temperature 0.3 \
  --top_k 40 \
  --top_p 0.9 \
  --num_ctx 8192
# Persistent options
ollama run <model> --keep-alive 5m

Dual GPU

# Split across GPUs (for 30B+ models)
ollama run llama3.1:70b --num-gpu 2
# Force CPU only
OLLAMA_INTEL_GPU=0 ollama run <model>