Skip to the content.

Ollama Local LLM Guide: Run LLMs Locally on Mac, Windows and Linux (Hardware, Models, Tools, Setup)

A practical, vendor-neutral guide to running large language models locally on your own computer with Ollama, LM Studio, llama.cpp, MLX, vLLM and other tools. It covers how much RAM and VRAM you need, how fast models will run on your hardware, which open-weight models to pick for chat, coding, reasoning, vision and embeddings, step-by-step setup on macOS, Windows and Linux, and how to connect local models to chat UIs, coding tools and your own apps through OpenAI-compatible APIs. It is for developers, privacy-conscious users and tinkerers who want a private, offline, free-to-run ChatGPT alternative on their own machine.

Last reviewed: December 2026. This is an independent guide; it is not affiliated with Ollama or any other project mentioned. Local AI moves fast: version numbers and model names below were checked in December 2026, and the commands are the stable, documented ones.

Table of Contents

Quick start in 3 commands

macOS or Linux:

curl -fsSL https://ollama.com/install.sh | sh     # install Ollama
ollama pull qwen3.5:9b                             # download a ~6 GB model
ollama run qwen3.5:9b "Explain what a vector database is in 3 sentences."

Windows (PowerShell):

irm https://ollama.com/install.ps1 | iex
ollama run qwen3.5:9b

Prefer a graphical app? Install LM Studio, search for a model, click Download, then Chat. Both run fully offline once the model is downloaded.

Best picks at a glance

If you want… Pick Why
The easiest start on any OS Ollama One installer, one command per model, background API on port 11434, huge model library
A polished desktop app with no terminal LM Studio Model search and download from Hugging Face, chat UI, local server, MLX engine on Macs
Maximum control and the newest model support llama.cpp The engine many tools build on; every flag exposed; runs almost anywhere
Best speed on Apple Silicon MLX (mlx-lm, or MLX models in LM Studio/Ollama) Built by Apple for unified memory
Serving many users from an NVIDIA/AMD server vLLM or SGLang Continuous batching and high throughput
A ChatGPT-style web UI for the whole household or team Open WebUI on top of Ollama Multi-user, document chat, model switching
A first model for 16 GB of RAM qwen3.5:9b, gemma4:e4b, or gpt-oss:20b (tight) Good quality per GB; tool calling support
A coding model on a 24 to 32 GB GPU or Mac qwen3-coder:30b or qwen3.6:27b Strong local coding with tool use
Embeddings for local RAG qwen3-embedding, nomic-embed-text, bge-m3 Small, fast, widely supported

These picks reflect the Ollama library and community usage as of December 2026. New models appear every month; the model selection method below stays valid when names change.

Why run LLMs locally (and when not to)

Good reasons

Honest limits

A common setup is hybrid: local models for private, high-volume or offline work, and a cloud model for the hardest tasks.

How local inference works in 5 minutes

  1. A model is a big file of numbers (weights). An 8-billion-parameter model has 8 billion weights. Stored as 16-bit floats that is 16 GB.
  2. Quantization shrinks the weights to about 4 to 8 bits each, with a small loss in quality. At about 4.5 to 5 bits per weight, the same 8B model is around 5 GB. Most local tools use 4-bit to 5-bit quantized files by default. See the companion idea of GGUF quantization types.
  3. The runtime loads weights into fast memory: GPU VRAM, Apple Silicon unified memory, or system RAM for CPU inference.
  4. Generating each token reads (almost) all the weights once. That is why token speed is limited mostly by memory bandwidth, not raw compute.
  5. Reading your prompt (prefill) is compute-bound and much faster per token than generating; long prompts still take noticeable time on CPUs and small GPUs.
  6. The context window holds your conversation. Its memory (the KV cache) grows with every token of context.
  7. File formats: GGUF (llama.cpp, Ollama, LM Studio, Jan, KoboldCpp), MLX (Apple’s format), and safetensors (Hugging Face, vLLM, SGLang).

Hardware sizing

Memory: will the model fit?

Rule of thumb

