BetaMaShop is in public beta. We improve it continuously, and your feedback shapes what comes next.
MaShop/Blog/Tools/How to Run Local LLMs With Ollama: A Practical 202…
ToolsJune 22, 2026
Read · 5 min
ollama · local llm

How to Run Local LLMs With Ollama: A Practical 2026 Guide

Run local LLMs with Ollama on your own hardware: install, pull models, the OpenAI-compatible API, RAM needs, and quantization explained.

Running large language models used to mean renting GPU time from a cloud provider and shipping every prompt to a server you do not control. That assumption is breaking down on the desktop. With a free, open-source tool, you can run local LLMs with Ollama on an ordinary laptop, keep every token on your own machine, and still talk to the model through the same API shape that the OpenAI client libraries already speak. This guide covers what the tool does, the hardware it actually needs, how to pull and run your first model, the quantization math that makes it possible, and how to wire a local model into a real application.

Key takeaways
  • Ollama wraps the llama.cpp inference engine behind a single command-line tool and a local REST API on port 11434, with installers for macOS, Linux, and Windows.
  • The practical floor is roughly 8 GB of RAM for a 7B-class model at 4-bit quantization; a 13B model wants about 8 to 10 GB, and 70B-class models need 38 to 48 GB.
  • An OpenAI-compatible endpoint at /v1/chat/completions lets existing code point at localhost with almost no changes.
  • Local inference trades raw speed and frontier quality for privacy, zero per-token cost, and full offline operation.

What Ollama actually is

Ollama is a thin, friendly layer over the heavy machinery of local inference. Underneath, it runs llama.cpp, the C and C++ engine that made it possible to run quantized transformer models on consumer hardware. The project's own repository confirms the split: the codebase is roughly two thirds Go and a quarter C, with the Go side handling model management, the REST server, and the command-line experience, while the C layer does the numerical work.

What you get in practice is a package manager for models plus a runtime. You ask for a model by name, the tool downloads a quantized copy, caches it on disk, loads it into memory, and exposes it both as an interactive chat in your terminal and as a small web service. There is no Python environment to assemble, no CUDA toolkit to match against a driver version, and no separate server process to babysit. For most people that reduction in friction is the entire point.

The model files themselves use the GGUF format, a single-file packaging of weights plus metadata that llama.cpp reads directly. Because the format bundles the tokenizer and the prompt template alongside the weights, a downloaded model carries everything it needs to produce sensible output without extra configuration.

Why run local LLMs with Ollama at all?

The case for local inference rests on three concrete benefits rather than benchmark bragging rights. The first is privacy. When the model runs on your hardware, your prompts and the documents you feed it never leave the machine. For anyone handling client contracts, medical notes, unreleased code, or personal journals, that property is not a nice-to-have, it is the difference between a usable tool and a compliance problem.

The second is cost structure. A hosted API charges per token, so a workload that hammers the model thousands of times a day turns into a recurring bill that scales with usage. A local model has a fixed cost, namely the electricity and the hardware you already own. Once the weights are on disk, you can generate as much text as you like without a meter running.

The third is availability. A local model works on a plane, in a basement lab with no network, or during the inevitable afternoon when a provider's status page turns red. The model does not depend on anyone else's uptime. Those three properties, taken together, explain why local inference has moved from a hobbyist curiosity to a serious option for developers and small teams.

None of this means local models match the largest hosted systems on raw capability. They do not, and pretending otherwise sets you up for disappointment. The honest framing is that a well-chosen local model handles a large share of everyday tasks well enough that the privacy and cost advantages tip the balance.

The hardware question: how much memory you need

The single most common reason a first attempt goes badly is a mismatch between the model and the machine. A model has to fit in memory to run, and if it does not fit it either crashes or spills onto disk and crawls. The numbers below come from community testing and vendor guidance gathered through 2026, and they are best read as floors rather than comfortable targets.

The documented minimum for Ollama is about 8 GB of RAM, 10 GB of free disk, and a 64-bit processor with AVX2 support, with no dedicated graphics card strictly required. At that floor, a 7B-class model quantized to 4-bit precision fits, using somewhere between 4 and 6 GB once loaded. Step up to a 13B model and you should plan for 8 to 10 GB at the same quantization. A 70B-class model is a different animal entirely, wanting 38 to 48 GB depending on how much context you ask it to hold.

