How to Run an Open Model Locally with Ollama in 20 Minutes

Why run a model on your own machine?

Cloud chatbots are convenient, but every prompt becomes someone else's server traffic. Running an open model locally flips that around: the weights live on your disk, inference happens on your hardware, and your prompts never leave your laptop. There is no API key to manage, no per-token bill, and once the model is downloaded, you can work without an internet connection.

Ollama is the simplest way to get there. It downloads models, runs a local server, and gives you a command line plus an HTTP API.



Source: NewsCarpenter illustration. Running a model locally keeps prompts and data on your own machine.



 



What you need before you start

The one hard constraint is memory: the model has to fit. A rough rule is about 1 GB of memory per billion parameters for a quantized model, plus headroom for your system. In practice, 8 GB of RAM runs a 7–8B model, and 16 GB opens up the 13B class.

  • OS: macOS, Windows, or Linux, with GPU acceleration where available.
  • Disk: at least 10 GB free. One 8B model is roughly 5 GB.
  • Internet: only for the download. After that, everything works offline.
  • GPU (optional): faster generation, but Ollama also runs on CPU. Start small on CPU-only hardware.

Set expectations honestly: a small local model will not match a frontier cloud model on hard reasoning. What it gives you is privacy, zero marginal cost, and a fast loop for learning and prototyping. The open-weight ecosystem keeps expanding — see Nvidia's reported interest in open-weight lab Reflection AI.

Step 1: Install Ollama

On Linux or macOS, the official install script is the fastest route:

curl -fsSL https://ollama.com/install.sh | sh

On macOS you can also use Homebrew (brew install ollama). On Windows, download the installer from ollama.com/download, or use PowerShell:

irm https://ollama.com/install.ps1 | iex

Verify the install and check that the server answers:

ollama --version curl http://localhost:11434/api/tags

Ollama serves its API on port 11434 by default. If the CLI cannot connect, start the server manually with ollama serve in a separate terminal and leave it running.

Step 2: Pick your first model

Choose a model that fits comfortably in memory rather than the biggest one you can download:

  • Llama 3.1 8B (llama3.1, about 4.7 GB) — a solid general-purpose default for chat, writing, and light coding.
  • Qwen3 4B (qwen3:4b, about 2.5 GB) — a good smaller option for laptops with limited memory.
  • Gemma 3 4B (gemma3:4b, about 3.3 GB) — a strong compact model for everyday tasks.
  • Mistral 7B (mistral, about 4.1 GB) — a long-standing community favorite for general chat.

Download your pick with pull. This is the only step that needs the internet:

ollama pull llama3.1

Browse the full library at ollama.com/library and check each model's tags and sizes before downloading. DeepSeek's open-weights push is another reason the library keeps growing.

Step 3: Chat in the terminal

Start an interactive session with run. The first run downloads the model if needed, then opens a chat prompt:

ollama run llama3.1

Type a message and press Enter. Type /bye to exit, or /help to see built-in commands. For a one-off prompt, pass it as an argument:

ollama run llama3.1 "Explain quantization in two sentences."

Three commands manage your local library:

ollama list ollama ps ollama rm old-model-name

list shows downloaded models, ps shows what is loaded, and rm frees disk space. Deleting a model only removes the local copy.

Step 4: Call the local API from your own code

Terminal chat is great for trying a model, but the real payoff is when your own programs can call it. Ollama exposes a native API under /api and an OpenAI-compatible API under /v1.

One-shot generation with the native API:

curl http://localhost:11434/api/generate -d '{   "model": "llama3.1",   "prompt": "Why is the sky blue?",   "stream": false }'

In Python, point the OpenAI client at your local server. The API key can be any placeholder, since nothing is sent to OpenAI:

from openai import OpenAI client = OpenAI(base_url="http://localhost:11434/v1", api_key="ollama") response = client.chat.completions.create(     model="llama3.1",     messages=[{"role": "user", "content": "Explain what a closure is in JavaScript."}], ) print(response.choices[0].message.content)

This pattern is what makes local models useful for building: agents, retrieval pipelines, and internal tools can all talk to the same local endpoint. Open-weight decision models built for AI agents show where this is heading.

Step 5: Customize a model with a Modelfile

A Modelfile bakes in a system prompt and sampling parameters so behavior stays consistent. Create a file named Modelfile:

FROM llama3.1 PARAMETER temperature 0.7 SYSTEM """ You are a concise coding assistant. Answer with short explanations and working code. If you are unsure, say so instead of guessing. """

Build it and run it:

ollama create my-coding-assistant -f ./Modelfile ollama run my-coding-assistant

Keep temperature modest for factual or coding work, and raise it only for more varied output. The base model is untouched, so you can delete the variant and try again.

Troubleshooting

  • Cannot connect. Make sure Ollama is running: run ollama serve in a spare terminal.
  • Port 11434 in use. Another Ollama instance is probably running. Find it with lsof -i :11434 and stop it.
  • Model not found. Run ollama list for exact names and tags. Tags are case-sensitive.
  • Slow or out of memory. Drop to a smaller tag — from an 8B model to a 4B one — and close heavy apps. On CPU-only machines, single-digit tokens per second is normal, not a bug.

Where to go next

Once the loop works, add a chat UI such as Open WebUI, point a coding assistant at the local API, and try a second model family to compare outputs. When one user stops being enough — a small team sharing a model — look at a serving engine built for concurrent requests, such as vLLM.

The whole setup fits in an evening: install Ollama, pull one model that fits your hardware, have a real conversation with it, and make one API call from your own code.

Comments

Popular posts from this blog

Open-Source AI Weekly: Bonsai, GigaChat 4 Lead

Claude Claims Proof of Riemann Hypothesis After 167 Years

How to Build an AI Agent with LangGraph in 30 Minutes