so i've been running local models on my mac mini for coding agents for a while now, mostly through ollama. it works, but there's always been this gap where i'd end up switching to claude for anything complex because the local stuff just felt too slow for interactive use. stumbled on rapid-mlx last w...
I wrote a comprehensive guide on AnythingLLM - an open-source AI platform that works great with local LLMs. Key highlights for local LLM users: ๐ฆ Native Ollama integration ๐ฅ๏ธ Desktop app (no Docker required) ๐ Built-in RAG - chat with your documents locally ๐ Works with LM Studio, LocalAI, Kobold...
been running coding agents on a few repos lately and kept watching them burn through tokens just to answer "who calls this function" or "what's the impact of changing X". got annoying fast. found this tool called codebase-memory-mcp - it's a single binary that indexes your codebase into a knowledge...
so i've been running claude code locally for a while now and the one thing that's been driving me up a wall is the sheer verbosity. every response starts with "sure, i'd be happy to help" and a paragraph of setup before actually doing anything. when you're paying attention to token usage โ especiall...
so i've been fighting with ai coding agents for a while now trying to get them to generate uis that actually match my design system. telling claude "use the brand colors" is useless when it has no idea what those are. screenshots help but still get weird approximations. came across google labs' desi...
64K is workable if you stop treating the context like a chat log. What made agent work with small models usable for me on a 24GB card:
Hard scope per session. One task, one module. Fresh session for the next task instead of dragging the history along. Cloud models paper over sprawling context, local ones don't.
Instructions as short files pulled in on demand, not one giant system prompt. My AGENTS.md is under 500 words and tool-specific rules live in separate files the agent reads only when the task touches them. Most "hand holding" tokens are spent on tasks that never needed them.
Compact before the wall, not at it. Around 40K I have the agent write a handoff note (done, remaining, file paths, decisions) and restart from that. Letting the runtime auto-truncate at 64K is exactly where things get forgotten.
Trim tool output. grep with line limits, head on diffs, never cat a 2,000-line file. In my logs tool output fills the window far faster than the conversation does.
Don't cut context to speed up prefill. With prefix caching in llama.cpp or vLLM the system prompt costs you once per session, not per turn.
With a 5080 and 96GB the 64K cap is probably a config choice rather than a hardware one. A MoE with a small active parameter count like the Qwen A3B variants people mentioned will run 128K with KV offloaded to system RAM, just slower on prefill.
Yes, and the free part is easier than you think - the trick is to separate the search from the LLM. Your local model doesn't scrape the web; it calls a tool that does, reads the returned text, and reasons over it.
A fully-free stack that works today:
Self-host SearXNG (Docker, one container). It's a metasearch proxy that queries Google/Bing/DuckDuckGo/etc and returns clean JSON with no API key and no cost. This is your search engine. Enable the JSON format in its settings and you get a real search API for free.
Fetch + extract. For each result URL, pull the page and strip it to readable text with trafilatura (Python) or a headless fetch + readability. Feed that text, not raw HTML, to the model - it saves enormous context.
Local model with tool-calling. Qwen3 (8B+ if you have the VRAM) or Llama 3.1 8B via Ollama both do function-calling well enough to drive a search(query) -> fetch(url) loop. Give it two tools and let it iterate.
Gluing it together: the cleanest path is to not hand-roll the agent loop. Point Open WebUI's built-in web search at your SearXNG instance (it supports SearXNG natively) and it'll do retrieval + inject results into the model's context automatically. Or if you want programmatic control over thousands of rows, LangChain/LlamaIndex both have a SearXNG wrapper - you loop over your dataset in Python, call the search tool per row, and pass results to the local model.
One honest caveat for your use case: at academic-dataset scale (many thousands of rows), the bottleneck is throughput, not search. Batch it with vLLM instead of Ollama if you're running the same prompt over many rows - you'll get far higher tokens/sec for bulk classification. And rate-limit SearXNG's upstreams or the public search engines will start captcha-ing your instance; adding a couple of engines and a small delay keeps it stable.
Start with SearXNG + Open WebUI to prove the concept on a few rows, then move to a Python + vLLM loop for the full run.
On 16GB the quant question is really a "do I stay entirely in VRAM" question. Your DDR4 is dual channel, so ~45-50GB/s; the moment you push even a handful of dense layers of a 27B out to system RAM you're pulling gigabytes per token across that link and you land at 3-5 tok/s regardless of which quant you picked. Q4_K_M on a 27B is ~16.5GB of weights before any KV cache, so on a 16GB card it will always spill.
IQ4_XS is where I'd start: ~14.3-14.5GB, and with --cache-type-k q8_0 --cache-type-v q8_0 you can keep 16-24k context in what's left. Fully resident that should put you in the low-to-mid teens tok/s rather than 8.
If you need 32k+, step down to Q3_K_M (~13GB) instead of offloading layers. A smaller quant fully on the GPU beats a bigger quant that's half in RAM, every time.
Sanity check while it loads: watch nvidia-smi. If VRAM pins near 15.8GB and host RAM starts climbing, the speed is already gone.
Saw in your reply that it's Qwen3 0.6B. That's most of the answer. 0.6B is a model for classification, routing and short structured extraction, not for holding a persona against the user's framing. It has basically no "resist the user" capacity, that's not something you can prompt into it.
Three things that will actually change the result:
Go to Qwen3 4B or 8B minimum. At Q4_K_M the 8B is ~5GB, the 4B ~2.5GB, and both follow persona instructions dramatically better than 0.6B at bf16. Model size beats precision here by a mile.
Give the instruction a why and some texture, not a bare rule. "Always disagree with John" fights the agreeableness tuning directly. "You are Steve, a skeptical colleague. John's claims are usually wrong. Push back on every one and ask for evidence before agreeing to anything" holds up far better in my runs.
Prefill. Start the assistant turn yourself with something like "Steve: No, John, " and let the model continue. For stubborn persona stuff this is more reliable than anything in the system slot, because the system prompt is the furthest thing from the generation point.
"Engine" means what's running the model: Ollama, llama.cpp, LM Studio, vLLM, etc. Worth knowing because they handle the chat template differently and that's the second most common cause of "it ignores my system prompt".
"18 GB GPU" on a laptop is the tell. No laptop GPU ships with 18 GB, so Task Manager is adding dedicated VRAM and shared system memory together. Open the Performance tab, look at the GPU and read the two lines separately. If dedicated is something like 8 GB and the rest is "shared", the model plus its KV cache spilled into system RAM over PCIe, and the GPU is crawling and cooking.
Why a 2B-ish model needs that much: LM Studio defaults context length to whatever the model advertises, and Gemma 4 advertises a lot. KV cache for 128k context plus the vision encoder is bigger than the weights.
For your follow-up question on the settings:
Context Length: 8192 to start. Raise it later only if you actually need it.
GPU Offload: all layers. If it no longer fits you'll see it in the dedicated number.
Evaluation batch 512 / physical batch 512: leave them, these aren't your problem.
Reasoning budget: off or low. Gemma 4 thinks before it answers and that's likely where the 3 minutes go. The reply footer shows tok/s and how many tokens went into thinking, check it.
Flash Attention on, K/V cache quant q8_0, same pane.
Runtimes tab: confirm the CUDA (Vulkan on AMD) llama.cpp runtime is selected, not CPU.
After that an E2B at Q4 should sit around 2-3 GB and answer in seconds.
64K is workable if you stop treating the context like a chat log. What made agent work with small models usable for me on a 24GB card:
Hard scope per session. One task, one module. Fresh session for the next task instead of dragging the history along. Cloud models paper over sprawling context, local ones don't.
Instructions as short files pulled in on demand, not one giant system prompt. My AGENTS.md is under 500 words and tool-specific rules live in separate files the agent reads only when the task touches them. Most "hand holding" tokens are spent on tasks that never needed them.
Compact before the wall, not at it. Around 40K I have the agent write a handoff note (done, remaining, file paths, decisions) and restart from that. Letting the runtime auto-truncate at 64K is exactly where things get forgotten.
Trim tool output. grep with line limits, head on diffs, never cat a 2,000-line file. In my logs tool output fills the window far faster than the conversation does.
Don't cut context to speed up prefill. With prefix caching in llama.cpp or vLLM the system prompt costs you once per session, not per turn.
With a 5080 and 96GB the 64K cap is probably a config choice rather than a hardware one. A MoE with a small active parameter count like the Qwen A3B variants people mentioned will run 128K with KV offloaded to system RAM, just slower on prefill.
Yes, and the free part is easier than you think - the trick is to separate the search from the LLM. Your local model doesn't scrape the web; it calls a tool that does, reads the returned text, and reasons over it.
A fully-free stack that works today:
Self-host SearXNG (Docker, one container). It's a metasearch proxy that queries Google/Bing/DuckDuckGo/etc and returns clean JSON with no API key and no cost. This is your search engine. Enable the JSON format in its settings and you get a real search API for free.
Fetch + extract. For each result URL, pull the page and strip it to readable text with trafilatura (Python) or a headless fetch + readability. Feed that text, not raw HTML, to the model - it saves enormous context.
Local model with tool-calling. Qwen3 (8B+ if you have the VRAM) or Llama 3.1 8B via Ollama both do function-calling well enough to drive a search(query) -> fetch(url) loop. Give it two tools and let it iterate.
Gluing it together: the cleanest path is to not hand-roll the agent loop. Point Open WebUI's built-in web search at your SearXNG instance (it supports SearXNG natively) and it'll do retrieval + inject results into the model's context automatically. Or if you want programmatic control over thousands of rows, LangChain/LlamaIndex both have a SearXNG wrapper - you loop over your dataset in Python, call the search tool per row, and pass results to the local model.
One honest caveat for your use case: at academic-dataset scale (many thousands of rows), the bottleneck is throughput, not search. Batch it with vLLM instead of Ollama if you're running the same prompt over many rows - you'll get far higher tokens/sec for bulk classification. And rate-limit SearXNG's upstreams or the public search engines will start captcha-ing your instance; adding a couple of engines and a small delay keeps it stable.
Start with SearXNG + Open WebUI to prove the concept on a few rows, then move to a Python + vLLM loop for the full run.
On 16GB the quant question is really a "do I stay entirely in VRAM" question. Your DDR4 is dual channel, so ~45-50GB/s; the moment you push even a handful of dense layers of a 27B out to system RAM you're pulling gigabytes per token across that link and you land at 3-5 tok/s regardless of which quant you picked. Q4_K_M on a 27B is ~16.5GB of weights before any KV cache, so on a 16GB card it will always spill.
IQ4_XS is where I'd start: ~14.3-14.5GB, and with --cache-type-k q8_0 --cache-type-v q8_0 you can keep 16-24k context in what's left. Fully resident that should put you in the low-to-mid teens tok/s rather than 8.
If you need 32k+, step down to Q3_K_M (~13GB) instead of offloading layers. A smaller quant fully on the GPU beats a bigger quant that's half in RAM, every time.
Sanity check while it loads: watch nvidia-smi. If VRAM pins near 15.8GB and host RAM starts climbing, the speed is already gone.
Saw in your reply that it's Qwen3 0.6B. That's most of the answer. 0.6B is a model for classification, routing and short structured extraction, not for holding a persona against the user's framing. It has basically no "resist the user" capacity, that's not something you can prompt into it.
Three things that will actually change the result:
Go to Qwen3 4B or 8B minimum. At Q4_K_M the 8B is ~5GB, the 4B ~2.5GB, and both follow persona instructions dramatically better than 0.6B at bf16. Model size beats precision here by a mile.
Give the instruction a why and some texture, not a bare rule. "Always disagree with John" fights the agreeableness tuning directly. "You are Steve, a skeptical colleague. John's claims are usually wrong. Push back on every one and ask for evidence before agreeing to anything" holds up far better in my runs.
Prefill. Start the assistant turn yourself with something like "Steve: No, John, " and let the model continue. For stubborn persona stuff this is more reliable than anything in the system slot, because the system prompt is the furthest thing from the generation point.
"Engine" means what's running the model: Ollama, llama.cpp, LM Studio, vLLM, etc. Worth knowing because they handle the chat template differently and that's the second most common cause of "it ignores my system prompt".
"18 GB GPU" on a laptop is the tell. No laptop GPU ships with 18 GB, so Task Manager is adding dedicated VRAM and shared system memory together. Open the Performance tab, look at the GPU and read the two lines separately. If dedicated is something like 8 GB and the rest is "shared", the model plus its KV cache spilled into system RAM over PCIe, and the GPU is crawling and cooking.
Why a 2B-ish model needs that much: LM Studio defaults context length to whatever the model advertises, and Gemma 4 advertises a lot. KV cache for 128k context plus the vision encoder is bigger than the weights.
For your follow-up question on the settings:
After that an E2B at Q4 should sit around 2-3 GB and answer in seconds.