{"id":"6b08c24f38c84264c20274b4","slug":"local-llms","title":"Local language models: Ollama, llama.cpp, vLLM, quantization and the real trade-offs","summary":"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#.","servedLang":"en","availableLangs":["pl","en"],"topics":["local-llms","llm-fundamentals","llm-ops","fine-tuning"],"techs":["python","typescript","dotnet"],"tags":["local-llm","ollama","llama-cpp","vllm","gguf","quantization","open-weights","privacy"],"level":"intermediate","kind":"article","access":"members","status":"published","cover":null,"author":{"id":"6b08bd2e80884893657cc8cf","name":"Redakcja Art of Devs","avatar":null,"handle":"redakcja","community":false},"readingMinutes":12,"stats":{"views":2,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-26T23:35:43.196Z","updatedAt":"2026-11-27T13:10:24.095Z","requestedLang":"en","theme":{"hero":"classic","heroMedia":null,"accent":"rose","background":"grid","weaveResources":true,"toc":"right"},"seoDescription":"Local LLMs in practice: Ollama, llama.cpp and vLLM, Q4_K_M quantization and GGUF, memory and bandwidth, OpenAI-compatible APIs, local structured outputs, and when to choose local over the cloud.","wordCount":2371,"doc":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"A cloud model is one HTTP call to someone else's server. A "},{"type":"text","text":"local model","marks":[{"type":"bold"}]},{"type":"text","text":" 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."}]},{"type":"stats","attrs":{"items":[{"value":"~5 GB","label":"of weights for an 8B model in Q4_K_M","hint":"instead of about 16 GB in FP16"},{"value":"11434","label":"Ollama's default port","hint":"with an OpenAI-compatible endpoint under /v1"},{"value":"~4×","label":"less memory for weights","hint":"after quantizing from 16 to about 4 bits"}]}},{"type":"callout","attrs":{"variant":"info","title":"TL;DR"},"content":[{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"To run a model you need "},{"type":"text","text":"memory for the weights","marks":[{"type":"bold"}]},{"type":"text","text":" (parameters × bits per parameter) and for the "},{"type":"text","text":"KV cache","marks":[{"type":"bold"}]},{"type":"text","text":", which grows with the context. Quantizing to 4 bits shrinks the weights roughly fourfold at the cost of a small loss in quality."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Ollama and llama.cpp are the simplest path for a laptop or a server without many users; vLLM is a GPU server for high concurrency. All of them expose an "},{"type":"text","text":"OpenAI-compatible API","marks":[{"type":"bold"}]},{"type":"text","text":"."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"A local model wins on privacy, offline operation and predictable cost at high volume; it loses on quality in hard tasks and on maintenance cost."}]}]}]}]},{"type":"heading","attrs":{"level":2,"id":"the-problem-complaints-full-of-personal-data"},"content":[{"type":"text","text":"The problem: complaints full of personal data"}]},{"type":"paragraph","content":[{"type":"text","text":"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."}]},{"type":"paragraph","content":[{"type":"text","text":"Both cases have one thing in common: "},{"type":"text","text":"the model has to run on our side","marks":[{"type":"bold"}]},{"type":"text","text":". Let's see what that means in practice."}]},{"type":"heading","attrs":{"level":2,"id":"the-ecosystem-in-a-nutshell"},"content":[{"type":"text","text":"The ecosystem in a nutshell"}]},{"type":"table","content":[{"type":"tableRow","content":[{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Tool"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"What for"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Model format"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"When to choose it"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Ollama"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"the simplest way to run models on a laptop or server"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"GGUF (model library via "},{"type":"text","text":"ollama pull","marks":[{"type":"code"}]},{"type":"text","text":")"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"getting started, prototypes, small teams, offline work"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"llama.cpp ("},{"type":"text","text":"llama-server","marks":[{"type":"code"}]},{"type":"text","text":")"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"a C/C++ inference engine, CPU, Metal, CUDA, Vulkan"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"GGUF"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"full control, edge devices, embedding in an application"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"LM Studio"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"a desktop app with a GUI"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"GGUF, MLX"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"experimenting without a terminal"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"vLLM"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"a high-throughput GPU server (continuous batching, PagedAttention)"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"safetensors, AWQ, GPTQ, FP8"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"many concurrent users, production on GPUs"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"MLX / mlx-lm"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"inference and fine-tuning on Apple Silicon"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"MLX"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"a Mac as a workstation"}]}]}]}]},{"type":"paragraph","content":[{"type":"text","text":"Apart from the GUI-only app, all of them expose an endpoint compatible with the OpenAI API – you can change "},{"type":"text","text":"base_url","marks":[{"type":"code"}]},{"type":"text","text":" in existing code and nothing else."}]},{"type":"codeGroup","attrs":{"title":"Starting a model server"},"content":[{"type":"codeBlock","attrs":{"language":"bash","filename":"ollama.sh"},"content":[{"type":"text","text":"# Install from ollama.com, then pull a quantized model (GGUF, Q4_K_M by default for most tags)\nollama pull llama3.1:8b\nollama run llama3.1:8b \"Classify: 'pierogi arrived cold'\"   # quick test in the terminal\n\n# The server listens on localhost:11434 - native API and an OpenAI-compatible /v1 endpoint\ncurl http://localhost:11434/v1/chat/completions -H \"Content-Type: application/json\" \\\n  -d '{\"model\": \"llama3.1:8b\", \"messages\": [{\"role\": \"user\", \"content\": \"Hello\"}]}'"}]},{"type":"codeBlock","attrs":{"language":"bash","filename":"llama-server.sh"},"content":[{"type":"text","text":"# llama.cpp: one binary, GGUF files, CPU / Apple Metal / CUDA / Vulkan back-ends\n# -hf downloads a GGUF from Hugging Face, -c sets the context window, -ngl offloads layers to the GPU\nllama-server -hf ggml-org/gemma-3-4b-it-GGUF -c 8192 -ngl 99 --port 8080\n\n# OpenAI-compatible endpoint: http://localhost:8080/v1/chat/completions"}]},{"type":"codeBlock","attrs":{"language":"bash","filename":"vllm.sh"},"content":[{"type":"text","text":"# vLLM: high-throughput GPU server (continuous batching, PagedAttention) for many concurrent users\npip install vllm\nvllm serve Qwen/Qwen2.5-7B-Instruct --max-model-len 8192 --api-key \"$LOCAL_LLM_KEY\"\n\n# OpenAI-compatible endpoint: http://localhost:8000/v1 (requires the API key above)"}]}]},{"type":"heading","attrs":{"level":2,"id":"how-much-memory-you-need-weights-and-the-kv-cache"},"content":[{"type":"text","text":"How much memory you need: weights and the KV cache"}]},{"type":"paragraph","content":[{"type":"text","text":"A simple rule: "},{"type":"text","text":"weight size ≈ number of parameters × bits per parameter ÷ 8","marks":[{"type":"bold"}]},{"type":"text","text":". 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 "},{"type":"text","text":"KV cache","marks":[{"type":"bold"}]},{"type":"text","text":": 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."}]},{"type":"chart","attrs":{"type":"bar","title":"Approximate size of the model weights alone by quantization","caption":"Calculation: parameters × bits ÷ 8 (FP16 = 16 bits, Q8_0 ≈ 8.5, Q4_K_M ≈ 4.85). Without the KV cache and engine overhead – real usage is higher.","unit":"GB","data":{"labels":["8B","14B","32B","70B"],"series":[{"name":"FP16","values":[16,28,64,140]},{"name":"Q8_0","values":[8.5,14.9,34,74.4]},{"name":"Q4_K_M","values":[4.9,8.5,19.4,42.4]}]}}},{"type":"heading","attrs":{"level":3,"id":"quantization-fewer-bits-almost-the-same-quality"},"content":[{"type":"text","text":"Quantization: fewer bits, almost the same quality"}]},{"type":"paragraph","content":[{"type":"text","text":"Quantization","marks":[{"type":"bold"}]},{"type":"text","text":" 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 "},{"type":"text","text":"GGUF","marks":[{"type":"bold"}]},{"type":"text","text":" format (llama.cpp, Ollama) offers variants labelled "},{"type":"text","text":"Q8_0","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"Q6_K","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"Q5_K_M","marks":[{"type":"code"}]},{"type":"text","text":", "},{"type":"text","text":"Q4_K_M","marks":[{"type":"code"}]},{"type":"text","text":": the number is bits per weight, "},{"type":"text","text":"K","marks":[{"type":"code"}]},{"type":"text","text":" denotes the so-called k-quants with smarter block splitting, and "},{"type":"text","text":"S/M/L","marks":[{"type":"code"}]},{"type":"text","text":" says how many of the more important tensors get higher precision. For GPU servers, AWQ, GPTQ and FP8 are popular."}]}]},"toc":[{"id":"the-problem-complaints-full-of-personal-data","text":"The problem: complaints full of personal data","level":2,"locked":false},{"id":"the-ecosystem-in-a-nutshell","text":"The ecosystem in a nutshell","level":2,"locked":false},{"id":"how-much-memory-you-need-weights-and-the-kv-cache","text":"How much memory you need: weights and the KV cache","level":2,"locked":false},{"id":"quantization-fewer-bits-almost-the-same-quality","text":"Quantization: fewer bits, almost the same quality","level":3,"locked":false},{"id":"where-speed-comes-from-memory-bandwidth","text":"Where speed comes from: memory bandwidth","level":2,"locked":true},{"id":"code-the-same-client-a-different-address","text":"Code: the same client, a different address","level":2,"locked":true},{"id":"local-or-cloud","text":"Local or cloud?","level":2,"locked":true},{"id":"checklist","text":"Checklist","level":2,"locked":true},{"id":"test-yourself","text":"Test yourself","level":2,"locked":true},{"id":"what-s-next","text":"What's next","level":2,"locked":true}],"locked":true,"paywall":null,"previewRatio":0.3,"totalBlocks":43,"visibleBlocks":15,"resources":[{"id":"6b0857c73c96f2d34d0b4979","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=il0dgxjpoC0","embedUrl":"https://www.youtube-nocookie.com/embed/il0dgxjpoC0","title":"Local AI 301: Quantization","description":"Learn about quantization in this livestream and get started with quantization using llama.cpp and vLLM. Program: - Introduction to Quantization, Merve Noyan, Hugging Face - Calibration based quantization, Colin Kealty (aka bartowski), RedHat - Quantization Aware Distillation, Maxime Labonne…","author":"Hugging Face","thumbnailUrl":"https://i.ytimg.com/vi/il0dgxjpoC0/hqdefault.jpg","durationSec":null,"lang":"en","topics":["fine-tuning","llm-ops","local-llms"],"techs":["general"],"tags":["ai"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"youtube-rss","publishedAt":"2026-11-11T06:39:06.000Z","popularity":63,"verifiedAt":"2026-11-26T10:58:31.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:10.095Z","updatedAt":"2026-11-26T16:01:10.095Z"},{"id":"6b0857b53c96f2d34d0b38f1","type":"article","provider":"web","url":"https://ollama.com/blog/structured-outputs","embedUrl":null,"title":"Structured Outputs with Ollama","description":"Ollama now supports structured outputs making it possible to constrain a model's output to a specific format defined by a JSON schema. The Ollama Python and JavaScript libraries have been updated to support structured outputs.","author":"ollama.com","thumbnailUrl":"https://ollama.com/public/og.png","durationSec":null,"lang":"en","topics":["tool-use","local-llms","ai-in-node","ai-in-python"],"techs":["javascript","python"],"tags":["ai","hacker-news"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"hn","publishedAt":"2024-12-07T01:12:32.000Z","popularity":70,"verifiedAt":"2026-11-26T11:19:30.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:52.228Z","updatedAt":"2026-11-26T16:00:52.228Z"},{"id":"6b0857b43c96f2d34d0b3879","type":"article","provider":"web","url":"https://steelph0enix.github.io/posts/llama-cpp-guide","embedUrl":null,"title":"Llama.cpp guide – Running LLMs locally on any hardware, from scratch","description":"Psst, kid, want some cheap and small LLMs?","author":"steelph0enix.github.io","thumbnailUrl":"https://steelph0enix.github.io/og-image.png","durationSec":null,"lang":"en","topics":["local-llms"],"techs":["general"],"tags":["llm","ai","hacker-news"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"hn","publishedAt":"2024-11-29T15:28:34.000Z","popularity":74,"verifiedAt":"2026-11-26T11:19:30.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:52.228Z","updatedAt":"2026-11-26T16:00:52.228Z"},{"id":"6b0857c03c96f2d34d0b4359","type":"article","provider":"web","url":"https://docs.vllm.ai/en/latest","embedUrl":null,"title":"vLLM","description":"","author":"vLLM","thumbnailUrl":null,"durationSec":null,"lang":"en","topics":["llm-ops","local-llms"],"techs":["general"],"tags":["ai"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":55,"verifiedAt":"2026-11-26T11:26:44.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"},{"id":"6b0857b53c96f2d34d0b39c4","type":"article","provider":"web","url":"https://blogs.cisco.com/security/detecting-exposed-llm-servers-shodan-case-study-on-ollama","embedUrl":null,"title":"Finding thousands of exposed Ollama instances using Shodan","description":"We uncovered 1,100+ exposed Ollama LLM servers—20% with open models—revealing critical security gaps and the need for better LLM threat monitoring.","author":"Giannis Tziakouris, Elio Biasiotto","thumbnailUrl":"https://blogs.cisco.com/gcs/ciscoblogs/1/2025/08/FY26_Q1_detecting-exposed-llm-servers-shodan-case-study-on-ollama_blog_fb_social_card.jpeg","durationSec":null,"lang":"en","topics":["local-llms"],"techs":["general"],"tags":["security","llm","ai","observability","hacker-news"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"hn","publishedAt":"2025-09-03T08:18:07.000Z","popularity":64,"verifiedAt":"2026-11-26T11:19:30.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:52.228Z","updatedAt":"2026-11-26T16:00:52.228Z"},{"id":"6b0857bf3c96f2d34d0b42cb","type":"article","provider":"web","url":"https://ollama.com/library","embedUrl":null,"title":"library","description":"Browse Ollama's library of models.","author":"Ollama","thumbnailUrl":"https://ollama.com/public/og.png","durationSec":null,"lang":"en","topics":["local-llms"],"techs":["general"],"tags":["ai"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":60,"verifiedAt":"2026-11-26T11:26:44.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"}],"challenges":[],"attachments":[],"hasCode":true,"repoUrl":null,"series":[{"slug":"ai-path","title":"AI for developers","items":[{"slug":"llm-fundamentals","title":"LLM fundamentals: tokens, context windows and next-token prediction","current":false},{"slug":"prompt-engineering","title":"Prompt engineering: writing instructions a model will actually follow","current":false},{"slug":"embeddings-vector-db","title":"Embeddings and vector databases: searching by meaning","current":false},{"slug":"rag","title":"RAG: answers grounded in your own documents","current":false},{"slug":"tool-use","title":"Tool use: how a language model calls your application's functions","current":false},{"slug":"ai-agents","title":"AI agents: a model in a loop with tools – and when a plain workflow is enough","current":false},{"slug":"mcp","title":"MCP (Model Context Protocol): one standard for connecting AI to tools and data","current":false},{"slug":"evals","title":"Evaluating LLM applications (evals): tests for systems that are not deterministic","current":false},{"slug":"llm-ops","title":"LLMOps: model gateways, caching, limits, observability and costs in production","current":false},{"slug":"ai-guardrails","title":"Guardrails and security for LLM applications: prompt injection, data leaks and tool permissions","current":false},{"slug":"local-llms","title":"Local language models: Ollama, llama.cpp, vLLM, quantization and the real trade-offs","current":true},{"slug":"fine-tuning","title":"Fine-tuning language models: when it pays off, LoRA and QLoRA in practice","current":false},{"slug":"ai-coding-assistants","title":"AI coding assistants: from editor suggestions to an agent that opens pull requests","current":false}]}],"prev":{"slug":"ai-guardrails","title":"Guardrails and security for LLM applications: prompt injection, data leaks and tool permissions"},"next":{"slug":"fine-tuning","title":"Fine-tuning language models: when it pays off, LoRA and QLoRA in practice"},"featured":false,"authorCard":{"id":"6b08bd2e80884893657cc8cf","name":"Redakcja Art of Devs","avatar":null,"handle":"redakcja","headline":"Wzorce projektowe · Architektura · AI i LLM","community":false,"reputation":{"points":3900,"level":{"key":"mentor","label":"Mentor"}},"articles":68,"skills":[{"key":"typescript","title":"TypeScript","level":5,"levelLabel":"Authority","articles":63},{"key":"dotnet","title":".NET","level":5,"levelLabel":"Authority","articles":53},{"key":"python","title":"Python","level":5,"levelLabel":"Authority","articles":52},{"key":"java","title":"Java","level":5,"levelLabel":"Authority","articles":38}]}}