weights_GB  ≈ parameters_in_billions × bits_per_weight / 8
total_GB    ≈ weights_GB + KV_cache_GB + 1 to 2 GB overhead

Q4_K_M, the most common default quantization, averages about 4.9 bits per weight. Q8_0 is about 8.5.

Approximate weight sizes

Parameters Q4_K_M (≈4.9 bpw) Q5_K_M (≈5.7 bpw) Q8_0 (≈8.5 bpw) 16-bit
1B 0.6 GB 0.7 GB 1.1 GB 2 GB
3 to 4B 2 to 2.5 GB 2.1 to 2.9 GB 3.2 to 4.3 GB 6 to 8 GB
7 to 9B 4.3 to 5.5 GB 5 to 6.4 GB 7.4 to 9.6 GB 14 to 18 GB
12 to 14B 7.4 to 8.6 GB 8.6 to 10 GB 12.8 to 15 GB 24 to 28 GB
27 to 32B 16.5 to 19.6 GB 19 to 23 GB 29 to 34 GB 54 to 64 GB
70B 43 GB 50 GB 74 GB 140 GB
120B (MoE) about 65 GB as shipped for gpt-oss:120b (MXFP4)      

The llama.cpp project’s own measurement for an 8B model is 4.58 GiB at Q4_K_M and 7.95 GiB at Q8_0, consistent with this table.

KV cache (context memory)

KV_bytes = 2 × layers × kv_heads × head_dim × context_tokens × bytes_per_value

For a typical 8B model with grouped-query attention (32 layers, 8 KV heads, head dim 128) at 16-bit, that is 128 KiB per token: about 1 GB for 8K tokens and 4 GB for 32K tokens. Larger models and longer contexts grow this fast, which is why tools default to modest context sizes. Quantizing the KV cache to 8-bit halves it (see Performance tuning).

Mixture-of-Experts (MoE) models such as gpt-oss, qwen3-coder:30b or gemma4:26b must still fit all their weights in memory, but each token only uses a few experts, so they generate much faster than a dense model of the same total size. On machines with lots of RAM but modest bandwidth, MoE models are often the sweet spot.

Apple Silicon note: Macs share one pool of unified memory between CPU and GPU, but macOS reserves part of it; by default the GPU can use roughly two thirds to three quarters of RAM. Leave headroom for the OS and your apps: on a 16 GB Mac, aim for models of 10 GB or less; on 32 GB, about 22 GB; on 64 GB, about 45 GB.

Speed: how many tokens per second?

max_generation_tokens_per_sec ≈ memory_bandwidth_GB_per_s / bytes_read_per_token_GB

For a dense model, bytes read per token is roughly the model file size. For MoE models, use the size of the active parameters. Real-world speed is typically 50 to 80% of this upper bound.

Hardware Memory bandwidth (approx.) 8B Q4 (≈5 GB) upper bound 32B Q4 (≈19 GB) upper bound
Laptop/desktop CPU, dual-channel DDR5 60 to 100 GB/s 12 to 20 tok/s 3 to 5 tok/s
Apple M-series base chip 100 to 150 GB/s 20 to 30 tok/s 5 to 8 tok/s
Apple M-series Pro about 200 to 300 GB/s 40 to 60 tok/s 10 to 15 tok/s
Apple M-series Max about 400 to 550 GB/s 80 to 110 tok/s 20 to 28 tok/s
NVIDIA RTX 3090 / 4090 (24 GB) about 940 to 1,000 GB/s 180+ tok/s 50 tok/s (fits in 24 GB at Q4)
NVIDIA RTX 5090 (32 GB) about 1,800 GB/s 300+ tok/s 90 tok/s

Reading speed for comfortable chat is about 5 to 10 tokens per second; coding agents and batch jobs benefit from much more. Check exact bandwidth for your chip on the manufacturer’s spec page.

When the model does not fit in VRAM, tools split layers between GPU and CPU (“partial offload”). It works, but speed drops toward CPU speed as more layers live in system RAM.

Hardware tiers and what they run

