Can a frontier model edit the weights of a small model with no training to make it answer in the language it is asked for? This note explores it in two settings, a translation request in the user prompt and a language set in the system prompt. For each, Claude Code measured the failure, located it, edited it with a patch - a change to Qwen3.5-0.8B's weights - and measured what the patch costs. For the translation request, Claude built a patch with a single edit on one layer 16 MLP projection, and then generalized the same steps as a program, which was executed over 30 languages. It found 17 languages that drift and was able to build a patch for 13 of them. Across these 13 languages, the translations in the requested language went from 38% to 79% on average on held out paragraphs, and six of them reached 90% or more. For the system prompt, an edit of ten weight rows in two attention layers - only 0.0012% of total model weights - increased the replies in the requested language from 5% to 54% on held out questions.
HF: hajili/weight-space-programming-against-language-confusion
GitHub: mammadhajili/wsp-language-drift
A recent article by Takehi and Teoh et al.11 Sparks of Weight-Space Programming: LLMs can natively read & write neural network weights, 2026 introduced the idea of weight-space programming. It showed GPT-6 Astra reading the activations of Qwen3.5-0.8B and editing its weights with no training, which lifted the model's MATH-500 score from 7.9% to 48.1%, essentially by healing its reasoning loop.1 Sparks of Weight-Space Programming: LLMs can natively read & write neural network weights, 2026
I thought this idea could be a good fit for the language drift problem in multilingual language models. Small models especially reply in a language other than the one they are prompted in or asked for, a failure Marchisio et al.22 Marchisio et al. 2024 call language confusion. In machine translation a similar problem is known as off-target translation33 Zhang et al. 2020.2 Marchisio et al. 20243 Zhang et al. 2020
To this end, I experimented with weight-space edits on Qwen3.5-0.8B in a single Claude Code session, alternating44 When I was running these experiments, Anthropic limited Fable usage. between Fable 5.2 and Opus 5.5 Max Reasoning. I set several ground rules for the experiments:4 When I was running these experiments, Anthropic limited Fable usage.
- No training: every change to the weights is computed in closed form from the model's activations, with no gradient steps.
- Claude Code as a teacher: with minimal manual intervention, the Claude models reasoned, probed the activations, judged the results and chose the next experiment.
- Held out data: weight edits are built and chosen on probing prompts, then scored on held out prompts against the unedited model on the same prompts.
- Labels: GlotLID55 Kargaran et al.,2023 labels the language of each reply.5 Kargaran et al.,2023
- Thinking: off throughout the experiments.
Data
The prompts come from three public sources:
| Source | What it holds | Used for |
|---|---|---|
| Belebele66 Bandarkar et al. 2023 | 488 English passages with 900 reading-comprehension questions, all translated by people into 121 other languages | the screen, the system-prompt questions, and the held out tests of the Norwegian patch6 Bandarkar et al. 2023 |
| FLORES+77 NLLB Team et al. 2022 | the sentences Belebele's passages are made of, in the same languages | fitting the drift patches, chrF, and the four drift examples7 NLLB Team et al. 2022 |
| English Wikipedia introductions88 From the HotpotQA corpus (Yang et al. 2018). | 2400 paragraphs of 250-600 characters, with no translations | the program over 30 languages and the summarize prompts8 From the HotpotQA corpus (Yang et al. 2018). |
Each Belebele passage is the same text in each language, so its copy in a given language serves as the reference translation of the English one. Belebele and FLORES+ texts overlap, so Claude split them together using a fixed hash of each passage. It used 254 passages for probing and 234 as held out passages to test the unedited and patched models. The Wikipedia paragraphs used here have no text overlap with the other two sources. Claude added them later when Belebele passages had already been used for earlier tests. It split them the same way, 1200/1200 for probing and held out.
A translation request in the user turn
The first experiment was Claude screening over every language in the Belebele dataset. For each language besides English, it gave the model 60 English passages with a single line in the user prompt without any system prompt.
As a control, the model got 100 passages written in the original language without any instruction. For every language shown below, it answered in the same language 79-100% of the time. This means the model is able to produce each when it is addressed in the original language. But when asked in English, it often translated into a different language - a close relative or the "main" language of the region where the language is spoken. Below are four examples of such drift, where the language the model replied in is the request's neighbor or relative.
Where the translations of each drifting language land:
The Norwegian patch
Claude started patches with Norwegian because it was the clearest case. During the screen, 41 of its 45 wrong translations went to Danish. It applied a single weight matrix edit which fixed most of the translation drift. After the patch, on 234 held out passages, translations that came back correctly in Norwegian went from 47% to 94%. The figure below shows step by step how Claude built this Norwegian patch. After the screen and the check, three stages shaped it, each one leading to the next:
- Stage 3: Claude found a behavior where the first k tokens of the correct translation lead the model to continue in the correct language. With 8 forced tokens, 79% of replies carried on in Norwegian, and with 20 tokens, 96%. So the reply language is decided around the first 10 tokens, which lead the model to continue writing in Norwegian. This gave stages 4 and 5 their window. Claude looked only at the start of the reply and the first 12 tokens.
- Stage 4: In that window, Claude checked if the model still recalls that Norwegian was asked for while it is generating a translation in Danish. It gave the model the same Danish reply twice, once after a Norwegian request and once after a Danish request. The only difference between these two checks is the language asked for in the request. Claude then implemented a probe, a simple linear classifier on the activations, and used it to guess which request each check was run with. If the probe guesses correctly around 50% of the time, the probed layer has forgotten the requested language, and close to 100% means it still recalls it. The probe at layer 16 guessed right 98% of the time, which means at layer 16 the model still knows that Norwegian was asked for, but it is not acting on it.
- Stage 5: Based on the probe results in Stage 4, Claude then built the patch in layer 16 as a two-part rule. First, the key reads 3584 neurons and returns a score close to 1 when Norwegian is the requested language, and close to 0 for any other language request. Second, the push is the difference in model state between writing Norwegian and writing Danish. At each word, the patch adds the push times the key’s score to the model's state. This pushes Norwegian requests towards Norwegian, and as Stage 3 showed, once the first words are Norwegian, the model keeps going in Norwegian.
How the patch works
The model carries a state of 1024 numbers per token and passes this running state through 24 layers, each of which adds something to it99 Elhage et al. 2021. In the MLP of each layer, the last step is a 1024x3584 projection that turns the neurons into what is added to the state. The patch adds one extra grid to this projection1010 The same kind of rank-1 edit changes facts in ROME: Meng et al. 2022, built only from the key k and the push v: each neuron's copy of the push v is scaled by its key weight1111 Reading the MLP as keys and values: Geva et al. 2021. When the neurons fire in the pattern of a request for the target language (in this case, Norwegian), the grid adds up to the push times the key's score. For any other request, the entries cancel out, because the key's score is near zero. A patch of this kind, one key and one push in layer 16 for one language, is a drift patch. This means the patch is built from 3584 + 1024 = 4608 numbers, but as the grid touches every entry of the 1024x3584 projection, it changes about 0.4% of the model's weights.9 Elhage et al. 202110 The same kind of rank-1 edit changes facts in ROME: Meng et al. 202211 Reading the MLP as keys and values: Geva et al. 2021
Generalizing to other languages
Claude tried to generalize this framework into a program whose steps were finding the neighbor, fitting the key and push, and raising the strength until requests for the neighbor or other languages started losing replies in their own language, or until chrF1212 A character-overlap score against a reference translation (Popović 2015), here its chrF++ variant on FLORES sentences. falls. This program ran on 30 languages, found 17 with the same translation failure, and built a drift patch for 13 of them. The chart below tests each patch on 300 held out Wikipedia paragraphs.12 A character-overlap score against a reference translation (Popović 2015), here its chrF++ variant on FLORES sentences.
Limits and costs
- Javanese and Sundanese. The model is weak for both languages. For a Sundanese passage with no instruction, the response was in Sundanese only 79% of the time. In this drift experiment, even the weakest patch turned replies into invented words and chrF dropped by around 6 points.
- Unchecked languages. The program checked each patch only on its neighbor and on the three other languages its key fires on the most. The Greek patch turned 35 of 60 replies asked in Albanian into Greek, and Albanian was not on that list.
- A shared patch fails. Claude also tried one patch for all the languages that drift into Russian. It learned to leave Cyrillic script, but that dropped Kyrgyz from 50% to 5%, with replies going to a closer language like Uyghur and, surprisingly, also to distant languages like Armenian and Hungarian. This showed that a shared patch approach was not able to generalize.
- Translation quality does not improve. A reply converted by the patch is about as good as the model's own replies in that language (for Norwegian, a sentence chrF of 44 against 46). For Kazakh, Kyrgyz, Mongolian and Azerbaijani, chrF moved by less than one point.
- More replies loop. For the languages that drift into Russian, more long replies get stuck repeating a phrase after the patch - for Mongolian, replies without a loop dropped from 84% to 31%. The patch itself does not cause the loops, the model loops as often in Kazakh with or without the patch (58% and 60%), but now more replies are in these languages.
A language set in the system prompt
In the second experiment, Claude moved the language into the system prompt, where an application would usually set it once, and asked a question in English. It ran this across 25 languages:
Across the 25 languages, only 6% of the replies came in the language requested. In this experiment, unlike language drift, the wrong replies were not in the neighbor or regional languages. 86% of all replies were in English. As a control experiment, on a smaller screen over 8 languages, Claude moved the same instruction to the end of the user prompt instead of the system prompt, and 88% of the replies came in the given language, against 7% with the instruction in the system prompt. This showed that the model is capable of following the instruction, but failed to do so when it was given in the system prompt.
Building the attention patch
Claude prepared a patch for this issue and targeted ten weight rows in two attention layers which make the start of the reply read the system prompt. On held out questions, averaged over four different system prompt variations1313 "Always respond in X."; "You are an assistant that replies only in X, even when the user writes in another language."; "Language: X"; "You are a helpful assistant. The user's preferred language is X.", this attention patch increased the replies in the correct target language from 5% to 54%. The figure below shows step by step how Claude built this patch. As with the drift patch, after the screen, the following five stages progressively shaped the mechanism.13 "Always respond in X."; "You are an assistant that replies only in X, even when the user writes in another language."; "Language: X"; "You are a helpful assistant. The user's preferred language is X."
- Stage 2: On 128 probing prompts in 8 languages, Claude ran the instruction in the system prompt and in the user prompt. It then copied the start of the reply from the user prompt run into the system prompt run. Changing only the first token raised the replies in the requested language from 8% to 80%. This shows, as in the drift runs, that the language is decided in the very first tokens of the reply, and in the system prompt run the instruction that mentions the language does not reach those first tokens.
- Stage 3: It then focused on the start of the reply, which can only learn what the instruction says through the model's attention. To find which layer the instruction actually travels through, the instruction was hidden from the reply one layer at a time. With the instruction in the user prompt, hiding it in layer 11 dropped the replies in the requested language from 89% to 20%, while hiding it in any other layer changed little. This means layer 11 is the layer that brings the instruction to the start of the reply, and when it cannot read it, no other layer makes up for it.
- Stage 4: Then it measured how much layer 11 looks at the instruction. Across its heads, the start of the reply gives the instruction 6% of its attention when it is in the system prompt, against 18% when it is in the user prompt. This means the instruction in the system prompt mostly does not get delivered.
- Stages 5 and 6: Based on Stages 3 and 4, the next step was making layer 11 look harder at the system prompt, one head at a time, without any weight change at this step. For each attention head, the start of the reply gives every earlier token a score that sets how much it reads from that token. During execution, a fixed boost was added to the scores the start of the reply gives the system prompt tokens. On 250 probing prompts with "Always respond in X.", boosting head 7 raised the replies in the target language from 8% to 63%. Then, using this boosted run, Claude made the fix permanent by patching ten rows of the attention weights to imitate the effect of the boost. Adding layer 7, an earlier layer that also reads the instruction, helped more than a stronger boost, so the final ten rows are in layers 7 and 11 and give 81-98% of the effect of the boost.
How the attention patch works
For every attention head, the transformer model turns the state of each token into a query and a key, each a vector with 256 numbers. An attention score between two tokens is the dot product of the first token's query and the second one's key. The first 64 dimensions map to the rotary position code, and the rest of them, 192 dimensions, give the same term wherever the two tokens are in the prompt. The attention patch takes the one of those 192 dimensions whose term contributed least to the attention score and edits its rows in both the key and query matrices. Similar to probing in the drift patch, here this row in the key matrix becomes a classifier that returns a score around 1 for the system prompt tokens and around 0 for any other token. The query matrix rows become classifiers that return close to 1 for the positions right before the reply starts. This basically means the term for the dimension turns into a product of two classifiers. When the start of the reply attends to a system prompt token, both become around 1, and their product creates the score boost from Stage 5. In layers 7 and 11, Claude edited 5 rows of 1024 weights each, so the patch has 10 × 1024 = 10240 weights in total, which is 0.0012% of the model's weights. Below is the visualization that shows this mechanism for layer 11 - one key row and the query rows of the four heads that share it:
Limits and costs
- User prompt requests are followed less. For "Summarize the text below in one or two sentences. Reply in X.", the replies in the requested language dropped from 47% to 37% across 30 languages.
- System prompt wording. For "The user's preferred language is X.", the patch only moved the replies from 0% to 11%.
Closing
Claude also ran the same tests on two larger models, Qwen3.5-4B and Gemma-4 E2B, and neither drifted in translation, with 100% and 98% of their replies following a language set in the system prompt. Claude then tried to move some of the 4B's translation ability into the 0.8B model with a closed-form patch. The two models share a tokenizer, so on the same translations Claude could compare which next token each model picks. For each token, there is a shift of the 0.8B model's last-layer state that raises its agreement with the 4B from 63% to 84%. Claude fitted a patch that predicts this shift from the 0.8B model's own activations, and on held out sentences the patch closed none of the gap.
The patches are on Hugging Face, and the program that builds a drift patch for a new language, the patch builders and the held out tests are on GitHub.
Citation
Please cite this note as:
Mammad Hajili. "Weight-space programming against language confusion in a small model." November 2026. https://mhajili.com/notes/weight-space-programming/
or in BibTeX:
@misc{hajili2026languageconfusion,
title = {{Weight-space programming against language confusion in a small model}},
author = {Hajili, Mammad},
year = {2026},
month = nov,
howpublished = {\url{https://mhajili.com/notes/weight-space-programming/}},
note = {Blog post}
}