A graphics card changes the experience from usable to pleasant. On a machine with 16 GB of system RAM plus an 8 to 12 GB GPU, such as an NVIDIA RTX 3060 or 4060, or on an Apple Silicon Mac with 16 GB of unified memory, a 7B to 14B model runs at a comfortable 30 to 60 tokens per second. That is fast enough to feel like a real conversation rather than a slideshow. Apple Silicon deserves a special mention because its unified memory architecture lets the GPU address the same pool as the CPU, so a Mac with generous RAM punches above its weight for local inference.

Note

Context length costs memory too. The key and value cache that holds the conversation grows with the number of tokens in the window, so a model that fits at a short context can run out of room at a long one. If a model loads but stalls during a lengthy chat, shrink the context before blaming the weights.

Quantization, or why a 7B model fits in five gigabytes

The reason any of this works on a laptop is quantization, the practice of storing model weights at lower numerical precision than the 16-bit floating point used during training. A weight that would occupy 16 bits in full precision can be squeezed to 4 bits with a clever scheme that preserves most of the model's behavior. The popular Q4_K_M variant does exactly that, compressing weights to roughly 4-bit precision and cutting memory use by about 75 percent compared with full 16-bit storage.

The trade is real but usually small. A 4-bit model produces output that is marginally less precise than the same model at full precision, and on hard reasoning tasks the gap widens. For drafting text, summarizing documents, or answering questions over your own files, the difference is often imperceptible. The naming convention encodes the scheme: a tag like q4_K_M means 4-bit, K-quant method, medium size, and you will see q5 and q8 variants that trade more memory for higher fidelity.

The practical advice is to start at Q4_K_M, which sits at the sweet spot of size and quality for most hardware, and only move up to Q5 or Q8 if you have memory to spare and notice quality problems. Moving down to Q3 or Q2 is possible on very tight machines, but the quality cost there is steep enough that a smaller model at Q4 is usually the better choice.

Installing and running your first model

Installation is a single command on every supported platform. On macOS or Linux, the project's documented one-liner fetches and runs the installer:

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

On Windows, the PowerShell equivalent does the same:

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

There is also an official ollama/ollama Docker image for anyone who prefers containers. Once installed, pulling and chatting with a model is one command. To start an interactive session with a small Llama model, you run ollama run followed by the model name and an optional quantization tag, for example ollama run llama3.1:8b-q4_K_M. The first invocation downloads the weights, which can take a few minutes on a typical connection, and every later invocation loads them from the local cache. If you only want to fetch a model without chatting, ollama pull downloads it for later use.

From the interactive prompt you simply type, and the model streams its reply token by token. You can switch models on the fly. Listing what you have downloaded is ollama list, and removing one you no longer want is ollama rm. The whole surface is small enough to learn in an afternoon.

The Modelfile

For anything beyond casual chat, the Modelfile is where customization lives. It is a short text file, modeled loosely on a Dockerfile, that declares a base model and layers settings on top. You can pin a system prompt so the model always adopts a particular role. You can set the temperature and other sampling parameters, then define a custom template if the default does not suit your task. Building a tailored model from a Modelfile is a single ollama create command, and the result behaves like any other named model. This is how teams standardize a local assistant: one Modelfile checked into a repository gives everyone the same behavior without anyone hand-tuning settings.

The REST API and the OpenAI-compatible endpoint

The feature that turns Ollama from a toy into infrastructure is its local server. Whenever the tool is running, it exposes a REST API at http://localhost:11434. The native chat route lives at /api/chat and accepts a JSON body with a model name and a list of messages, returning either a streamed or a single response. That alone is enough to script against from any language.

The more interesting door is the OpenAI-compatible layer. Ollama publishes a compatibility surface at http://localhost:11434/v1, with chat completions at /v1/chat/completions, designed to mirror the request and response shape that the OpenAI client libraries already use. The practical consequence, spelled out in the project's compatibility announcement, is that you can take existing code written against the official OpenAI SDK and redirect it to a local model by changing two lines.

In Python, you construct the client with a base URL of http://localhost:11434/v1 and a placeholder API key of ollama, then call client.chat.completions.create exactly as you would against the hosted service. The JavaScript client follows the same pattern, passing baseURL and apiKey to the OpenAI constructor. Anything in your stack that already speaks the OpenAI Chat Completions protocol, including many agent frameworks and editor plugins, can be pointed at the local model with that single redirect.