Your machine Comfortable models Notes
8 GB RAM, no GPU 1B to 4B at Q4 (gemma4:e2b, qwen3.5:2b, qwen3.5:4b, llama3.2:3b) Fine for simple tasks, summaries, classification
16 GB RAM laptop or 16 GB Mac 4B to 9B (qwen3.5:9b, gemma4:e4b), gpt-oss:20b only if little else is open The most common starting point
8 to 12 GB VRAM GPU (RTX 3060/4060/4070 class) 7B to 14B fully on GPU Fast; bigger models with partial offload
24 GB VRAM (RTX 3090/4090) or 32 GB Mac 27B to 35B at Q4 (qwen3.6:27b, gemma4:31b, qwen3-coder:30b) The local sweet spot for quality
32 GB VRAM (RTX 5090) or 48 to 64 GB Mac 30B-class at higher precision, 70B at Q4 on 64 GB Macs, gpt-oss:120b on 96 GB+ Long contexts become practical
96 to 512 GB unified memory, or multi-GPU servers 100B+ MoE models Workstation or server territory

Buying advice in one paragraph: memory size decides what fits; memory bandwidth decides how fast it runs. For a single user, a Mac with lots of unified memory runs the biggest models quietly; an NVIDIA GPU with 24 to 32 GB runs mid-size models fastest and has the widest software support; CPU-only works for small models. Do not buy hardware for one specific model, because model sizes shift every few months.

Tools compared

Tool Type OS Interface API License Best for
Ollama Runtime + model library macOS, Windows, Linux, Docker CLI + desktop app Native REST, OpenAI- and Anthropic-compatible, port 11434 MIT Easiest start, apps that need a local API
LM Studio Desktop app macOS, Windows, Linux GUI + lms CLI OpenAI- and Anthropic-compatible, default port 1234 Proprietary (free) Point-and-click users, model browsing
llama.cpp Engine + CLI + server Everything, including Android CLI, built-in web chat OpenAI- and Anthropic-compatible server MIT Control, newest features, unusual hardware
MLX-LM Python library + CLI macOS (Apple Silicon) CLI OpenAI-style server (mlx_lm.server) MIT Fastest on Macs, fine-tuning on Macs
vLLM Serving engine Linux (NVIDIA, AMD, TPU and more) CLI OpenAI-compatible, port 8000 Apache-2.0 Multi-user servers, high throughput
SGLang Serving engine Linux GPUs CLI OpenAI-compatible Apache-2.0 High-throughput serving, structured outputs
Jan Desktop app macOS, Windows, Linux GUI OpenAI-compatible local server see repo Open-source ChatGPT-style desktop app
LocalAI API server Linux, macOS, Docker Web UI + API OpenAI-compatible (text, images, audio) MIT Drop-in OpenAI API replacement for many modalities
KoboldCpp Single-file app Windows, Linux, macOS Web UI KoboldAI and OpenAI-compatible AGPL-3.0 Storytelling and role-play communities
llamafile Single-file executables macOS, Windows, Linux, BSD Web UI + CLI OpenAI-compatible see repo Shipping a model as one file
text-generation-webui Web UI Windows, Linux, macOS Web UI OpenAI-compatible AGPL-3.0 Experimenting with many backends and settings
exo Distributed runtime macOS, Linux Web UI OpenAI-compatible Apache-2.0 Splitting one big model across several machines
Open WebUI Chat UI (needs a backend) Docker, Python Web UI n/a Open WebUI License Team chat UI over Ollama or any OpenAI-compatible API

Notes:

Setup: Ollama

Install

OS Command or download
macOS curl -fsSL https://ollama.com/install.sh \| sh or the macOS app
Windows irm https://ollama.com/install.ps1 \| iex in PowerShell, or the installer from ollama.com/download
Linux curl -fsSL https://ollama.com/install.sh \| sh (installs a systemd service)
Docker (NVIDIA GPU) docker run -d --gpus=all -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama

Check it works:

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

Everyday commands

