The same machine, a different job
Both are transformer language models trained to predict the next token. Nothing in the architecture of a coding model is special: same attention, same feed-forward layers, same tokenizer family, often the same base checkpoint before post-training. The differences are in the data, the objectives, the post-training pipeline and the software wrapped around the model.
That is why the boundary is blurry in practice. A strong general model can write a patch, and a code-specialised model can hold a conversation. What differs is the distribution it was optimised for. Code is exact, verifiable and densely structured in a way prose is not, and a model trained mostly on prose learns different habits: it paraphrases, hedges and generalises where a coding model has to copy an identifier exactly and keep a schema consistent across a thousand lines.
What changes with code
Code punishes approximation. A variable name that is almost right raises a name error; an import that is almost right is a missing module; a bracket in the wrong place changes the meaning of a block. Prose tolerates paraphrase, and a model trained on prose learns to paraphrase. A coding model has to learn to reproduce names, respect indentation and stay inside the API surface that actually exists in the project.
Code also has long-range dependencies that prose rarely has. A function's behaviour depends on a type defined in another file, on a configuration value set at startup, on a library version pinned in a lockfile. A model that only sees the current file will confidently call methods that do not exist. This is why repository context, not just code fluency, separates a useful coding model from a demo.
Tokenization adds a subtler problem. Source code is full of rare identifiers, punctuation and whitespace that a general-purpose tokenizer splits into many small pieces, so a line of code costs more tokens than a line of prose of similar length. That raises cost, shortens the effective context and makes exact copying harder, which is one reason code-focused tokenizers and long identifiers treated as single units matter for a coding model.
And code gives feedback. A program either compiles or it does not; a test either passes or it fails. That signal is the reason coding models can be improved with reinforcement learning in a way chat models cannot: the reward can be computed instead of judged. Training pipelines generate candidate patches, run them against tests, keep the ones that pass and discard the rest, sometimes with extra filters for style or complexity.
Coding assistants also rely on tooling: file search, test runners, linters and execution sandboxes. A capable model behind a chat box produces suggestions a developer must copy by hand; the same model behind a harness that can read the repository, apply a patch and run the suite produces verified changes.
How a coding model is trained
The pretraining mix is the first lever. Code is a smaller share of the public web than text, so it is usually upsampled, balanced across languages, deduplicated aggressively and filtered by licence. Deduplication matters more than it sounds: near-duplicate files teach memorisation, and memorised solutions inflate benchmark scores without improving generalisation to new problems.
Fill-in-the-middle training is the second. Instead of only predicting what follows a prefix, the model is trained on a prefix and a suffix with the middle removed, so it learns to complete a function given both the code that calls it and the code that comes after. This is what makes inline completion work, and it teaches the model to use context in both directions rather than only looking backwards.
Repository-level training is the third. Files are packed with their neighbours, imports and tests, so the model sees how a change in one place implies a change elsewhere. Instruction tuning on real development artefacts — an issue and the commit that closed it, a failing test and the fix, a review comment and the follow-up patch — teaches the edit-shaped behaviour that agents depend on.
The last stage is usually reinforcement learning against executable checks, or rejection sampling with the same filters. The quality of the test suite becomes the ceiling on the quality of the model, which is worth remembering when you rely on one: a model trained to satisfy tests will satisfy the tests it can see, including by special-casing inputs if the suite is weak.
Evaluation is different
Chat models are usually judged by human preference, a rubric or an LLM judge. Coding models are judged by execution, and that changes what the numbers mean.
The trap with public benchmarks is saturation and contamination. Most popular function-level suites have been in training data for years, so a high score can mean memorisation rather than skill. Fresh, private tasks drawn from your own repository are the only evaluation that survives a model upgrade.
- Unit tests and hidden test cases beat stylistic review. A patch that reads well and fails the suite is worthless, because the suite is the specification.
- Pass@k measures whether any of k samples passes. It is the right metric for a completion product where the user picks from several suggestions, and the wrong one for an agent that must land a single patch.
- Repository-level tasks test retrieval and multi-file edits, not just function synthesis. They are much closer to real work and much noisier to grade.
- Security and licence awareness matter for generated code: vulnerable patterns, hallucinated dependencies and copied copyleft code are all real failure modes.
- Efficiency counts. A correct solution that is quadratic where the input has a million rows will pass a small test and fail in production.
Context is the real constraint
A coding model is only as good as the code it can see. Real tasks require the file being changed, the definitions it depends on, the callers that depend on it, the test that encodes the expected behaviour and the conventions of the project. That is often far more than fits comfortably in a prompt, even with a large context window.
Stuffing everything is the naive answer and it performs poorly. Models attend less reliably to material in the middle of a long context, irrelevant files act as distractors, and cost per request scales with the prompt. Better systems retrieve: search for the symbol, follow the imports, pull the matching test, and include only the neighbourhood the edit needs.
Retrieval for code is not the same as retrieval for documents. Exact symbol names matter more than semantic similarity, so lexical search and syntax-aware chunking often beat embeddings alone. A good harness combines both: find the definition by name, expand along the call graph, then let the model ask for more when it discovers a dependency it cannot see.
The harness is half the product
A coding model in a chat box is a suggestion engine. A coding model with tools is an agent: it can list files, read them, search for a symbol, apply a patch, run the tests, read the failure and try again. The loop is what turns fluent code into working code, because the model gets to observe the consequences of its own edit.
Each tool brings its own requirements. Patches need a consistent edit format — whole-file rewrite, unified diff, or search-and-replace blocks — and the model has to be trained or prompted for the one the harness applies. Test runners need timeouts, output truncation and a working directory. Shell access needs a sandbox, a permission model and a hard boundary around secrets.
The security posture is part of the design, not an afterthought. Generated code runs, which means it can read files, make network calls and consume resources. Run it in an isolated environment with a read-only view of anything sensitive, a network policy and a human approval step for destructive operations. The model is not the only thing that can be wrong; the tool that executes its output is the thing that can do damage.
Why edit formats cause so many failures
A model that can write a correct function can still fail to land a change, because the hard part is expressing the edit in a form the tool can apply. Unified diffs need accurate line numbers and context lines, and models are unreliable at counting lines; one wrong hunk offset makes the patch fail. Whole-file rewrites avoid that but pay to regenerate every untouched line, which is slow and invites accidental edits elsewhere. Search-and-replace blocks sit in between: the model quotes the exact text to change, and the harness fails loudly when it does not match.
The practical fix is to make failure cheap and visible. Apply the patch as a dry run, report the mismatch back to the model with the surrounding text that actually exists, and let it retry. Models correct a rejected patch far better than they produce a perfect one first time. Choose the format the model was trained on, keep the quoted context small enough to match exactly, and track apply failures as a first-class metric, because they often dominate the end-to-end failure rate.
Can one model do both?
Yes. A strong general model can write code, and a code-specialised model can chat. The difference is the training mix and the product around it. For production, evaluate on your actual repository and language, not only public benchmarks.
The practical question is not which category a model belongs to but which configuration wins on your tasks. A general model with good tool use can beat a code-specialised model with a bad harness, and a smaller code model with retrieval and tests can beat a larger one without them. Measure the system, not the label on the model card.
Choosing one for real work
Build a private evaluation before you compare candidates. Fifty to a hundred tasks from your own repository, each with a test that decides pass or fail, is enough to rank models and far more informative than a leaderboard. Include the boring cases: renaming a field across files, adding a parameter to an API, fixing a failing test, updating a dependency.
Measure the things that decide cost. Pass rate on the first attempt. Pass rate after the agent sees test feedback. Latency to a usable patch, not to the first token. Tokens and money per accepted change. How often the patch applies cleanly. How often it breaks an unrelated test. How often a human has to rewrite it.
Check the unglamorous compatibility details too: context window, tool-calling format, whether it supports the edit format your harness applies, whether it can be served at the throughput you need, and what the licence permits. A model that is five points better on a benchmark but twice as slow per accepted patch is usually the worse choice.
Common mistakes
- Treating a public benchmark score as a prediction of performance on your codebase.
- Quoting pass@k when the product needs one correct answer, which makes a model look far better than it is.
- Shipping generated code without running the tests, or without reviewing the diff because the tests passed.
- Letting the agent edit files freely with no diff review and no version-control checkpoint, so a bad patch is hard to undo.
- Ignoring licence and provenance: copyleft code reproduced from training data is a legal problem, and a hallucinated package name is a supply-chain one.
- Assuming chat quality predicts coding quality. The correlation is real but loose, and it breaks down on long repository-level tasks.
- Pinning nothing, so an unpinned model version changes silently and last month's evaluation no longer describes today's behaviour.
- Giving the model a huge context of unrelated files and calling it retrieval.
What good looks like in practice
The pattern that works in production is unglamorous: a competent model, a tight retrieval step that puts the right twenty files in front of it, an edit format the model was trained on, a test command that finishes in seconds, and a human who reviews the diff. Each piece is replaceable; the loop is what produces reliable changes.
That also tells you where to invest. If the model fails because it cannot find the right file, better retrieval beats a bigger model. If it fails because the patch does not apply, fix the edit format. If it fails because the tests are slow or flaky, the model is being blamed for a harness problem. Diagnose before you upgrade.