The compatibility is not yet total. The announcement notes that the chat completions endpoint is fully operational, while embeddings, function calling, vision support, and log probabilities were still under consideration at the time of writing. For retrieval pipelines that need an embedding model, the native /api/embeddings route covers the gap, so you are not stuck waiting for full parity.

Choosing a model from the library

The model library is broad, and the right choice depends on the task and the hardware budget rather than chasing the largest number. The Llama family from Meta covers general chat and instruction following at sizes from a few billion parameters up. The Gemma models from Google are strong small options. Qwen models from Alibaba have become favorites for their quality at modest sizes, and DeepSeek's releases brought capable reasoning-oriented weights into the open library. Mistral and the related Mixtral mixture-of-experts models round out the menu for anyone wanting a different architecture.

A reasonable default strategy is to keep two models on hand: a small, fast one in the 3B to 8B range for quick tasks and autocomplete-style work, and a larger 13B to 30B model for jobs that need more reasoning, pulled out when the smaller one stumbles. Code-specialized variants exist for programming work and tend to outperform general models on that narrow task at the same size. Because pulling a new model is one command, experimenting is cheap, and the cache makes switching instant once the weights are local.

Tuning for speed on modest hardware

When a model runs but feels sluggish, a few levers usually recover most of the lost speed before you reach for new hardware. The first is offloading layers to the GPU. Ollama tries to place as many transformer layers as will fit into graphics memory and runs the rest on the processor, so a card that holds even part of the model speeds things up. If only some layers fit, you still gain, and watching how many layers land on the GPU tells you whether a smaller quantization would let the whole model run on the card.

The second lever is the context window. A shorter window means a smaller key and value cache, which frees memory and reduces the work per token. If you do not need the model to remember a long conversation, trimming the context is close to free performance. The third is batch and thread settings exposed through environment variables and the API, which let you match the number of CPU threads to your actual core count rather than a conservative default. None of these turn a laptop into a data center, but together they often move a model from frustrating to fluid, and they cost nothing but a few minutes of experimentation. The right combination depends on your exact machine, so the reliable method is to change one setting at a time and measure the token rate after each.

Where local inference makes sense, and where it does not

Honesty about limits is what separates a useful guide from a sales pitch. Local models running on consumer hardware will not match the largest hosted frontier systems on the hardest reasoning, the longest context, or the broadest knowledge. If your task genuinely needs the strongest model in existence, a local 7B is not it, and forcing the comparison only breeds frustration.

Where local inference shines is the long tail of ordinary work. Drafting and rewriting text, summarizing documents, extracting structured fields from messy input, classifying tickets, answering questions over a private knowledge base, and powering an editor's autocomplete are all well within reach of a mid-sized local model. For those jobs the privacy and zero marginal cost outweigh the modest quality gap, and the model is always there whether or not the network is.

There is also a hybrid pattern worth naming. Many teams route the bulk of high-volume, low-stakes calls to a local model and reserve a hosted frontier model for the rare request that genuinely needs it. Because both can speak the same OpenAI-compatible protocol, switching between them is a configuration choice rather than a rewrite. That arrangement keeps sensitive and repetitive work local while leaving an escape hatch for the hard cases.

Getting started without overcommitting

The fastest way to learn whether local inference fits your work is to spend twenty minutes with it. Install the tool, pull a 7B or 8B model at Q4_K_M, and run a few of your real tasks through it rather than a contrived demo. Watch the token speed, judge the quality on your own prompts, and note whether the machine stays responsive. That short test tells you more than any benchmark table, because it measures the thing that matters, which is whether the model is good enough for the work you actually do.

If the answer is yes, the next step is to wire the local server into your existing tools through the OpenAI-compatible endpoint and let the habit form. If the answer is no, you have lost almost nothing, and you have a clear, evidence-based reason to keep using a hosted model. Either way, the value of running the experiment is that it replaces guesswork about local models with a concrete answer for your hardware and your tasks. The barrier to that answer has never been lower, and for a growing number of developers the result is a permanent shift toward keeping inference close to home.

Comments 0

0 / 4000Your email stays private.
No comments yet. Be the first.

Keep reading picked for you.

Describe it. MaShop builds it.

Commerce apps and websites from one sentence. No card to start.

Start building