ollama run gemma4:e4b                 # download if needed, then chat (type /bye to exit)
ollama run qwen3.5:9b "one-shot prompt"   # answer once and exit
ollama pull gpt-oss:20b               # download only
ollama list                           # installed models and sizes
ollama ps                             # loaded models, memory use, GPU/CPU split
ollama show qwen3.5:9b                # parameters, template, license, context length
ollama stop qwen3.5:9b                # unload from memory
ollama rm llama3.2:3b                 # delete from disk
ollama cp qwen3.5:9b my-assistant     # copy under a new name
ollama serve                          # run the server in the foreground (the app/service does this for you)

Inside an interactive ollama run session:

/set parameter num_ctx 16384     raise the context window for this session
/set system "Answer in French."  set a system prompt
/show info                       model details
/save my-variant                 save current settings as a new model
/bye                             exit

Run any GGUF from Hugging Face

ollama run hf.co/bartowski/Llama-3.2-3B-Instruct-GGUF            # picks Q4_K_M if present
ollama run hf.co/bartowski/Llama-3.2-3B-Instruct-GGUF:Q8_0       # choose a quantization

See Hugging Face’s Ollama integration docs for private repos and custom templates.

Customize a model with a Modelfile

# Modelfile
FROM qwen3.5:9b
PARAMETER num_ctx 16384
PARAMETER temperature 0.3
SYSTEM """You are a concise senior Python reviewer. Point out bugs first, then style."""
ollama create py-reviewer -f Modelfile
ollama run py-reviewer

Important settings (environment variables)

Variable Default What it does
OLLAMA_HOST 127.0.0.1:11434 Bind address. 0.0.0.0:11434 exposes it to your network (see security)
OLLAMA_CONTEXT_LENGTH 4096 tokens Default context window for all models
OLLAMA_MODELS ~/.ollama/models (macOS), /usr/share/ollama/.ollama/models (Linux service), C:\Users\<you>\.ollama\models (Windows) Where models are stored; point it at a bigger disk
OLLAMA_KEEP_ALIVE 5 minutes How long an idle model stays in memory (-1 keeps it loaded)
OLLAMA_FLASH_ATTENTION automatic 1 forces on, 0 off
OLLAMA_KV_CACHE_TYPE f16 q8_0 or q4_0 to shrink context memory
OLLAMA_NUM_PARALLEL backend-dependent Parallel requests per model
OLLAMA_MAX_LOADED_MODELS 3 per GPU (3 on CPU) How many models can stay loaded at once

How to set them (from the Ollama FAQ):

# macOS (then restart the Ollama app)
launchctl setenv OLLAMA_CONTEXT_LENGTH 16384

# Linux (systemd service)
sudo systemctl edit ollama.service
#   [Service]
#   Environment="OLLAMA_CONTEXT_LENGTH=16384"
sudo systemctl daemon-reload && sudo systemctl restart ollama

# Windows: quit Ollama, add the variable in Settings > System > About > Advanced system settings >
# Environment Variables (user variables), then start Ollama again.

Ollama’s API

curl http://localhost:11434/api/chat -d '{
  "model": "qwen3.5:9b",
  "messages": [{"role": "user", "content": "Why is the sky blue?"}],
  "stream": false,
  "options": {"num_ctx": 8192}
}'

OpenAI-compatible endpoint at http://localhost:11434/v1 (see Use local models from code). Full reference: docs.ollama.com/api.

Setup: LM Studio

  1. Download from lmstudio.ai (macOS, Windows, Linux) and open it once.
  2. Search for a model (for example “qwen” or “gemma”). LM Studio shows which quantizations fit your memory.
  3. On Apple Silicon, MLX versions of models are usually faster than GGUF; LM Studio offers both.
  4. Chat in the app, or start the local server in the Developer section.

The lms command-line tool ships with LM Studio (CLI docs):

lms get qwen3.5-9b          # download a model (search term)
lms ls                      # downloaded models
lms load <model>            # load into memory
lms ps                      # loaded models
lms server start            # OpenAI-compatible server (default examples use port 1234)
lms chat                    # chat in the terminal
lms unload --all
lms daemon up               # run headless without the GUI

Setup: llama.cpp

llama.cpp is the C/C++ engine behind much of the local ecosystem. It reached version 1.0 in November 2026 and now uses semantic versioning.

Install

