74. Ollama

Run large language models locally on your own machine with Ollama.

By Jacques Botte, founder of Toptronic®. Last updated 12 September 2026.

The lesson

Ollama is a free, open-source tool that makes it easy to run large language models on your own computer. It handles the complex steps of downloading model weights, configuring the runtime, and exposing a chat interface or API, so you can focus on using the model instead of managing infrastructure.

The main reason people use Ollama is local execution. When a model runs on your machine, your prompts and documents never leave your network. This is important for privacy, intellectual-property protection, and working offline. There are also no per-token API fees, although you do need capable hardware.

Installing Ollama gives you a command-line program. To start chatting, you type a command such as `ollama run llama3` or `ollama run qwen2`. Ollama downloads the model if you do not already have it, then opens an interactive chat session where you can type prompts and receive answers.

Ollama maintains a large model library. You can find general chat models such as Llama 3, Mistral, and Qwen; coding models such as CodeLlama and DeepSeek-Coder; and smaller models such as Phi 3 and Gemma that fit on laptops with limited memory. The library is constantly growing as the open-source community releases new models.

You can customize models with a Modelfile, which is like a recipe. In a Modelfile you set the base model, the system prompt, parameters such as temperature and context length, and any adapter files. This lets you build specialized agents or enforce a consistent personality across conversations.

Ollama exposes a local REST API and an OpenAI-compatible endpoint. That means tools such as LangChain, OpenWebUI, Continue, and many IDE extensions can talk to Ollama as if it were a cloud provider. This makes it easy to integrate local models into your existing workflow.

Hardware matters. Running a 70-billion-parameter model at full precision requires a powerful GPU and a lot of memory. Most users run quantized versions, which use less memory and run faster at the cost of a small quality drop. Ollama handles quantization automatically when you pull a model.

Best practices: keep Ollama and your models updated, choose a model size that fits your hardware, test outputs before using them in production, and remember that local models can still produce incorrect or biased answers.

Check yourself

Question 1: What is the main advantage of running a model with Ollama?
  1. It is the only way to use OpenAI models
  2. Local execution, privacy, and no per-token API cost — correct
  3. It requires no computer
  4. It only runs on mobile phones

Answer: Local execution, privacy, and no per-token API cost

Ollama runs models locally, keeping prompts private and avoiding per-token cloud API charges.

Question 2: Which command starts an interactive chat with a model in Ollama?
  1. ollama train llama3
  2. ollama run llama3 — correct
  3. ollama delete llama3
  4. ollama build llama3

Answer: ollama run llama3

`ollama run <model>` downloads the model if needed and opens an interactive chat session.

Question 3: How can external tools connect to an Ollama model?
  1. They cannot
  2. Through a local REST API and OpenAI-compatible endpoint — correct
  3. Only by email
  4. Only through a paid subscription

Answer: Through a local REST API and OpenAI-compatible endpoint

Ollama exposes a local REST API and an OpenAI-compatible endpoint for integration.

← Previous lesson · All 83 lessons · Next lesson →

The full course — 83 lessons and 249 quiz questions — ships inside the app. Get TPEE to study it offline.