惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

AWS News Blog
AWS News Blog
F
Fortinet All Blogs
T
The Blog of Author Tim Ferriss
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
A
About on SuperTechFans
WordPress大学
WordPress大学
MongoDB | Blog
MongoDB | Blog
T
Tailwind CSS Blog
美团技术团队
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Security Blog
Microsoft Security Blog
GbyAI
GbyAI
U
Unit 42
有赞技术团队
有赞技术团队
G
GRAHAM CLULEY
Scott Helme
Scott Helme
小众软件
小众软件
T
Threatpost
S
Securelist
SecWiki News
SecWiki News
Recent Announcements
Recent Announcements
L
LINUX DO - 最新话题
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
罗磊的独立博客
Y
Y Combinator Blog
aimingoo的专栏
aimingoo的专栏
Security Latest
Security Latest
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
AI
AI
Schneier on Security
Schneier on Security
博客园 - 叶小钗
The GitHub Blog
The GitHub Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Google DeepMind News
Google DeepMind News
M
MIT News - Artificial intelligence
B
Blog RSS Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
爱范儿
爱范儿
S
Secure Thoughts
博客园 - 聂微东
The Hacker News
The Hacker News
Stack Overflow Blog
Stack Overflow Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Cloudbric
Cloudbric
V
V2EX
Attack and Defense Labs
Attack and Defense Labs
宝玉的分享
宝玉的分享
Vercel News
Vercel News

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Running Local LLMs With Ollama For Private Development
Nazar Boyko · 2026-06-16 · via DEV Community

Here's a thing that catches almost everyone the first week they run a model locally. You paste a 600-line file into your shiny new local assistant, ask it to find the bug, and it confidently rewrites a function that isn't even in the part it read. No error. No warning. It just... silently dropped most of your file on the floor before the model ever saw it.

That's not the model being dumb. That's Ollama doing exactly what it was told. By default it gives every model a context window of 2048 tokens and quietly truncates anything past that. It's one of a handful of small surprises that separate "I installed Ollama" from "I actually understand what's running on my machine." Let's go through the ones that matter: how the thing works under the hood, what hardware you really need, the gotchas, and the honest answer to "should I even bother instead of just calling an API?"

What Ollama actually is

Ollama gets described as "Docker for LLMs," and that's a decent first approximation. You pull a model, you run it, there's a registry. But it hides what's doing the heavy lifting. Underneath, Ollama is a friendly wrapper around llama.cpp, the C/C++ inference engine that made running these models on consumer hardware practical in the first place. When you type ollama run, you're really booting a llama.cpp runtime with a sane default config and a tidy HTTP server bolted on.

The models it runs are in a format called GGUF (GPT-Generated Unified Format). A GGUF file isn't just weights. It's a self-contained package that bundles the tensors, the tokenizer config, the architecture details, and hyperparameters like the trained context length, all in one file. That's why ollama pull llama3.1 gives you something that just works: everything the runtime needs to reconstruct the model is in the box.

Ollama itself is young. The project shipped its first release in early July 2023, and it rode the wave of open-weight models (Llama 2 landed that same month) that suddenly made "run a real LLM on your laptop" a thing normal developers could do. Before that, local inference meant compiling things and reading a lot of GitHub issues. Ollama's whole pitch is removing that friction.

The hardware math nobody explains up front

The number that decides whether a model runs well on your machine isn't its parameter count. It's how much memory the weights occupy after quantization. This is the single most important concept for running models locally, so it's worth slowing down for.

A model's weights are originally stored in 16-bit floating point. Quantization squeezes them down to a lower precision, commonly 4-bit integers, which shrinks the file and, just as importantly, eases the memory-bandwidth pressure that bottlenecks inference. The format you'll see by default in Ollama is Q4_K_M, part of llama.cpp's "K-quant" family. The trade is genuinely good: Q4_K_M cuts memory use by roughly 75% versus the 16-bit original while losing well under 1% of quality on most benchmarks. That's not a free lunch exactly, but it's close enough that most people never run anything else.

Here's the rule of thumb that actually helps you size hardware: budget about 0.6 GB per billion parameters at Q4_K_M, then add headroom for context. So:

Model size Q4_K_M footprint Fits comfortably on
7B ~4-6 GB 8 GB GPU, or any M-series Mac
13B ~8-10 GB 12 GB GPU
32B ~22-24 GB RTX 4090 (24 GB)
70B ~38-48 GB 2x 24 GB GPUs, or a 64 GB Mac

The memory you want this to live in is VRAM, your GPU's memory, because that's where inference is fast. If the model doesn't fit in VRAM, Ollama will happily run it on the CPU using system RAM instead, and it'll work, just slowly. On Apple Silicon the line blurs in a nice way: unified memory means the GPU and CPU share one pool, so a 64 GB Mac can run models that would need multiple discrete GPUs on a PC.

A comparison of one 7B model at FP16, Q8_0, Q5_K_M and Q4_K_M, with memory footprint shrinking from about 14 GB to about 4 GB and Q4_K_M noted as under 1 percent quality loss.

What does this buy you in speed? Be realistic about it. On CPU-only inference you're looking at roughly 10-25 tokens per second, usable for short answers, painful for long ones. Put the same model fully on a decent GPU and you jump to 40-80+ tokens/sec; an RTX 4090 can hit 130-160 tokens/sec, which is in the same league as a cloud API. The hardware is the whole game here. A local model on the wrong hardware isn't a cheaper API, it's a worse one.

The silent context-window trap