brew install llama.cpp              # macOS and Linux (Homebrew)
winget install llama.cpp            # Windows
conda install -c conda-forge llama.cpp
# or download prebuilt binaries for CUDA, Vulkan, ROCm, Metal, CPU from the GitHub releases page

Build from source (NVIDIA example):

git clone https://github.com/ggml-org/llama.cpp && cd llama.cpp
cmake -B build -DGGML_CUDA=ON          # Metal is on by default on macOS; -DGGML_VULKAN=ON for Vulkan
cmake --build build --config Release -j

Run

# chat in the terminal, downloading a GGUF from Hugging Face (Q4_K_M by default if present)
llama-cli -hf ggml-org/gemma-3-1b-it-GGUF

# OpenAI-compatible server plus built-in web chat
llama-server -hf ggml-org/gemma-3-1b-it-GGUF -c 16384

# local file
llama-server -m ./models/qwen3.5-9b-Q4_K_M.gguf -c 16384 --host 127.0.0.1 --port 8080

Recent releases also provide a unified llama command (llama cli ..., llama serve ...). The server’s default port changed in the 1.x series; it prints the address it listens on at startup, and the examples here set --port explicitly to avoid surprises.

Key flags

Flag Meaning
-m FILE / -hf user/repo[:quant] local GGUF or Hugging Face repo
-c N context size (0 = model’s maximum)
-ngl N layers to put on the GPU: a number, auto (default) or all
-fa on\|off\|auto flash attention (default auto)
-ctk q8_0 -ctv q8_0 quantize the KV cache to save memory
-np N parallel slots for concurrent requests
--host, --port, --api-key networking and simple auth
--jinja Jinja chat templates (enabled by default; needed for tool calling on older builds)
-cmoe keep MoE expert weights on the CPU (run big MoE models on small GPUs)

Measure your hardware:

llama-bench -m ./models/qwen3.5-9b-Q4_K_M.gguf

Full flag list: server README. For converting and quantizing models yourself, see the GGUF quantization guide in this collection.

Setup: MLX on Apple Silicon

python3 -m venv .venv && source .venv/bin/activate
pip install mlx-lm

mlx_lm.generate --model mlx-community/Mistral-7B-Instruct-v0.3-4bit --prompt "hello"
mlx_lm.chat --model mlx-community/Mistral-7B-Instruct-v0.3-4bit
mlx_lm.server --model mlx-community/Mistral-7B-Instruct-v0.3-4bit     # OpenAI-style server
mlx_lm.convert --model mistralai/Mistral-7B-Instruct-v0.3 -q           # quantize a Hugging Face model to 4-bit MLX

Python:

from mlx_lm import load, generate

model, tokenizer = load("mlx-community/Mistral-7B-Instruct-v0.3-4bit")
messages = [{"role": "user", "content": "Write a haiku about unified memory"}]
prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True)
print(generate(model, tokenizer, prompt=prompt, max_tokens=100))

Ready-made MLX conversions live in the mlx-community organization on Hugging Face. Ollama and LM Studio also ship MLX variants of popular models on Macs (in Ollama, tags ending in -mlx).

Setup: vLLM and SGLang on Linux GPUs

Use these when several people or programs call the model at once. They are built for throughput, use safetensors (Hugging Face format) models, and expect a Linux machine with a supported GPU.

# vLLM (NVIDIA, with uv as in the official quickstart)
uv venv --seed && source .venv/bin/activate
uv pip install vllm --torch-backend=auto
vllm serve Qwen/Qwen2.5-1.5B-Instruct          # OpenAI-compatible API on http://localhost:8000/v1
from vllm import LLM, SamplingParams

llm = LLM(model="Qwen/Qwen2.5-1.5B-Instruct")
outputs = llm.chat([{"role": "user", "content": "Hello!"}], SamplingParams(max_tokens=64))
print(outputs[0].outputs[0].text)

See the vLLM quickstart for AMD, TPU and other platforms, and the SGLang docs for its server.

Add a chat UI: Open WebUI and others

Open WebUI gives you a ChatGPT-style interface with accounts, chat history, document upload and model switching, on top of Ollama or any OpenAI-compatible server.

