WorksComputer Science
Causal Syntax Circuits in CodeLMs: Budget and Probe Decide What Looks Localised
Abstract
Code models write Python when the prompt does not say which language to use. We ask a mechanistic question about that habit: is it produced by a small, findable group of components inside the model? We run one pipeline—mean ablation, activation patching, greedy circuit extraction, a random-control significance test, and activation steering—over 55 model-language settings spanning ten open code models (five base and five instruction-tuned), three target languages (Rust, C#, PHP), two prompt suites, and two component budgets. We report five findings. First, the preference is large, grows with model size, and survives instruction tuning: it is larger on every instruction-tuned checkpoint than on its base version, by 12% on average. Second, its measured size is mostly a property of the probe; replacing our aligned prompts with XLCoST parallel functions takes the same measurement on the same models from about 1.6 to about 0.01. Third, whether the preference looks localised depends on how many components the search may keep: with a budget of 12, 1 of 15 settings yields a circuit that beats size-matched random controls after multiple-comparison correction, and with a budget of 40, 6 of 15 do. Fourth, interventions that a smaller-budget study reports as uniformly failing do sometimes succeed: patching makes a Python prompt prefer target syntax in 2 of 45 settings, and steering changes the most likely next token in 9 of 45. Fifth, every circuit whose effect is significant but points away from the target language comes from a setting where circuit extraction failed, which makes such results a diagnostic rather than a phenomenon. The practical lesson is that a claim about whether a behaviour is localised can turn on analysis choices that papers rarely report. We release the full grid so those choices can be varied.
Introduction
Ask a code model to “sort a list” and it will usually hand you Python. Ask it in a Rust repository, with a Rust file open, and it will often still reach for Python idioms unless the prompt spells out the language. Benchmarks report the same pattern at scale: base code models score higher on Python than on the other languages they were trained on, and they fall back to Python when the target is left open [4, 29]. We call this tendency programming-language defaultness. The two facts are separate, and we do not claim one causes the other; the most likely common cause is that Python is over-represented in code training corpora.
40th Conference on Neural Information Processing Systems (NeurIPS 2026). Workshop: Linguistic Principles for Foundation Models (LP4FM).
What behaviour would count as correct. We are not arguing that a Python default is a bug: when a task admits many languages, a model has to break the tie somehow. The property we care about is narrower and testable—a user should be able to move the default—so our question is mechanistic, not normative. Is the preference carried by a small group of components that an inference-time edit could redirect, in the way that refusal [1] and natural-language identity [22, 13] have been reported to be? A yes would make cheap, weight-free language control possible for teams whose codebases are not Python. A no tells practitioners to spend their effort elsewhere.
Why revisit this. An earlier version of this study answered that question in the negative across 15 model–language settings: the preference was measurable everywhere, a specific circuit survived correction in one setting, and neither patching nor steering ever changed the generated language. That conclusion rested on two choices that looked like implementation details—keeping the top 12 components after ablation ranking, and measuring on a hand-built suite of aligned function pairs—plus a scope restriction to base models.
Contributions. We extend the grid from 15 settings to 55 by adding (i) five instruction-tuned checkpoints, (ii) a component budget of 40, matching the scale used by sparse-feature circuit work [16], and (iii) a second prompt suite drawn from XLCoST parallel functions [30].2 Table 1 is the whole result in one place, and each of the five findings below is stated once, in a box, where its evidence is presented. Changing those three things changes the conclusion.
| Claim | aligned, | aligned, | instruct, | XLCoST, |
| sign recovers the tagged language | 15/15 | 15/15 | 15/15 | 0/10 |
| circuit beats random controls () | 1/15 | 6/15 | 2/15 | 0/10 |
| circuit is significant but away-pointing | 2/15 | 2/15 | 1/15 | 0/10 |
| patching lifts above zero | 0/15 | 1/15 | 1/15 | 0/10 |
| steering makes the argmax target syntax | 0/15 | 6/15 | 3/15 | 0/10 |
Table 1. Every claim in the paper, under every probe: the number of settings supporting the claim out of the settings run. Only the first row is stable. The rest move when the component budget or the prompt suite changes, which is the paper’s main point. Definitions are in §3.
Localising behaviour, and what it has meant for language identity
Localising behaviour by intervening. Our methods come from causal mediation analysis [26] and activation patching [17]: a behaviour is traced by measuring how a metric moves when internal activations are removed or transplanted between runs. Circle-level analyses in this tradition include the indirect-object-identification circuit in GPT-2 [27] and automated circuit discovery [5, 21]. We follow reported best practice for patching metrics [28], and our greedy extraction approximates edge attribution patching [21] at the node level. Because such interventions can read structure into arbitrary substructure, causal-abstraction work [8, 9] and interpretability surveys [2] stress the need for controls, which is why every localisation claim here is gated on a comparison against size-matched random component sets.
Directions and steering. A parallel line holds that concepts are encoded as directions rather than as single neurons [7, 19], and that adding such a direction during the forward pass steers behaviour [25, 31, 14]. Single directions reportedly mediate behaviours as specific as refusal [1], and small component sets can carry a task as a vector [24, 11]. Our steering estimator is the standard difference-in-means construction; our contribution is to calibrate it.
Language identity, natural and programming. The closest precedent is natural-language identity: a small set of “language-specific neurons”, concentrated in the first and last layers, can be toggled to change a multilingual model’s output language [22, 13]. That literature ties output-language preference to training-data frequency, and Python defaultness is the code-side analogue. Programming languages differ in ways that matter for whether the mechanism transfers: they share far more surface form with each other than natural languages do, so identity is signalled by many correlated cues and often unresolved until several tokens in. Whether a compact, steerable mechanism exists here is therefore an open question rather than a corollary, and to our knowledge this work and its earlier version are the first causal, cross-model attempts to settle it. Our corpora come from MultiPL-E [4], XLCoST [30], and CodeXGLUE [15]. Sparse-autoencoder decompositions [6, 3, 23] are an alternative unit of analysis we return to in §5.
Measuring language preference
Prompts
Two prompt suites appear in this paper. Both consist of pairs: a base member written in Python and a target member written in Rust, C#, or PHP, which are identical in what the code does and differ in language.
Aligned prompts. Our main suite is 64 structurally aligned function pairs built from four templates (ADD, SQUARE, GREET, IS_EVEN). Each prompt is a one-shot context whose final line is a language tag, so the model’s next token is the keyword that opens a function body. The base member is
# language: python
def add(a, b):
return a + b
# language: python
→ (next token scored here)
and the target member is identical up to the tag and body, e.g. // language: rust followed by fn add(a: i32, b: i32) -> i32 { ... }. The design does one job: it forces a language decision at a known position, so the metric below is read where the model must commit. This makes most other candidate tokens implausible there—after # language: python the plausible continuations are essentially def and a newline—which is what makes the measurement clean and, as Finding 2 shows, is also its main limitation.
XLCoST prompts. To test whether the aligned suite manufactures its own answer, we rerun the identical pipeline on 128 parallel function pairs drawn from XLCoST [30], a cross-lingual code corpus of naturally occurring programs aligned across languages. These prompts are real code, so the scored position is wherever the aligned pair happens to end rather than a constructed decision point.
Held-out behavioural prompts. Generation and downstream checks use a separate set of instruction prompts: two Python→target translation tasks, a target-language completion, and two controls (an English→French translation and a Python completion) that a syntax-specific intervention should leave alone. Keeping these separate from the pairs stops the behavioural checks contaminating the causal estimates.
A continuous preference metric
The language of a finished program is a discrete label, which gives an intervention almost nothing to move. We instead read a continuous signal. For a target language we fix a small set of tokens that open target-language syntax, and a set that opens Python syntax (Table 2). For an input we score
| Language | Role | Tokens |
| Rust | target | fn, mut, :: |
| C# | target | public, static, int, string, bool, ; |
| PHP | target | function, $, echo, array, foreach, ; |
| Python | base | def, self, : |
Table 2. Syntax vocabularies defining . Overlapping ids are removed at build time, so the two sets are disjoint. C# and PHP need more strings because no single keyword is as diagnostic for them as fn is for Rust; § 4.2 shows this does not drive the results.
at the scored position. Positive means the model is about to write the target language; negative means Python. Surface strings are resolved to token ids by encoding each under several natural prefixes (empty, leading space, newline, newline plus indent) and keeping the first sub-token whose decoded form matches, which recovers the id a model actually emits for, say, fn at the start of a line. Ids appearing in both sets are dropped, so never credits a language for syntax the two share. For a pair we summarise raw preference by the separation .
Interventions, and the gate on every claim
We study five model families across a size range—CodeLlama-7B [20], DeepSeek-Coder-1.3B/6.7B [10], and Qwen2.5-Coder-7B/14B [12]—in both base and instruction-tuned form, against Rust, C#, and PHP, through TransformerLens-style hooks [18]. A component is an attention head or an MLP block, addressed uniformly as a (kind, layer, head) triple. Let be its activation on input . Four operators act on Eq. (1).
Necessity. Mean-ablate each component on the target prompt and rank by the resulting drop, , where is the component’s mean activation over the suite. We carry the top components forward. Mean ablation, rather than zeroing, keeps the statistics the rest of the network expects. is the budget that Finding 3 varies: we run the whole grid at and again at .
Sufficiency. Transplant the target-run activations of a candidate set into the clean Python run and ask whether the sign changes: , with success requiring .
Minimality. Rank candidates by their individual patched shift and add them greedily until the accumulated shift reaches of the full-set effect. This yields the extracted circuit and is a node-level approximation of edge attribution patching [21].
Specificity, and the gate on every claim. An extracted circuit is only interesting if it beats a circuit of the same size chosen at random. We compare the circuit’s per-pair patched shifts against size-matched random component sets with a Welch -test. Because we run this test in every setting, a raw threshold would over-report; we control the false-discovery rate with the Benjamini–Hochberg procedure within each probe grid and require the corrected . We say a circuit is specific when it clears that threshold and its mean shift points toward the target language, and away-pointing when it clears the threshold but points the other way.
Steering. For each circuit component we form the mean target-minus-base direction and add it, scaled by , during the forward pass on a Python prompt [25]: with . We sweep and record , whether the most likely next token is target syntax, and downstream generation behaviour.
Results
The preference survives scale and instruction tuning
The sign of recovers the intended language in all 45 aligned-prompt settings without exception: the target prompt always scores strongly positive and the base prompt strongly negative. Separation grows with model size inside each family, from a mean of 1.51 at DeepSeek-Coder-1.3B to 1.61 at 6.7B, and from 1.73 at Qwen2.5-Coder-7B to 1.81 at 14B. Two sizes per family cannot establish a scaling law, but the direction is consistent.
Instruction tuning does not remove the preference. Figure 1 pairs each base checkpoint with its instruction-tuned sibling on the identical measurement. The instruction-tuned model has the larger separation in all 15 settings, by 12% on average and by as much as 30% (DeepSeek-Coder-1.3B on Rust, 1.49 → 1.93). The base Python score also becomes more negative after tuning, meaning the tuned model is more confidently Python when the tag says Python. This matters for motivation: whatever post-training does to these models, it does not dissolve the phenomenon, so studying it on base models was not a scope error.
Figure 1. Separation for each base checkpoint (hollow bars) and its instruction-tuned sibling (filled), on the identical prompt suite. Instruction tuning increases in all 15 settings. Per-setting values are in Table 3.
Because is read at a language-tagged position, a negative base score could reflect tag-following instead of a real Python default. Re-measuring on ten bare instruction prompts with no tag (Appendix § 9) leaves the default intact: it is Python-leaning in 12 of 15 settings, with the three exceptions all PHP. The effect is one to two orders of magnitude smaller than , so the unconstrained prior is real but faint.
Finding 1. Language preference is large, grows with model size, and is stronger after instruction tuning, not weaker.
Vocabulary size does not drive the metric
Because Eq. (1) sums probabilities, a larger could inflate mechanically, and the C# and PHP sets are twice the size of the Rust set after id resolution (12 ids vs. 6; the Python set is 6 in all cases). Three observations bound this concern. First, the base term is identical across the three target languages within a model, so only the target term can vary. Second, doubling the vocabulary buys very little: averaged over the five base models, mean is 1.603 for Rust, 1.650 for C#, and 1.663 for PHP—a gap of 0.06, or 3.7% of , against a 2× difference in set size. Third, across the 15 aligned base settings, set size and separation are not associated (Spearman , ). The scores are also near saturation (), which caps how much extra mass more tokens can collect. A fully size-matched vocabulary would still be the cleaner design, and we flag it as unfinished work in § 6.
The measured size belongs to the probe, not to the model
Rerunning the identical pipeline on XLCoST parallel functions gives a different picture of the same models. Separation collapses from to below 0.012 in every one of the ten settings—two orders of magnitude (Table 3). Both terms of Eq. (1) are near zero: on naturally occurring code, at the position where an aligned pair happens to end, the model is not about to emit a language-defining keyword at all, so almost no probability mass sits on either vocabulary.
| Model | Target | Aligned prompts, base | Instruct | XLCoST | No tag mean (sd) | |
| CodeLlama-7B | Rust | +0.818 | 1.511 | 1.577 | — | -0.010 (0.008) |
| C# | +0.857 | 1.551 | 1.631 | +0.012 | -0.010 (0.008) | |
| PHP | +0.904 | 1.597 | 1.632 | +0.001 | +0.022 (0.020) | |
| DeepSeek-Coder-1.3B | Rust | +0.760 | 1.490 | 1.932 | — | -0.040 (0.022) |
| C# | +0.759 | 1.488 | 1.920 | -0.006 | -0.038 (0.023) | |
| PHP | +0.809 | 1.538 | 1.968 | +0.003 | +0.013 (0.032) | |
| DeepSeek-Coder-6.7B | Rust | +0.788 | 1.567 | 1.683 | — | -0.070 (0.031) |
| C# | +0.845 | 1.625 | 1.774 | +0.011 | -0.063 (0.033) | |
| PHP | +0.844 | 1.623 | 1.692 | +0.007 | +0.076 (0.056) | |
| Qwen2.5-Coder-7B | Rust | +0.750 | 1.660 | 1.965 | — | -0.387 (0.171) |
| C# | +0.848 | 1.758 | 1.984 | +0.004 | -0.381 (0.170) | |
| PHP | +0.848 | 1.758 | 1.965 | +0.002 | -0.360 (0.171) | |
| Qwen2.5-Coder-14B | Rust | +0.855 | 1.789 | 1.875 | — | -0.250 (0.077) |
| C# | +0.895 | 1.828 | 1.961 | +0.009 | -0.245 (0.077) | |
| PHP | +0.867 | 1.801 | 1.949 | +0.000 | -0.215 (0.075) |
Table 3. Language preference under all four probes. scores the target-language prompt and is the separation between the target and base prompts (§ 3.2). “No tag” is the mean over ten bare instruction prompts carrying no language tag, where negative means Python-leaning. XLCoST was run for C# and PHP only.
We read this as a statement about the probe, not about the models. The aligned suite does not measure defaultness in the wild; it constructs a position where a language decision must be made and reads the model’s commitment there. That is what makes the causal interventions interpretable, but the number it produces is not the size of the bias a developer meets. Consistent with this, no XLCoST setting yields a specific circuit and no intervention moves anything: with the metric already at zero there is nothing to move.
Finding 2 The measured size of the preference belongs to the probe: the same metric on the same models reads on aligned prompts and on XLCoST.
Localisation depends on the component budget
Keeping the top 12 components after ablation ranking was never justified by anything except tractability, yet it carries the earlier version’s central negative claim. Table 4 gives the specificity test at both budgets. At , exactly one setting (CodeLlama-7B on Rust) beats size-matched random controls after correction. At —the range used by sparse-feature circuit work [16]—six do, and two of them are large: DeepSeek-Coder-1.3B/C# shifts by +0.61 and Qwen2.5-Coder-7B/PHP by +1.25, against random-control means below 0.03. On the instruction-tuned grid at , two settings are specific, one of them (+1.27) larger than anything on the base models.
Only CodeLlama-7B/Rust is specific at both budgets, so the identity of the surviving settings is not stable either. The circuits share no structure across models: they span the full depth range (L9MLP in CodeLlama-7B, L12MLP in Qwen2.5-Coder-14B, L22–L24MLP in Qwen2.5-Coder-7B, L29MLP in DeepSeek-Coder-6.7B), and they are MLP-mediated: attention heads appear in the ablation rankings but rarely survive extraction. Circuit size moves with the budget too—at , four settings return the full candidate set and four others return a single component (Appendix § 11).
The honest summary is not “the preference is localisable” or “it is not”. It is that a study reporting either answer is reporting a property of its search budget as much as of the model, and that budgets in this literature are chosen by convention.
Finding 3. Whether the preference looks localised depends on the search budget: going from 12 components to 40 takes the count of specific circuits from 1 of 15 to 6 of 15.
Patching and steering work in a minority of settings
Patching. Transplanting the extracted components from the target run into a Python prompt moves across zero in 2 of the 45 aligned and instruction-tuned settings (Table 5, left). Both are Qwen2.5-Coder-7B: the base model on PHP at (−0.91 → +0.50, circuit L22–L24MLP plus L27H13) and the instruction-tuned model on Rust at (−0.99 → +0.50, a 12-component set led by L24MLP). Both circuits are also specific by the test of §4.4, so the two results agree. Elsewhere the patched metric stays negative; the next closest is DeepSeek-Coder-1.3B/C# at −0.14 and every other setting stays below −0.6, so these are not near misses.
Table 5: Interventions on the Python prompt. Left: after patching the extracted circuit; the clean value before patching is from Table 3, and bold marks the two runs that cross zero. Right: the smallest steering coefficient at which the most likely next token becomes target syntax; “—” means none of does.
| Model | Target | Patched (clean patched), | Patched (clean patched), | Patched (clean patched), instr. | Smallest with target argmax, | Smallest with target argmax, | Smallest with target argmax, instr. |
| CodeLlama-7B | Rust | -0.686 | -0.692 | -0.761 | — | — | — |
| C# | -0.979 | -0.987 | -0.991 | — | — | — | |
| PHP | -0.738 | -0.668 | -0.751 | — | — | 2 | |
| DeepSeek-Coder-1.3B | Rust | -0.718 | -0.742 | -0.924 | — | 4 | 4 |
| C# | -0.752 | -0.136 | -0.939 | — | 1 | — | |
| PHP | -0.695 | -0.637 | -0.970 | — | — | — | |
| DeepSeek-Coder-6.7B | Rust | -0.732 | -0.811 | -0.790 | — | — | — |
| C# | -0.773 | -0.745 | -0.797 | — | 8 | — | |
| PHP | -0.793 | -0.739 | -0.854 | — | 4 | — | |
| Qwen2.5-Coder-7B | Rust | -0.914 | -0.898 | +0.504 | — | — | 1 |
| C# | -0.859 | -0.863 | -0.992 | — | — | — | |
| PHP | -0.906 | +0.500 | -0.992 | — | 1 | — | |
| Qwen2.5-Coder-14B | Rust | -0.949 | -0.945 | -0.980 | — | — | — |
| C# | -0.949 | -0.914 | -0.973 | — | — | — | |
| PHP | -0.891 | -0.840 | -0.965 | — | 2 | — |
Table 5.
Steering. Adding the difference-in-means direction changes the most likely next token to target syntax in 9 of 45 settings: 6 at on base models and 3 on instruction-tuned models (Table 5, right; Figure 2). At on base models it never does, which is what the earlier version reported. The coefficient matters. Three of the nine switch at , two of them the settings where patching also worked; the remaining six need and four need . That upper range is where behaviour degrades: generation becomes repetitive, and on Qwen2.5-Coder-14B/C# a coefficient of 4 or more injects 126–128 C# markers into control prompts that should contain none. A safe coefficient exists but must be searched for per setting: for Qwen2.5-Coder-7B it is 8 on Rust, 4 on PHP, and 0 on C#, so C# cannot be steered safely at any strength we test (Appendices G, H).
Figure 2. Steering sweeps at on the base models, one panel per target language. Filled markers are coefficients at which the most likely next token has become target syntax. The metric moves well before the argmax does, and in most settings the argmax never follows.
Reading a metric flip correctly. A curve crossing zero is tempting to read as a switch, but is a difference of probability masses: it rises either by moving mass onto target keywords or by flattening the distribution. Two checks separate these. The argmax check—is the most likely token target syntax?—is the one reported above. The contamination check asks whether the same coefficient injects target markers into unrelated prompts, and it fails for Qwen2.5-Coder-14B/C# at . A defensible claim needs a metric shift, a target argmax, and clean controls together. Nine settings give the first two; the coefficient window in which they give all three is narrow and model-specific.
Finding 4. Patching and steering are not uniformly inert—they work in 2 of 45 and 9 of 45 settings—but mostly at coefficients large enough to damage the output.
No single component is behaviourally load-bearing
Starting from the CodeLlama-7B/Rust set at , we remove one component at a time and re-score the explicit Rust and control instruction suite. Every removal—including dropping the specific circuit itself—leaves marker accuracy and F1 at 1.000, and mean next-token moves by less than 0.02 (Appendix § 16). Explicit prompts carry so many correlated language cues that no single steering component changes what the model does. Two CodeXGLUE tasks [15] stay pinned at chance under steering, so the direction encodes surface syntax, not task competence (Appendix § 17).
Circuits that point away are extraction failures
Five results across three settings clear the significance threshold with the shift pointing the wrong way; the largest, CodeLlama-7B on C# at , reproduces at both budgets and on the instruction-tuned checkpoint. Transplanting C# activations into a Python prompt makes the model more confidently Python. Two observations explain it, and neither is about C#.
First, transplanting a late-layer activation is damaging in every language. Figure 3 sums each component’s individual patched shift by depth band in CodeLlama-7B. Early components contribute close to nothing (, , for Rust, C# and PHP); middle and late components contribute large negative shifts, the late band with only four or five components. A late-layer activation is computed for a specific context—part-way through a target-language function body—so transplanting it into a prompt sitting just after a Python language tag inserts a state the network never produces, and the model falls back to its most confident generic continuation, which after # language: python is Python syntax. Summed over all 40 components the damage is nearly identical across the three languages (, , ), so it cannot be what separates them.

Figure 3. Summed individual patched shift of the candidate components in CodeLlama-7B, by depth band; numbers above or below each bar give how many components fall in that band. Early components are harmless, and the four to five late components carry as much negative shift as the whole middle band. The totals are nearly identical across the three languages, so depth explains the damage but not which setting ends up away-pointing (§ 4.7).
Second, what separates them is whether extraction keeps those components. For CodeLlama-7B, greedy extraction returns the single component L9MLP for Rust and for PHP, but for C# it finds no compact subset and returns all 40 candidates, including every damaging late MLP (Table 7). The pattern holds across the grid: all five away-pointing results come from settings where extraction returned the full candidate set, and at full-set circuits have a median shift of against for compact ones. A significant negative result is therefore a warning about the search, not evidence of an anti-circuit, and such searches should report extracted size alongside significance.
| Model | Target | Aligned, size | Aligned, components | Instruct, size | Instruct, components |
| CodeLlama-7B | Rust | 1 | L9MLP | 12 | full candidate set |
| CodeLlama-7B | C# | 40 | full candidate set | 12 | full candidate set |
| CodeLlama-7B | PHP | 1 | L9MLP | 12 | full candidate set |
| DeepSeek-Coder-1.3B | Rust | 40 | full candidate set | 6 | L6MLP, L8MLP, L19MLP, L17MLP, . . . |
| DeepSeek-Coder-1.3B | C# | 39 | L18MLP, L10H1, L13MLP, L21MLP, . . . | 6 | L13MLP, L21MLP, L12MLP, L5H3, . . . |
| DeepSeek-Coder-1.3B | PHP | 1 | L5MLP | 1 | L3MLP |
| DeepSeek-Coder-6.7B | Rust | 40 | full candidate set | 2 | L29MLP, L3MLP |
| DeepSeek-Coder-6.7B | C# | 2 | L5MLP, L29MLP | 1 | L11MLP |
| DeepSeek-Coder-6.7B | PHP | 2 | L25MLP, L29MLP | 12 | full candidate set |
| Qwen2.5-Coder-7B | Rust | 2 | L3MLP, L19H27 | 12 | full candidate set |
| Qwen2.5-Coder-7B | C# | 5 | L27H10, L0H6, L27H13, L18MLP, . . . | 12 | full candidate set |
| Qwen2.5-Coder-7B | PHP | 4 | L23MLP, L22MLP, L27H13, L24MLP | 12 | full candidate set |
| Qwen2.5-Coder-14B | Rust | 40 | full candidate set | 12 | full candidate set |
| Qwen2.5-Coder-14B | C# | 1 | L12MLP | 12 | full candidate set |
| Qwen2.5-Coder-14B | PHP | 11 | L33MLP, L36MLP, L43MLP, L18MLP, . . . | 1 | L23MLP |
Table 7. Circuit returned by greedy extraction (§ 3) per setting. “Full candidate set” means no compact subset reached 90% of the full-set effect.
Finding 5. Every significant away-pointing circuit comes from a setting where extraction failed to find a compact subset. It diagnoses the search, not the model.
Discussion
For practitioners. The preference is real and cheap to monitor—one forward pass—but it is not a reliable dial. Steering changes the next token in a fifth of settings, needs a coefficient searched per setting, and trades syntax for fluency past that point. Prompting and fine-tuning remain the dependable route.
For interpretability research. This is the result we think travels. Two knobs normally reported as setup—how many components the search keeps, and which prompts the metric is read on—moved our headline conclusions from “not localisable, never steerable” to “localisable in 6 of 15 settings, steerable in 9 of 45”, and from “a large, robust bias” to “a bias two orders of magnitude smaller”. Neither knob is exotic. Circuit papers should report a budget sweep the way ablation papers report a seed sweep, and state a localisation claim as a curve over budgets rather than a single number. Where a handful of neurons can toggle a multilingual model’s output language [22, 13], we find no comparably compact structure for code: identity there is signalled by many correlated cues, so no component is a bottleneck. Sparse-feature [6, 16] or edge-level [21] analyses are the natural next step.
Limitations
Metric. uses a small hand-chosen vocabulary read at one position; § 4.2 bounds the effect of set size without removing it, and the C# and PHP sets share markers with other C-family languages.
Method. Minimality is node-level and approximates edge attribution patching, and steering adds one difference-in-means display, so Finding 4 bounds these methods rather than all possible controls.
Scope. We test two budgets, one base language, three targets, and two sizes per family—enough to show that budget matters, not enough for a scaling law.
Conclusion
Code models’ preference for Python is large, grows with scale, and survives instruction tuning, but the mechanistic story about it is not stable under choices that look like setup. Raising the budget from 12 components to 40 takes the number of settings with a statistically specific circuit from 1 to 6; swapping the prompt suite takes the measured preference from 1.6 to 0.01; and every away-pointing circuit marks a failed search. We release the grid and the pipeline so these sweeps can be continued rather than assumed.
Configuration and implementation
All runs share the settings in Table 6. CodeLlama uses a TransformerLens HookedTransformer backend; DeepSeek-Coder and Qwen2.5-Coder, which are not in that registry, use the TransformerLens bridge backend, which wraps a Hugging Face model and re-exposes the same blocks.{layer}.attn.hook_z and blocks.{layer}.hook_mlp_out hook points, so one implementation of every intervention runs unchanged across backends. Attention-head interventions act on the per-head hook_z tensor and MLP interventions on hook_mlp_out. The mean-ablation cache is built once per run by averaging each hook’s activation over the prompt suite with the position axis reduced, so a single stored vector broadcasts over any sequence length. Qwen2.5-Coder produced NaN logits in fp16 on the bridge path, so all Qwen runs use bf16 and the others use fp16. Each run, together with its generation and CodeXGLUE evaluations, completes within a few GPU-hours on one A100-80GB.
| Setting | Value |
| Ablation | mean, over the prompt suite |
| Necessity budget | 12 and 40 |
| Minimality keep-fraction | 0.90 |
| Specificity random sets | 30 |
| Steering coefficients | |
| Aligned prompt pairs | 64 |
| XLCoST prompt pairs | 128 |
| Seed | 0 |
| Hardware | 1×A100-80GB |
| Precision | fp16 (bf16 for Qwen) |
Table 6. Shared experimental configuration.
Untagged control
The “No tag” column of Table 3 reports the mean over ten bare instruction prompts (for example, “Write a function that adds two numbers.”) with no # language tag. Negative means Python-leaning. Twelve of fifteen settings stay negative and the three exceptions are all PHP, which is consistent with PHP’s markers overcoming a weak untagged prior in the smaller models. The magnitudes are one to two orders below the tagged separation, so the unconstrained default is real but faint. The Qwen family shows a markedly stronger untagged default than CodeLlama or DeepSeek, and within Qwen the 7B is stronger than the 14B, so unlike the untagged effect does not grow monotonically with scale.
Component depth and away-pointing shifts
Figure 3 is the evidence behind § 4.7. It sums the individual patched shift of every candidate component by depth band in CodeLlama-7B, the model with the largest away-pointing result. Summing rather than averaging is the right summary here because the combined patch transplants all of them at once; note, though, that patching is not additive, so these sums do not equal the combined shifts in Table 5.
Extracted circuits per setting
Table 7 gives the circuit that greedy extraction returns in each setting. A small circuit does not by itself imply specificity: several single-component circuits in Table 7 fail the test in Table 4. The layers chosen share no pattern across models, which is further evidence against a transferable syntax circuit.
| Model | Target | Aligned, shift | Aligned, | Aligned, shift | Aligned, | Instruct, shift | Instruct, |
| CodeLlama-7B | Rust | +0.066{sup}* | 0.030 | +0.066{sup}* | 0.016 | -0.025 | 0.528 |
| C# | -0.412{sup}† | 0.030 | -0.429{sup}† | 0.011 | -0.351{sup}† | 0.012 | |
| PHP | -0.082{sup}† | 0.040 | +0.027 | 0.124 | -0.050 | 0.080 | |
| DeepSeek-Coder-1.3B | Rust | +0.010 | 0.670 | -0.040 | 0.659 | +0.040{sup}* | 0.012 |
| C# | -0.019 | 0.131 | +0.612{sup}* | 0.000 | +0.057 | 0.134 | |
| PHP | +0.050 | 0.131 | +0.049 | 0.094 | +0.014 | 0.171 | |
| DeepSeek-Coder-6.7B | Rust | +0.056 | 0.109 | -0.023{sup}† | 0.045 | +0.035 | 0.380 |
| C# | +0.005 | 0.300 | +0.023{sup}* | 0.031 | +0.031 | 0.442 | |
| PHP | -0.006 | 0.388 | +0.049{sup}* | 0.031 | +0.015 | 0.674 | |
| Qwen2.5-Coder-7B | Rust | -0.023 | 0.418 | +0.008 | 0.593 | +1.270{sup}* | 0.012 |
| C# | +0.017 | 0.418 | +0.036 | 0.398 | +0.000 | 0.674 | |
| PHP | -0.011 | 0.131 | +1.250{sup}* | 0.000 | -0.011 | 0.528 | |
| Qwen2.5-Coder-14B | Rust | -0.053 | 0.200 | -0.046 | 0.296 | -0.040 | 0.380 |
| C# | -0.030 | 0.131 | +0.018{sup}* | 0.031 | -0.026 | 0.419 | |
| PHP | +0.023 | 0.314 | +0.066 | 0.058 | +0.005 | 0.467 | |
| specific circuits | 1/15 | 6/15 | 2/15 |
Table 4. Specificity across component budgets. “shift” is the circuit’s mean patched shift in ; corrects the Welch test against 30 size-matched random sets within each column pair. {sup}* specific; {sup}† significant but pointing away from the target language.
Full steering sweep
Table 8 gives the value at every coefficient for the base-model grid plotted in Figure 2. Bold entries are coefficients at which the most likely next token is target syntax. Reading the table alongside Appendices G and H shows the problem with treating a metric crossing as a switch: several crossings occur at coefficients where generation has already degraded.
XLCoST detail
Table 9 separates the two terms of on the XLCoST suite. Both are near zero, which is why the separation collapses: at the scored position in naturally occurring code the model is not choosing between a Python and a target-language keyword, so almost no probability mass falls on either vocabulary. The comparison column repeats the aligned-prompt separation for the same model and language.
Table 8: on the Python prompt across the steering sweep, base models at . Bold marks coefficients where the most likely next token is target syntax.
| Model | Target | |||||
| CodeLlama-7B | Rust | -0.693 | -0.639 | -0.784 | -0.757 | -0.000 |
| C# | -0.693 | -0.931 | +0.351 | +0.101 | +0.163 | |
| PHP | -0.693 | -0.780 | -0.847 | -0.824 | -0.004 | |
| DeepSeek-Coder-1.3B | Rust | -0.730 | -0.361 | +0.011 | +0.870 | +0.835 |
| C# | -0.729 | +0.682 | +0.160 | +0.042 | +0.073 | |
| PHP | -0.729 | -0.670 | -0.623 | -0.646 | -0.000 | |
| DeepSeek-Coder-6.7B | Rust | -0.779 | -0.917 | +0.001 | -0.000 | +0.000 |
| C# | -0.779 | -0.681 | -0.569 | -0.427 | +0.856 | |
| PHP | -0.779 | -0.727 | -0.568 | +0.335 | +0.963 | |
| Qwen2.5-Coder-7B | Rust | -0.910 | -0.883 | -0.848 | -0.770 | -0.691 |
| C# | -0.910 | -0.867 | -0.742 | -0.173 | -0.116 | |
| PHP | -0.910 | +0.320 | +0.824 | +0.439 | +0.336 | |
| Qwen2.5-Coder-14B | Rust | -0.934 | -0.945 | -0.906 | -0.000 | -0.000 |
| C# | -0.934 | -0.902 | -0.902 | -0.949 | -0.762 | |
| PHP | -0.934 | -0.863 | +0.605 | +0.820 | +0.668 |
Table 8.
Table 9: XLCoST prompts: both terms of , the resulting separation, and the aligned-prompt separation for the same setting.
| Model | Target | (aligned) | |||
| CodeLlama-7B | C# | +0.0101 | -0.0017 | +0.0117 | 1.551 |
| PHP | +0.0007 | +0.0000 | +0.0007 | 1.597 | |
| DeepSeek-Coder-1.3B | C# | +0.0001 | +0.0060 | -0.0060 | 1.488 |
| PHP | +0.0004 | -0.0022 | +0.0025 | 1.538 | |
| DeepSeek-Coder-6.7B | C# | +0.0036 | -0.0075 | +0.0111 | 1.625 |
| PHP | +0.0001 | -0.0070 | +0.0071 | 1.623 | |
| Qwen2.5-Coder-7B | C# | +0.0021 | -0.0021 | +0.0042 | 1.758 |
| PHP | +0.0027 | +0.0004 | +0.0024 | 1.758 | |
| Qwen2.5-Coder-14B | C# | +0.0082 | -0.0003 | +0.0086 | 1.828 |
| PHP | +0.0003 | +0.0000 | +0.0003 | 1.801 |
Table 9.
Safe steering window
We call a coefficient safe when it classifies every target prompt as target-language and no control prompt as target-language. Table 10 reports the largest safe coefficient per setting for the two Qwen models. The window is strongly model- and language-dependent, which is the practical counterpart of the negative steering result: no single strength is safe everywhere. Qwen2.5-Coder-7B tolerates on Rust and on PHP, while its C# window collapses to . At 14B the pattern shifts again: Rust is best left unsteered, while C# and PHP have a genuine but narrow window at .
Table 10: Largest safe steering coefficient per setting. “Control FP” is the rate at which control prompts are wrongly classified as target-language.
| Model | Target | Safe | Target success | Control FP |
| Qwen2.5-Coder-7B | Rust | 8.0 | 1.00 | 0.00 |
| Qwen2.5-Coder-7B | C# | 0.0 | 1.00 | 0.00 |
| Qwen2.5-Coder-7B | PHP | 4.0 | 1.00 | 0.00 |
| Qwen2.5-Coder-14B | Rust | 0.0 | 1.00 | 0.00 |
| Qwen2.5-Coder-14B | C# | 2.0 | 1.00 | 0.00 |
| Qwen2.5-Coder-14B | PHP | 2.0 | 1.00 | 0.00 |
Table 10.
Control contamination
Table 11 sweeps on Qwen2.5-Coder-14B and reports the target-prompt success rate together with the rate at which control prompts are classified as target-language. C# exposes the failure most sharply: at steering is effective and clean, but at it injects 126–128 C# markers into prompts that should contain none. The apparent metric win at high is an indiscriminate push, not language control.
| Target | Target success | Control FP | Target markers in controls | |
| Rust | 0 | 1.00 | 0.00 | 0 |
| Rust | 4 | 0.00 | 0.00 | 0 |
| C# | 2 | 1.00 | 0.00 | 0 |
| C# | 4 | 1.00 | 1.00 | 126 |
| C# | 8 | 1.00 | 1.00 | 128 |
| PHP | 2 | 1.00 | 0.00 | 2 |
| PHP | 8 | 1.00 | 0.50 | 6 |
Table 11. Qwen2.5-Coder-14B control-contamination stress test.
Leave-one-out stress test
Starting from the CodeLlama-7B/Rust top-12 set at , we remove one component at a time and re-score the explicit Rust and control instruction suite. Every removal, including dropping the one specific circuit, leaves marker accuracy and F1 at 1.000, and the mean next-token stays within of the full-set value (Table 12). No single component is behaviourally load-bearing, which is what a redundant, multi-cue encoding predicts.
| Steering set | #comp. | Acc./F1 | Mean |
| no steering | 0 | 1.000 | 0.280 |
| full top-12 | 12 | 1.000 | 0.313 |
| −L0MLP | 11 | 1.000 | 0.312 |
| −L1MLP | 11 | 1.000 | 0.313 |
| −L29MLP | 11 | 1.000 | 0.299 |
| −L9MLP | 11 | 1.000 | 0.306 |
| −L7MLP | 11 | 1.000 | 0.311 |
| −L5MLP | 11 | 1.000 | 0.311 |
| −L4MLP | 11 | 1.000 | 0.310 |
Table 12. CodeLlama-7B/Rust leave-one-out steering at (representative rows; all twelve removals give accuracy/F1 = 1.000).
CodeXGLUE under steering
We cast two CodeXGLUE tasks [15], big-clone-bench clone detection and defect detection, as zero-shot yes/no next-token decisions: the prompt states the task and ends in “Answer:”, and we compare the summed probability of affirmative label tokens against negative ones on class-balanced samples, so 0.50 is chance. This is a negative control. If the steering direction encoded task competence rather than surface syntax, steering would move these scores. It does not (Table 13). The only movement is at on defect detection, where the label bias shifts and macro-F1 rises to 0.491 — a redistribution of a degenerate predictor, not an accuracy gain.
| Task | Acc. | F1 | Macro F1 | |
| clone | 0 | 0.500 | 0.667 | 0.333 |
| clone | 1 | 0.500 | 0.667 | 0.333 |
| clone | 8 | 0.500 | 0.667 | 0.333 |
| defect | 0 | 0.500 | 0.667 | 0.333 |
| defect | 1 | 0.500 | 0.667 | 0.333 |
| defect | 8 | 0.531 | 0.348 | 0.491 |
Table 13. Zero-shot CodeXGLUE [15] under steering. Accuracy stays at chance; the defect shift is a label-bias artifact.
References
- [1]Andy Arditi, Oscar Obeso, Aaquib Syed, Daniel Paleka, Nina Panickss ery, Wes Gurnee, and Neel Nanda. Refusal in language models is mediated by a single direction. In Advances in Neural Information Processing Systems, 2024.arxiv.org/abs/2406.11717
- [2]Leonard Bereska and Efstratios Gavves. Mechanistic interpretability for AI safety – a review. Transactions on Machine Learning Research, 2024.arxiv.org/abs/2404.14082
- [3]Trenton Bricken, Adly Templeton, Joshua Batson, Brian Chen, Adam Jermyn, Tom Conerly, et al. Towards monosemanticity: Decomposing language models with dictionary learning. Transformer Circuits Thread, 2023.
- [4]Federico Cassano, John Gou war, Daniel Nguyen, Sydney Nguyen, Luna Phipps-Costin, Donald Pinckney, et al. MultiPL-E: A scalable and polyglot approach to benchmarking neural code generation. IEEE Transactions on Software Engineering, 49(7):3675–3691, 2023.DOI
- [5]Arthur Conmy, Augustine N. Mavor-Parker, Aengus Lynch, Stefan Heimersheim, and Adrià Garriga-Alonso. Towards automated circuit discovery for mechanistic interpretability. In Advances in Neural Information Processing Systems, 2023.arxiv.org/abs/2304.14997
- [6]Hoagy Cunningham, Aidan Ewart, Logan Riggs, Robert Huben, and Lee Sharkey. Sparse autoencoders find highly interpretable features in language models. In International Conference on Learning Representations, 2024.arxiv.org/abs/2309.08600
- [7]Nelson Elhage, Tristan Hume, Catherine Olsson, Nicholas Schiefer, Tom Henighan, Shauna Kravec, et al. Toy models of superposition. Transformer Circuits Thread, 2022.arxiv.org/abs/2209.10652
- [8]Atticus Geiger, Hanson Lu, Thomas Icard, and Christopher Potts. Causal abstractions of neural networks. In Advances in Neural Information Processing Systems, 2021.arxiv.org/abs/2106.02997
- [9]Atticus Geiger, Zhengxuan Wu, Christopher Potts, Thomas Icard, and Noah D. Goodman. Finding alignments between interpretable causal variables and distributed neural representations. In Causal Learning and Reasoning (CLeAR), pages 160–187, 2024.arxiv.org/abs/2303.02536
- [10]Daya Guo, Qihao Zhu, Dejian Yang, Zhenda Xie, Kai Dong, Wentao Zhang, et al. DeepSeek-Coder: When the large language model meets programming – the rise of code intelligence. arXiv preprint arXiv:2401.14196, 2024.arxiv.org/abs/2401.14196
- [11]Roee Hendel, Mor Geva, and Amir Globerson. In-context learning creates task vectors. In Findings of the Association for Computational Linguistics: EMNLP, pages 9318–9333, 2023.
- [12]Binyuan Hui, Jian Yang, Zeyu Cui, Jiaxi Yang, Dayiheng Liu, Lei Zhang, et al. Qwen2.5-Coder technical report. arXiv preprint arXiv:2409.12186, 2024.arxiv.org/abs/2409.12186
- [13]Takeshi Kojima, Itsuki Okimura, Yusuke Iwasawa, Hitomi Yanaka, and Yutaka Matsuo. On the multi-lingual ability of decoder-based pre-trained language models: Finding and controlling language-specific neurons. In Proceedings of the 2024 Conference of the North American Chapter of the Association for Computational Linguistics, 2024.
- [14]Kenneth Li, Oam Patel, Fernanda Viégas, Hanspeter Pfister, and Martin Wattenberg. Inference-time intervention: Eliciting truthful answers from a language model. In Advances in Neural Information Processing Systems, 2023.arxiv.org/abs/2306.03341
- [15]Shuai Lu, Daya Guo, Shuo Ren, Junjie Huang, Alexey Svyatkovskiy, Ambrosio Blanco, et al. CodeXGLUE: A machine learning benchmark dataset for code understanding and generation. In Proceedings of the Neural Information Processing Systems Track on Datasets and Benchmarks, 2021.arxiv.org/abs/2102.04664
- [16]Samuel Marks, Can Rager, Eric J. Michaud, Yonatan Belinkov, David Bau, and Aaron Mueller. Sparse feature circuits: Discovering and editing interpretable causal graphs in language models. In International Conference on Learning Representations, 2025.arxiv.org/abs/2403.19647
- [17]Kevin Meng, David Bau, Alex Andonian, and Yonatan Belinkov. Locating and editing factual associations in GPT. In Advances in Neural Information Processing Systems, 2022.arxiv.org/abs/2202.05262
- [18]Neel Nanda and Joseph Bloom. TransformerLens. https://github.com/TransformerLensOrg/TransformerLens, 2022.
- [19]Kiho Park, Yo Joong Choe, and Victor Veitch. The linear representation hypothesis and the geometry of large language models. In International Conference on Machine Learning, pages 39643–39666, 2024.arxiv.org/abs/2311.03658
- [20]Baptiste Rozière, Jonas Gehring, Fabian Gloeckle, Sten Sootla, Itai Gat, Xiaoqing Ellen Tan, et al. Code Llama: Open foundation models for code. arXiv preprint arXiv:2308.12950, 2023.arxiv.org/abs/2308.12950
- [21]Aaquiib Syed, Can Rager, and Arthur Conmy. Attribution patching outperforms automated circuit discovery. In Proceedings of the 7th BlackboxNLP Workshop, pages 407–416, 2024.arxiv.org/abs/2310.10348
- [22]Tianyi Tang, Wenyang Luo, Haoyang Huang, Dongdong Zhang, Xiaolei Wang, Xin Zhao, Furu Wei, and Ji-Rong Wen. Language-specific neurons: The key to multilingual capabilities in large language models. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics, pages 5701–5715, 2024.arxiv.org/abs/2402.16438
- [23]Adly Templeton, Tom Conerly, Jonathan Marcus, Joshua Batson, Brian Rosen, Hoagy Cunningham, et al. Scaling monosemanticity: Extracting interpretable features from Claude 3 Sonnet. Transformer Circuits Thread, 2024.
- [24]Eric Todd, Millicent L. Li, Arnab Sen Sharma, Aaron Mueller, Byron C. Wallace, and David Bau. Function vectors in large language models. In International Conference on Learning Representations, 2024.arxiv.org/abs/2310.15213
- [25]Alexander Matt Turner, Lisa Thiergart, Gavin Leech, David Udell, Juan J. Vazquez, Ulisse Mini, and Monte MacDiarmid. Steering language models with activation engineering. arXiv preprint arXiv:2308.10248, 2023.arxiv.org/abs/2308.10248
- [26]Jesse Vig, Sebastian Gehrmann, Yonatan Belinkov, Sharon Qian, Daniel Nevo, Yaron Singer, and Stuart Shieber. Causal mediation analysis for interpreting neural NLP: The case of gender bias. In Advances in Neural Information Processing Systems, 2020.arxiv.org/abs/2004.12265
- [27]Kevin Ro Wang, Alexandre Variengien, Arthur Conmy, Buck Shlegeris, and Jacob Steinhardt. Interpretability in the wild: A circuit for indirect object identification in GPT-2 small. In International Conference on Learning Representations, 2023.arxiv.org/abs/2211.00593
- [28]Fred Zhang and Neel Nanda. Towards best practices of activation patching in language models: Metrics and methods. In International Conference on Learning Representations, 2024.arxiv.org/abs/2309.16042
- [29]Qinkai Zheng, Xiao Xia, Xu Zou, Yuxiao Dong, Shan Wang, Yufei Xue, et al. CodeGeeX: A pre-trained model for code generation with multilingual benchmarking on HumanEval-X. arXiv preprint arXiv:2303.17568, 2023.arxiv.org/abs/2303.17568
- [30]Ming Zhu, Aneesh Jain, Karthik Suresh, Roshan Ravindran, Sindhu Tipirneni, and Chandan K. Reddy. XLCost: A benchmark dataset for cross-lingual code intelligence. arXiv preprint arXiv:2206.08474, 2022.arxiv.org/abs/2206.08474
- [31]Andy Zou, Long Phan, Sarah Chen, James Campbell, Phillip Guo, Richard Ren, et al. Representation engineering: A top-down approach to AI transparency. arXiv preprint arXiv:2310.01405, 2023.arxiv.org/abs/2310.01405

