Article · Local LLMs · LLM fundamentals
Local language models: Ollama, llama.cpp, vLLM, quantization and the real trade-offs
How to run an open model on your own hardware, how much memory it really needs, what quantization and GGUF are, where generation speed comes from and when a local model makes sense instead of an API. Code in Python, TypeScript and C#.
A cloud model is one HTTP call to someone else's server. A local model is a weights file on your disk, an inference server on your hardware and data that never leaves the building. Open models (Llama, Qwen, Gemma, Mistral, DeepSeek and others) have caught up in many tasks with commercial models from a year or two ago – and tools like Ollama have made running them a matter of minutes, not days.
- ~5 GB
- of weights for an 8B model in Q4_K_M – instead of about 16 GB in FP16
- 11434
- Ollama's default port – with an OpenAI-compatible endpoint under /v1
- ~4×
- less memory for weights – after quantizing from 16 to about 4 bits
The problem: complaints full of personal data
Halina's Pierogi receives several hundred complaints a day. Each contains an address, a phone number, sometimes a name and a description of a health problem ("after the meat pierogi I had an allergic reaction"). Management wants automatic classification and summaries, but the legal team sets a condition: customer data must not go to an external provider without a data-processing agreement and a risk assessment. The second idea – a kitchen tablet that answers questions about recipes – has to work even when the internet goes down on a Friday evening.
Both cases have one thing in common: the model has to run on our side. Let's see what that means in practice.
The ecosystem in a nutshell
| Tool | What for | Model format | When to choose it |
|---|---|---|---|
| Ollama | the simplest way to run models on a laptop or server | GGUF (model library via ollama pull) | getting started, prototypes, small teams, offline work |
llama.cpp (llama-server) | a C/C++ inference engine, CPU, Metal, CUDA, Vulkan | GGUF | full control, edge devices, embedding in an application |
| LM Studio | a desktop app with a GUI | GGUF, MLX | experimenting without a terminal |
| vLLM | a high-throughput GPU server (continuous batching, PagedAttention) | safetensors, AWQ, GPTQ, FP8 | many concurrent users, production on GPUs |
| MLX / mlx-lm | inference and fine-tuning on Apple Silicon | MLX | a Mac as a workstation |
Apart from the GUI-only app, all of them expose an endpoint compatible with the OpenAI API – you can change base_url in existing code and nothing else.
Starting a model server
# Install from ollama.com, then pull a quantized model (GGUF, Q4_K_M by default for most tags)
ollama pull llama3.1:8b
ollama run llama3.1:8b "Classify: 'pierogi arrived cold'" # quick test in the terminal
# The server listens on localhost:11434 - native API and an OpenAI-compatible /v1 endpoint
curl http://localhost:11434/v1/chat/completions -H "Content-Type: application/json" \
-d '{"model": "llama3.1:8b", "messages": [{"role": "user", "content": "Hello"}]}'# llama.cpp: one binary, GGUF files, CPU / Apple Metal / CUDA / Vulkan back-ends
# -hf downloads a GGUF from Hugging Face, -c sets the context window, -ngl offloads layers to the GPU
llama-server -hf ggml-org/gemma-3-4b-it-GGUF -c 8192 -ngl 99 --port 8080
# OpenAI-compatible endpoint: http://localhost:8080/v1/chat/completions# vLLM: high-throughput GPU server (continuous batching, PagedAttention) for many concurrent users
pip install vllm
vllm serve Qwen/Qwen2.5-7B-Instruct --max-model-len 8192 --api-key "$LOCAL_LLM_KEY"
# OpenAI-compatible endpoint: http://localhost:8000/v1 (requires the API key above)How much memory you need: weights and the KV cache
A simple rule: weight size ≈ number of parameters × bits per parameter ÷ 8. An 8B model in FP16 (16 bits) is about 16 GB, in 8 bits about 8.5 GB, and in the popular Q4_K_M quantization (about 4.8 bits on average) about 5 GB. On top of that comes the KV cache: for every token in the context the model stores the attention keys and values from every layer. With a long context it can take several gigabytes more – which is why the same 8B model that fits in 8 GB of VRAM with short prompts may no longer fit with 32 thousand tokens of context.
| FP16 | Q8_0 | Q4_K_M | |
|---|---|---|---|
| 8B | 16 GB | 8.5 GB | 4.9 GB |
| 14B | 28 GB | 14.9 GB | 8.5 GB |
| 32B | 64 GB | 34 GB | 19.4 GB |
| 70B | 140 GB | 74.4 GB | 42.4 GB |
Quantization: fewer bits, almost the same quality
Quantization stores weights at lower precision – instead of a 16-bit floating-point number, for example a 4-bit integer plus a shared scale factor for a block of weights. The GGUF format (llama.cpp, Ollama) offers variants labelled Q8_0, Q6_K, Q5_K_M, Q4_K_M: the number is bits per weight, K denotes the so-called k-quants with smarter block splitting, and S/M/L says how many of the more important tensors get higher precision. For GPU servers, AWQ, GPTQ and FP8 are popular.
The rest of this article is for members
Create a free account or sign in to read it all. Still ahead:
- Where speed comes from: memory bandwidth
- Code: the same client, a different address
- Local or cloud?
- Checklist
- Test yourself
- What's next