docker run -d -p 3000:8080 --add-host=host.docker.internal:host-gateway \
  -v open-webui:/app/backend/data --name open-webui --restart always \
  ghcr.io/open-webui/open-webui:main
# open http://localhost:3000 and create the first (admin) account

Without Docker: pip install open-webui (Python 3.12) then open-webui serve, which listens on port 8080.

Other front ends: LM Studio and Jan include their own chat UI; llama.cpp’s server has a built-in web chat; many editors and note apps can talk to any OpenAI-compatible endpoint.

Which model should I run?

Method that survives new releases

  1. Start from your memory budget using the sizing tables.
  2. Pick the newest generation of a well-known family that fits. Newer small models often beat older models twice their size.
  3. Use Q4_K_M (or the tool’s default); move to Q5/Q6/Q8 only if you have spare memory.
  4. Check the capabilities you need: tool calling, vision, thinking (reasoning), long context. The Ollama library shows badges for each.
  5. Test on your own tasks with 10 to 20 real prompts. Benchmarks rarely match your use case.

Picks by memory (December 2026)

All tags are from the Ollama library; the same models are available as GGUF or MLX on Hugging Face for other tools.

Available memory General chat Coding Reasoning Vision
4 to 8 GB gemma4:e2b, qwen3.5:2b, qwen3.5:4b, llama3.2:3b qwen2.5-coder:3b qwen3:4b gemma4:e2b, qwen3-vl:4b
12 to 16 GB qwen3.5:9b, gemma4:e4b, gemma4:12b qwen2.5-coder:7b, qwen2.5-coder:14b deepseek-r1:8b, qwen3:14b gemma4:12b, qwen3-vl:8b
20 to 24 GB gemma4:26b (MoE), qwen3.6:27b, gpt-oss:20b qwen3-coder:30b (MoE) gpt-oss:20b, deepseek-r1:32b qwen3.6:27b, gemma4:31b
32 to 48 GB gemma4:31b, qwen3.6:35b, qwen3.5:35b qwen3-coder:30b at higher precision qwen3:32b qwen3-vl:32b
64 to 128 GB llama3.3:70b, qwen3.5:122b (large unified memory)   gpt-oss:120b  

Notes:

Embedding models for search and RAG

Model (Ollama tag) Sizes Notes
nomic-embed-text one size Very popular default for RAG with Ollama
qwen3-embedding 0.6b, 4b, 8b Multilingual; larger sizes for higher quality
bge-m3 567m Multilingual, long inputs
mxbai-embed-large 335m Strong English retrieval
all-minilm 22m, 33m Tiny and fast; good for prototypes
snowflake-arctic-embed 22m to 335m Range of sizes for retrieval

Use local models from code

Most local servers speak the OpenAI Chat Completions format, so the official OpenAI SDKs work by changing base_url.

Server base_url
Ollama http://localhost:11434/v1
LM Studio http://localhost:1234/v1
llama.cpp llama-server http://localhost:<port>/v1 (the port you started it with)
vLLM http://localhost:8000/v1
MLX mlx_lm.server http://localhost:<port>/v1

Python with the OpenAI SDK (pip install openai):

from openai import OpenAI

client = OpenAI(base_url="http://localhost:11434/v1", api_key="ollama")   # key is ignored but required
resp = client.chat.completions.create(
    model="qwen3.5:9b",
    messages=[{"role": "user", "content": "Give me three names for a hiking app."}],
)
print(resp.choices[0].message.content)

Python with the official Ollama library (pip install ollama):

from ollama import chat

response = chat(model="qwen3.5:9b", messages=[{"role": "user", "content": "Why is the sky blue?"}])
print(response.message.content)

JavaScript (npm i ollama):

import ollama from "ollama";

const response = await ollama.chat({
  model: "qwen3.5:9b",
  messages: [{ role: "user", content: "Why is the sky blue?" }],
});
console.log(response.message.content);

Streaming with plain HTTP (each line is a JSON object):

curl -N http://localhost:11434/api/generate -d '{"model": "qwen3.5:9b", "prompt": "Count to five."}'

