ollama
Ollama for local LLM inference and model management
SKILL.mdconfig/skills/ollama/SKILL.md
GitHubCore Concepts
- Model Management:
ollama pull <model>downloads,ollama run <model>launches - Modelfile: Configuration file to customize model parameters, system prompt, template
- Ollama API: REST endpoint at
localhost:11434for chat, generate, embeddings - Local Inference: Run LLMs entirely offline on CPU or GPU with no cloud dependency
- Quantization: GGUF format with Q4_K_M, Q5_K_M, Q8_0 levels balancing speed/quality
- OpenAI Compatibility: Drop-in replacement via
OPENAI_BASE_URL=http://localhost:11434/v1
Common Patterns
ollama pull llama3.2:3bthenollama run llama3.2:3bfor first-time setup- Custom Modelfile with
FROM llama3.2,PARAMETER temperature 0.7,SYSTEM "You are..." - Python client:
requests.post("http://localhost:11434/api/generate", json={"model": "llama3.2", "prompt": "..."}) - OpenAI-compatible:
openai.OpenAI(base_url="http://localhost:11434/v1", api_key="ollama") - Embeddings via
POST /api/embeddingswith model likenomic-embed-text
Best Practices
- Match quantization to hardware: Q4_K_M for 8GB VRAM, Q8_0 for 16GB+
- Set
OLLAMA_NUM_PARALLEL=4andOLLAMA_MAX_LOADED_MODELS=2for concurrent use - Use Modelfile
TEMPLATEfor chat format alignment with each model - Pre-pull models during deployment to avoid first-request latency
- Monitor
ollama psto see loaded models and memory usage