Why run a model locally?
A local model can give you control over where inference runs, allow offline experiments after setup, and make memory use and generation speed easier to observe.
For sensitive material, verify the whole data path. A downloaded model running locally can process prompts on the machine, while cloud models, connected tools, telemetry and integrations may send data elsewhere. Ollama also offers cloud models, so a local app address alone does not prove that generation stays local. Check the selected model and integrations before using restricted data. Ollama local and cloud behavior.
Local inference has hardware, energy and maintenance costs. It can avoid a provider’s per-generation charge, subject to the model’s license and the software you use. Installation and model downloads can still require network access.
Estimating memory
As nominal weight arithmetic, seven billion parameters stored at two bytes each require about 14 GB. At four bits each they require about 3.5 GB. Actual files include scales, metadata and tensors that may use different precision. Running a model also needs memory for its context cache, intermediate data and the runtime, alongside other applications.
Quantization reduces the precision used to store some model data. Its effect on memory, speed and answer quality depends on the method, model, hardware and task. Compare the actual artifact and evaluate it on representative examples. Quantization overview.
GGUF names such as Q4_K_M describe a quantization scheme and variant. A mixed-precision variant need not store every tensor at exactly four bits. Check the artifact size and the runtime’s quantization documentation. llama.cpp quantization.
The qwen2.5:7b artifact used below is listed by Ollama as a 7.62B-parameter Q4_K_M model with a 4.7 GB download. That file size does not establish total runtime memory. Start with a context size and concurrent load your machine can support, then measure peak memory and tokens per second. Exact model tag.
A local example
Ollama’s installer supports macOS and Linux. Review the installation instructions for your operating system, then download the named model.
curl -fsSL https://ollama.com/install.sh | sh
ollama run qwen2.5:7bOllama exposes a subset of the OpenAI API on its local server. With that local model available, the following example uses the OpenAI Python client against localhost:11434. The placeholder API key is required by the client and ignored by the local server. Supported API behavior.
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:11434/v1",
api_key="ollama",
)
text = "The meeting moved to Friday. Please confirm attendance."
r = client.chat.completions.create(
model="qwen2.5:7b",
messages=[{
"role": "user",
"content": "Summarise this in three bullets:\n" + text,
}],
temperature=0,
)
choice = r.choices[0]
answer = choice.message.content
if choice.finish_reason != "stop" or not answer:
raise ValueError("No complete text answer was returned")
print(answer)Keep provider-specific handling in the adapter. Supported parameters, tools, output formats and retry behavior can differ even when endpoints share a request shape. Test those features when changing the base URL or model.
Other local runtimes and applications include llama.cpp, LM Studio and GPT4All. For server workloads, vLLM is another option. Check each tool’s hardware requirements, licenses and supported models before selecting it.
Evaluate the chosen model and runtime
Try the tasks your application needs, including difficult examples and failure cases. A model that performs well on ticket labels may still struggle with planning, arithmetic, a complex schema or tool use. That result needs investigation of the model, prompt, quantization and runtime settings.
Use the model’s documented chat template. A mismatched template can change behavior, so verify it when bypassing a high-level runtime. Measure memory with the actual context length and concurrency. Compare a local candidate with any hosted alternative using the same quality, privacy and latency requirements.
Check your understanding
A local quantized model tags support tickets well but performs poorly on a planning test. What is the justified next step?
Pick the one you would defend. Your answer stays private.
Your place and first choices stay on this browser. Classroom credit is recorded separately.
Every lesson here is open. Your progress is recorded once you pass the Python, from Zero, for AI exam.
Stuck on something?Ask Sayali, your AI tutor