Embeddings:

curl http://localhost:11434/api/embed -d '{"model": "nomic-embed-text", "input": ["first text", "second text"]}'

Tool calling works with models that have the “tools” badge, through either the native API or the OpenAI-compatible endpoint. Small models call tools less reliably than large ones; keep tool lists short and descriptions precise.

Local RAG: chat with your documents

The minimal pipeline, fully local:

documents → split into chunks → embed each chunk (embedding model) → store vectors
question  → embed → find nearest chunks → put them in the prompt → local chat model answers

A dependency-light example using Ollama’s embeddings and NumPy:

# pip install ollama numpy
import numpy as np
import ollama

docs = [
    "Our office is closed on public holidays.",
    "Refunds are processed within 10 business days.",
    "The VPN must be used on public Wi-Fi.",
]
emb = ollama.embed(model="nomic-embed-text", input=docs)["embeddings"]
D = np.array(emb)
D /= np.linalg.norm(D, axis=1, keepdims=True)

question = "How long does a refund take?"
q = np.array(ollama.embed(model="nomic-embed-text", input=[question])["embeddings"][0])
q /= np.linalg.norm(q)
best = [docs[i] for i in np.argsort(-(D @ q))[:2]]

prompt = "Answer using only these notes:\n" + "\n".join(f"- {b}" for b in best) + f"\n\nQuestion: {question}"
print(ollama.chat(model="qwen3.5:9b", messages=[{"role": "user", "content": prompt}]).message.content)

No-code options: Open WebUI and several desktop apps can index folders or uploaded files for document chat.

Local models for coding

Performance tuning

Goal What to do
Fit a bigger model Lower quantization (Q4_K_M → IQ4_XS or Q3_K_M), shorter context, quantized KV cache (OLLAMA_KV_CACHE_TYPE=q8_0, or -ctk q8_0 -ctv q8_0)
Faster generation Keep the whole model on the GPU (ollama ps should say 100% GPU), use a smaller or MoE model, close other GPU-heavy apps
Faster prompt reading GPU over CPU, flash attention on, larger batch sizes for long prompts
Longer conversations Raise context (num_ctx, -c) and budget memory for the KV cache
Avoid reload delays OLLAMA_KEEP_ALIVE=-1 or a longer duration
Serve several users OLLAMA_NUM_PARALLEL, llama.cpp -np, or vLLM/SGLang
Big MoE on a small GPU llama.cpp -cmoe (experts on CPU, attention on GPU)
More GPU memory on a Mac Recent macOS versions allow raising the GPU wired-memory limit with sudo sysctl iogpu.wired_limit_mb=<MB> (resets on reboot). Leave several GB for the system; use at your own risk
Consistent outputs Lower temperature, fixed seed ("options": {"seed": 42} in Ollama)

Measure before and after: ollama run <model> --verbose prints prompt and generation speed; llama-bench gives repeatable numbers.

Security and privacy checklist

Troubleshooting

Problem Likely cause Fix
Very slow, CPU fans spinning Model not on GPU, or does not fit ollama ps; choose a smaller model or quant; update GPU drivers
ollama ps shows a CPU/GPU split Model plus context too big for VRAM Smaller quant, shorter context, KV cache quantization
Model forgets the start of a long chat Context window too small (Ollama’s default is 4096 tokens) Raise num_ctx / OLLAMA_CONTEXT_LENGTH
Out of memory or crash when loading Not enough RAM/VRAM Smaller model; close other apps; on Linux check dmesg for OOM kills
connection refused on port 11434 Server not running Start the Ollama app or ollama serve; on Linux systemctl status ollama
Other devices cannot connect Server bound to localhost Set OLLAMA_HOST=0.0.0.0:11434 and allow it in the firewall, only on trusted networks
Docker container cannot reach Ollama on the host localhost inside a container is the container Use http://host.docker.internal:11434 with --add-host=host.docker.internal:host-gateway
Gibberish or endless output Wrong chat template in a custom GGUF Use a model from a known publisher or set the template; with llama.cpp keep Jinja templates on
Tool calls appear as plain text Model or template lacks tool support Pick a model with the “tools” badge
NVIDIA GPU not used on Linux Driver or container toolkit missing Install the NVIDIA driver; for Docker install the NVIDIA Container Toolkit and use --gpus=all
AMD GPU not used Unsupported ROCm target Check the tool’s GPU support docs; Vulkan builds of llama.cpp are an alternative
Disk filling up Many large models ollama list and ollama rm; move storage with OLLAMA_MODELS

