Ollama Complete Guide: The Easiest Way to Run LLMs Locally

📘 Tutorials 2026-07-19 · Updated 2026-11-26 3 min read

Ollama bundles model weights, an inference engine and an HTTP server into one installer. This guide covers install, model choice, commands, the OpenAI-compatible API, Modelfile customization and common errors.

📜 Table of Contents

📖 Keep reading

Ollama Tutorial: Run Local LLMs With One Command

Ollama wraps llama.cpp, a model registry and an HTTP server (port 11434) into one binary. Install it, run one command, and you have a local chat model.

What It Is Good For

Good for: private Chinese chat and drafting on your own machine, an offline backend for internal tools, the inference layer of a RAG stack.

Not good for: serving dozens of concurrent users (use vLLM), or research that needs fine-grained sampling control.

Install

# Linux (also installs a systemd service)
curl -fsSL https://ollama.com/install.sh | sh
systemctl status ollama

macOS: download the app or brew install ollama. Windows: download the installer; the service runs in the background.

ollama --version
ollama list

Pull and Choose a Model

ollama pull qwen2.5:7b
ollama run qwen2.5:7b "Explain vector databases in one sentence"
Tag Size (approx.) Chinese Best for
qwen3:4b 2.5GB Good Low-end machines
qwen2.5:7b 4.7GB Good Writing, doc QA, RAG backend
qwen2.5:14b 9GB Better 12GB+ VRAM
deepseek-r1:7b 4.7GB Good Math and logic
llama3.2:3b 2GB Fair English, old laptops
gemma3:4b 3.3GB Fair Multimodal tasks

Sizes are 4-bit approximations; check ollama.com/library for exact figures.

Commands You Actually Use

run, pull, list, ps, rm, show, cp, serve. In chat mode /bye exits, /clear resets context.

OpenAI-Compatible API

curl http://localhost:11434/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model":"qwen2.5:7b","messages":[{"role":"user","content":"hi"}]}'
from openai import OpenAI
client = OpenAI(base_url="http://localhost:11434/v1", api_key="ollama")

Any non-empty API key works. Advanced OpenAI features (structured outputs, logprobs, some tool-calling details) are not fully mirrored, so test real requests before relying on them.

Settings That Matter

Env var Effect Typical
OLLAMA_MODELS Model directory Large disk
OLLAMA_KEEP_ALIVE How long a model stays loaded 30m or -1
OLLAMA_NUM_PARALLEL Concurrent requests 2-4
OLLAMA_HOST Listen address Localhost only by default

Do not trust the default context window — it is small (around 4K in recent versions) and long documents get truncated. Set it in a Modelfile:

FROM qwen2.5:7b
PARAMETER num_ctx 16384
PARAMETER temperature 0.7
SYSTEM "You are a Chinese technical editor. Conclusion first, then reasons."
ollama create my-editor -f Modelfile

Raising num_ctx costs a lot of VRAM; a 7B model at 16K will spill to CPU on an 8GB card.

FAQ

Out of VRAM? Use a smaller or more quantized model, cut num_ctx to 4096, close other GPU apps. Check usage with ollama ps.

Slow first answer? Weights are loading; set OLLAMA_KEEP_ALIVE=30m.

Change port? OLLAMA_HOST=0.0.0.0:11435 ollama serve.

Where are models stored? /usr/share/ollama/.ollama/models on systemd Linux, ~/.ollama elsewhere. Move with OLLAMA_MODELS.

Commercial use? The tool is MIT; each model has its own license (Qwen mostly Apache 2.0, Llama has a custom agreement).

Ollama vs llama.cpp vs vLLM? Ollama for convenience, llama.cpp for control, vLLM for multi-user serving.

Related

Related Articles
2026-08-11
MLOps Tools 2026: The 12 Open Source Projects That Cover the Whole Pipeline
2026-07-22
GitHub Copilot Alternative Free 2026
2026-07-23
llama.cpp Guide 2026: Complete Tutorial to Run LLMs on Any Hardware
2026-07-23
Machine Learning Pipeline Architecture: Design Patterns for Production
2026-08-06
Plane (55,564 Stars) 2026: The Open-Source Jira Alternative for Project Management - Self-Host Guide
2026-08-07
AI Video Translator: Open-Source Dubbing and Subtitles That Work

Written by our editorial team; tools listed here are tested or verified against public sources. Links point to official sites or GitHub repos for reference only — no paid placements.

💬 Comments (0)

No comments yet. Be the first!

Login to comment