Back to the gotcha from the opener, because it's the one that wastes the most hours. Ollama defaults num_ctx, the context window, to 2048 tokens for every model, regardless of what that model was actually trained to handle. Llama 3.1 supports 128k tokens of context; out of the box, Ollama gives it 2048.

This default is deliberate, not a bug. It lets Ollama boot any model instantly on any hardware, including an 8 GB laptop, without forcing you to calculate your memory budget first. The problem is what happens when you exceed it: Ollama silently clips the input. No error, no warning. The tokens past your limit simply never reach the model. If you've ever fed a local model a big file and watched it "forget" the beginning, this is almost always why.

You fix it in one of two places. For a one-off, pass num_ctx in the request options:

Per-request override

curl http://localhost:11434/api/generate -d '{
  "model": "llama3.1",
  "prompt": "Summarize this file...",
  "options": { "num_ctx": 16384 }
}'

For a permanent per-model default, bake it into a Modelfile and create your own variant:

Modelfile

FROM llama3.1
PARAMETER num_ctx 16384

Build it once

ollama create llama3.1-16k -f Modelfile
ollama run llama3.1-16k

But there's a cost, and it's not optional: the context window lives in the KV cache, and that grows linearly with num_ctx. Bumping a 7B model to a 32k window can add around 6 GB of VRAM on top of the weights. So context length isn't a free dial you crank to maximum. It competes directly with the model for the same memory. Pick the smallest window that fits your actual workload.

Warning
The 2048 default plus silent truncation is the single most common reason people conclude "local models are dumb." They're usually not. They're just being shown a fraction of the input. Check your num_ctx before you blame the model.

Wiring it into your editor

The reason most developers reach for this in the first place is a private coding assistant: autocomplete and chat that never sends a line of your code anywhere. Ollama exposes a local HTTP API on port 11434, and editor extensions like Continue talk to it directly. Your code goes from your editor, to a process on your own machine, and back. Nothing crosses the network.

The wiring is small. Point your Continue config at the local model:

Continue config (shape may vary by version)

{
  "models": [
    {
      "title": "Llama 3.1 8B (local)",
      "provider": "ollama",
      "model": "llama3.1:8b"
    }
  ]
}

That's the whole privacy story, and it's a real one: with the model pulled, you can pull the ethernet cable out and it keeps working. Ollama doesn't phone home during normal inference: no telemetry upload, no cloud sync, no prompts shipped to a third party. The model files sit on your disk until you delete them, and only the initial ollama pull needs the internet. For anyone working under HIPAA, PCI-DSS, or GDPR data-residency rules, that's not a nice-to-have. It's frequently the only arrangement that's even allowed, because no amount of vendor paperwork beats the data physically never leaving your machine.

An architecture diagram showing the editor, Ollama on port 11434, and the local GGUF model all inside a 'your machine' boundary, with the connection to a cloud API crossed out in red.

The memory-management gotcha

One more behavior worth knowing before it confuses you. After you finish a request, Ollama keeps the model loaded in VRAM for 5 minutes by default, so your next prompt answers instantly instead of paying the load cost again. Handy, until you're trying to run a second large model and discover the first one is still squatting on your GPU memory.

You control this with keep_alive. Set it to 0 to unload the moment a response finishes, or to something like "24h" to pin a model in memory all day:

Unload immediately after responding

curl http://localhost:11434/api/generate -d '{
  "model": "llama3.1",
  "prompt": "quick question",
  "keep_alive": 0
}'

You can check what's currently resident with ollama ps and evict a model by hand with ollama stop. If you're juggling several models on a memory-tight machine, managing keep_alive is the difference between smooth switching and constant out-of-memory errors.

When local actually beats an API

Now the honest part, because the answer isn't "always." Running locally is a real engineering trade, and plenty of the time the cloud is just the better call.

Cost is the trap people get wrong in both directions. The rough crossover: under about 1M tokens a day, a cloud API is usually cheaper once you account for the hardware you'd have to buy and run. Past roughly 5M tokens a day, owning the hardware starts paying for itself. Below that line, a $1,600 GPU sitting mostly idle is a worse deal than per-token pricing. Buying a 4090 to occasionally autocomplete is a hobby, not a saving.

Latency can favor local, especially for short, frequent calls where the network round-trip dominates. But only if your hardware keeps up. Remember the numbers: a top GPU matches cloud throughput, CPU-only inference is 4-10x slower. Local isn't automatically faster. It's faster when the GPU is there.

Capability still favors the cloud at the top end. The biggest frontier models you reach through an API are stronger than anything you'll fit on a single machine. For routine work (autocomplete, summarizing, boilerplate, straightforward refactors) a good local 8B or 32B model is more than enough. For genuinely hard reasoning, the gap is still real.

Privacy and compliance is where local stops being a preference and becomes a requirement. If your data legally can't leave a boundary (patient records, payment data, regulated EU data) then keeping inference on hardware you control isn't a tradeoff, it's the entire point. No enterprise agreement substitutes for the data simply never being transmitted.

The pattern a lot of teams land on isn't all-or-nothing. It's a blend: local models for the private, high-volume, latency-sensitive, offline work, and a cloud API for the occasional heavy request that needs the strongest model available. You don't have to pick a side. You have to know which job each tool is actually good at.

So start small. Pull an 8B model, point your editor at it, write some real code through it for a week, and watch your token meter not move. Then decide what's worth keeping local, now that you know what's actually running on your machine, and why.


Originally published at nazarboyko.com.