FAQ

Can I run an LLM locally without a GPU? Yes. Small models (1B to 4B) run acceptably on modern CPUs, and 7B to 9B models are usable at a few tokens per second. Memory bandwidth matters more than core count.

How much RAM do I need to run a local LLM? 8 GB runs small models, 16 GB runs good 7B to 9B models, 32 GB runs strong 27B to 35B models at 4-bit, and 64 GB or more opens up 70B-class and large MoE models.

Is Ollama free? The Ollama app and local use are free and the code is MIT-licensed. Ollama also offers optional cloud models, which are a separate service.

Ollama vs LM Studio: which should I use? Ollama if you want a background service and API for apps and scripts; LM Studio if you prefer a graphical app for browsing and testing models. Both can run side by side, but they keep separate model downloads.

Ollama vs llama.cpp? llama.cpp is the engine and gives full control and the newest features first; Ollama wraps a similar engine with model management, a library and sensible defaults.

Can local models use the internet or tools? Only if the application you use gives them tools (web search, code execution). The model itself just generates text.

Are local models as good as ChatGPT or Claude? For many everyday tasks (summaries, drafting, simple code, extraction), good local models are close enough. For complex reasoning, large codebases and long agent tasks, frontier cloud models are still clearly ahead.

How do I run a model from Hugging Face in Ollama? ollama run hf.co/<user>/<repo> for any GGUF repo, optionally with :<quant>.

What do Q4_K_M, Q8_0 and similar names mean? They are GGUF quantization types: roughly the number of bits per weight and the method. Q4_K_M is the usual balance of size and quality; Q8_0 is near-lossless but twice the size.

Where are Ollama models stored and how do I move them? ~/.ollama/models on macOS, /usr/share/ollama/.ollama/models for the Linux service, C:\Users\<you>\.ollama\models on Windows. Set OLLAMA_MODELS to another folder and restart.

Can I fine-tune locally? Yes for small models: MLX-LM supports LoRA fine-tuning on Macs, and Hugging Face PEFT/TRL or Unsloth work on NVIDIA GPUs. Export to GGUF afterwards to run in Ollama or llama.cpp.

Is it legal to run these models? Running open-weight models is generally allowed under their licenses, but each license has its own terms (attribution, acceptable use, commercial thresholds). Read the license on the model page.

Glossary

Term Meaning
Open-weight model A model whose trained weights are downloadable
Parameters (7B, 70B) Number of weights, in billions
Quantization Storing weights with fewer bits to save memory
GGUF Single-file model format used by llama.cpp, Ollama, LM Studio and others
Q4_K_M A common 4-bit “k-quant” GGUF type, about 4.9 bits per weight on average
MLX Apple’s machine learning framework and model format for Apple Silicon
Context window Maximum tokens (prompt plus reply) the model can consider at once
KV cache Memory holding attention keys and values for the context
Offloading Putting some or all model layers on the GPU
MoE Mixture of Experts: many expert sub-networks, only a few used per token
Tokens per second Generation speed; one token is roughly three quarters of an English word
Prefill Processing the prompt before generation starts
OpenAI-compatible API An HTTP API that mimics OpenAI’s endpoints so existing SDKs work

Where to go next

Contributing

PRs are welcome: corrections, new tools, verified hardware speed reports (include the exact model file, quantization, context size, tool version and command), and better model picks. Every link must point to an official or primary source, and every command should be one you ran. Local AI changes monthly, so date-sensitive claims should say when they were checked.

If this guide helped you get a model running, a star helps others find it.

More free resources

Part of the Ralpberry Labs open-source collection. See also Top 100 Open Source.