Local AI · Coding Models · Retrieval Systems
By Abdulrahman Maslmany · Technical guide · Updated November 2026
When I first started running models on my own machine, I made the mistake most people make: I sorted a leaderboard, grabbed the biggest model that technically fit on my GPU, and waited. And waited. The benchmark score looked great. The experience of typing a prompt and watching tokens crawl out was not.
What I learned is simple: the best local model is not the one with the highest score. It is the one that fits your hardware, answers fast enough that you actually keep using it, and leaves room for a useful context window. This guide walks through three model families, Qwen2.5-Coder, Meta Llama 3.1 and DeepSeek-Coder V2, and explains how I would choose between them.
- Coding first: start with Qwen2.5-Coder. Use 7B for autocomplete, 14B or 32B for harder debugging and refactoring.
- General reasoning and document answers (RAG): Llama 3.1 8B or 70B is worth testing, depending on your memory.
- Curious about Mixture-of-Experts: try DeepSeek-Coder-V2-Lite. The full 236B model needs server-class memory.
- Less than 12GB of VRAM: begin with a 7B model rather than forcing a bigger one to fit.
1. Pick the Model for the Job, Not the Hype
Autocomplete, debugging, repository-level refactoring and document Q&A all sound like "AI for code," but they push a model in very different ways.
- Autocomplete: latency wins. A 7B-class model that answers instantly beats a 32B model that makes you pause mid-thought.
- Multi-file debugging: the model has to follow function calls, configs and tests across files. A 14B or 32B model is often worth the extra memory, but only if you feed it the right files.
- RAG: retrieval quality, chunking and source selection often matter as much as the model. I would never pick a RAG model from a coding benchmark alone.
2. A Quick Word on Benchmarks
Benchmarks are useful, but only if you know what each one measures:
- HumanEval and MBPP: short Python problems checked by tests. Good for basic code generation, far from a real production repository.
- LiveCodeBench: newer, time-aware coding problems.
- SWE-bench Verified: real GitHub issues. Results depend heavily on the agent framework, tools and prompts, not just the model, so be careful comparing numbers from different sources.
- Needle-in-a-Haystack: checks whether a model can find a fact inside a long prompt. Passing it does not prove reliable retrieval across your own documents.
Scores also shift with prompt format, sampling settings and model revisions. If two numbers were produced differently, they are not directly comparable.
3. Qwen2.5-Coder: My Starting Point for Code
If most of your work is software, Qwen2.5-Coder is where I would begin. It comes in several sizes, so you can match the model to your memory instead of treating the biggest one as the only serious option.
7B is the friendly entry point: explanations, small functions, test generation and quick debugging, with modest memory needs. 14B is a good middle ground for code review and trickier bugs, as long as the extra latency is acceptable on your machine. 32B Instruct is the ambitious option. Its model card lists roughly 32.5 billion parameters and a context length up to 131,072 tokens, and the Qwen team reports a HumanEval score of 92.7% for it. That is a developer-reported result, not a promise about your setup or about complex real-world repositories.
On a 24GB GPU, a 4-bit 32B build may be possible, but weights are only part of the story. The KV cache, runtime overhead and your chosen context length all compete for the same memory.
Sources: model card, family announcement, technical report.
4. Llama 3.1: The Generalist for Documents and RAG
Meta Llama 3.1 is not a coding-only family. It comes in 8B, 70B and 405B sizes with a documented context of up to 128K tokens, and it tends to shine at explaining, summarizing and following instructions.
The 8B model runs on ordinary desktop hardware and is handy for explaining code, summarizing technical documents and classifying retrieved passages. The 70B model is a much heavier deployment, useful for longer reasoning and synthesis if you have the memory for it.
One honest caution: no model, including a 70B one, is hallucination-free. In a RAG setup, always ask for source citations and spot-check them.
About the 128K window: it is a capability, not a guarantee that your GPU can use all of it at a comfortable speed. Longer contexts grow the KV cache fast. For most developer work, retrieving a few relevant files beats pasting a whole repository. Reference: Llama 3.1 model card.
5. DeepSeek-Coder V2 and the Mixture-of-Experts Trap
According to the official repository, DeepSeek-Coder-V2-Lite has 16B total parameters with 2.4B active, and DeepSeek-Coder-V2 has 236B total with 21B active, both with up to 128K context.
Here is where many hardware guides go wrong. "Active parameters" describes how much computation happens per token, not how much memory you need. All the experts' weights still have to be available, so a 236B model does not behave like a 21B model on your GPU. The Lite version is the realistic one to experiment with; the full model belongs on server-class or very large unified-memory machines.
6. VRAM, Quantization and the KV Cache
A first estimate for weight memory:
weight memory (GB) ≈ parameters (billions) × bits per weight ÷ 8
A 32B model at about 4 bits comes to roughly 16GB of theoretical weight size. Real files and runtime allocations are larger because of quantization metadata, buffers and alignment, and then you still need the KV cache on top.
- FP16: highest precision, biggest footprint.
- Q8: roughly half the size of FP16 with more precision than typical 4-bit formats.
- Q4: a common starting point for consumer GPUs.
- Q3 and below: saves more memory, but check code quality carefully before trusting it.
The effect of quantization varies by model, so I avoid quoting a fixed percentage of quality loss.
7. Side-by-Side Comparison
This table lists documented specs and practical notes. I deliberately left out speed numbers, since those depend on your machine.
| Model | Parameters | Published context | Good for | Keep in mind |
|---|---|---|---|---|
| Qwen2.5-Coder 7B | 7B | 128K | Autocomplete, small tasks | Easiest on memory |
| Qwen2.5-Coder 14B | 14B | 128K | Code review, debugging | Good balance of quality and cost |
| Qwen2.5-Coder 32B Instruct | 32.5B | 131K | Harder coding tasks | Plan quantization and KV cache |
| Llama 3.1 8B | 8B | 128K | General assistant, light RAG | Fits modest hardware |
| Llama 3.1 70B | 70B | 128K | Reasoning and RAG synthesis | Needs a lot of memory |
| DeepSeek-Coder-V2-Lite | 16B total / 2.4B active | 128K | MoE experiments | Check runtime and quant support |
| DeepSeek-Coder-V2 | 236B total / 21B active | 128K | Large-scale workloads | Server-class memory |
Interactive helper: what should I try first?
Choose your task and memory. This is a rough starting suggestion based on typical planning sizes, not a benchmark result.
8. Building a Local RAG Pipeline
A local RAG system lets you ask questions about documentation, code or notes without pasting everything into a chat. The pipeline has five stages:
- Ingest source files, Markdown, PDFs and other documents.
- Chunk the text while keeping headings and structure.
- Embed each chunk with a local embedding model.
- Retrieve and rerank the best candidates.
- Generate an answer grounded in those passages, with references.
Why code-aware chunking matters: fixed-length splitting can cut a function away from its class or a config value away from the code that uses it. A parser such as tree-sitter lets you split at function and class boundaries instead.
Embeddings and storage: good local options to try include BGE Large English and Nomic Embed Text, stored in ChromaDB or LanceDB. I would not trust a universal accuracy percentage for any of them; test against your own documents and questions.
Why rerank: vector search often returns passages that are related but not actually useful. A reranker reorders candidates by real relevance, so the model sees a small, relevant set instead of a data dump. For tool integration, see our guide to Model Context Protocol for local LLMs.
9. Hardware: What Actually Matters
A single 24GB GPU
A great platform for experimenting. It handles smaller models comfortably and can host some larger quantized ones if you manage memory carefully. For a 32B model, the file size alone does not tell you whether it will work; context length and overhead decide that.
Two 24GB GPUs
You get 48GB of physical memory, which opens the door to larger models, but it is not the same as one 48GB card. Sharding, PCIe topology, power, cooling and runtime support all affect the result. More in our local AI workstation builds guide.
Apple Silicon with unified memory
Unified memory lets the CPU and GPU share a large pool, which makes bigger models possible. Speed still depends on memory bandwidth, quantization and software support. See Mac Studio Ultra for local LLMs.
Checklist before you buy or load anything
- Check the real GPU memory, not just the product name.
- Leave room for the operating system and runtime.
- Estimate the KV cache at the context length you actually plan to use.
- Confirm power supply and cooling for multi-GPU builds.
- Verify your runtime supports the model architecture and quantization format.
10. Ollama, llama.cpp and vLLM
- Ollama: the easiest way to start. Simple command line and a local API, ideal for personal tools and prototypes.
- llama.cpp: great with GGUF models when you want control over quantization and CPU/GPU offloading.
- vLLM: built for serving many requests with continuous batching and PagedAttention, so it fits shared services better than solo use.
- Continue.dev: connects a local model to your editor for chat and coding help. Quality depends on the model and your configuration.
Detailed comparison: vLLM vs Ollama vs llama.cpp.
11. Getting Started in Five Minutes
These commands are a starting point, not a benchmark. Begin small to confirm your GPU and runtime work, then move up.
ollama pull qwen2.5-coder:7b ollama run qwen2.5-coder:7b
Check that the local API is up:
curl http://localhost:11434/api/tags
Send a simple request:
curl http://localhost:11434/api/generate -d '{
"model": "qwen2.5-coder:7b",
"prompt": "Explain this Python function and list possible edge cases.",
"stream": false
}'
For real scripts, use a proper HTTP client with timeouts and error handling. When connecting an editor extension, follow its current documentation, since config formats change between versions. For agent workflows, see LangGraph, CrewAI and AutoGen.
12. Test the Models Yourself
A short, repeatable test on your own hardware beats any number copied from someone else's workstation. I suggest four tests:
- Code generation: ask for a small function with clear inputs and outputs, run automated tests, and count the attempts needed.
- Debugging: give a broken function and a short failure description. Does the model find the real bug or just rewrite everything?
- Multi-file reasoning: give a small repo and ask it to trace a call across files and decide where a change belongs.
- RAG retrieval: build a tiny document set with known facts and check whether answers cite the right passages.
Write down the model and revision, quantization, GPU and VRAM, runtime version, context length, time to first token, generation tokens per second, peak memory and success rate. Keep prompt-processing speed and generation speed separate, because a model can read a long prompt slowly and still write short answers quickly.
13. Frequently Asked Questions
Which local LLM is best for coding?
Qwen2.5-Coder is a strong coding-focused choice, especially the 14B and 32B Instruct versions. For autocomplete and everyday help, smaller variants are often more practical.
Can a 24GB GPU run Qwen2.5-Coder 32B?
Often yes, with a 4-bit build and a modest context. The KV cache and runtime overhead must fit too, so you may need to shorten the context for stability.
Is Llama 3.1 better than Qwen2.5 for RAG?
Not universally. Llama 3.1 is a general-purpose model and Qwen2.5-Coder is specialized for code. RAG quality also depends heavily on embeddings, chunking and reranking.
Can an 8B model replace a cloud coding API?
For explanations, small functions and simple debugging, often yes. For architectural changes and repository-wide reasoning it is less dependable. It depends on your workload and how many errors you can tolerate.
How much VRAM does a 70B model need?
At about 4 bits per weight the weights alone are roughly 35GB in theory, more in practice, plus the KV cache and buffers. A 48GB setup may work with a careful configuration, but do not assume every context length will fit.
Does a 128K context mean I can load my whole codebase?
No. It is the maximum supported length, not a guarantee of memory, speed or accurate recall. Retrieval-based workflows are usually more efficient.
Is local inference automatically private?
It can reduce what you send to outside providers, but privacy still depends on plugins, telemetry, logging, network access and any connected services.
Sources and Further Reading
- Qwen Team: Qwen2.5-Coder family
- Qwen2.5-Coder-32B-Instruct model card
- Meta Llama 3.1 model card
- DeepSeek-Coder-V2 repository
- llama.cpp, vLLM docs, Ollama