How Do Language Models Speak Languages? A Case Study on Unintended Code-Switching

Yuxin Xiao, Zhen Huang, Wenxiao Wang, Binbin Lin, Xiaofei He, Xu Shen, Jieping YeOpenReview 2026 · Submission to ICLR 2026 · Rejected

TL;DR

Researchers have developed a scalable framework to map the internal "circuits" that govern how LLMs choose which language to speak. They discovered that unintended language switching (code-switching) occurs when language-agnostic semantic signals overpower language-specific control circuits, and they demonstrated that fine-tuning just 0.019% of a model's neurons can significantly reduce these linguistic errors.

What Problem Does This Paper Address?

Large Language Models (LLMs) are impressively multilingual, but they suffer from a frustrating quirk: unintended code-switching. This is when a model suddenly swaps languages mid-sentence (e.g., starting a summary in French but finishing a key phrase in Chinese).

While humans code-switch naturally, model-generated switches often violate linguistic rules and seem unpredictable. Until now, we haven't known why this happens or where in the billions of parameters these decisions are made. Existing methods to study this—like training Sparse Autoencoders—are computationally expensive and often leave a "gap" in interpretation. The authors sought a way to causally localize the specific neurons responsible for language selection and understand the tug-of-war that leads to linguistic confusion.

Methods

The authors introduce a scalable circuit discovery framework consisting of three main stages:

  1. Hierarchical Attribution Patching: Instead of just looking at which neurons affect the final output, this method traces causal links from one component to another (e.g., how an early layer neuron affects a middle layer neuron). This allows them to map an end-to-end "circuit" of information flow.
  2. Automated Neuron Description: To avoid manual labeling, they use an "explainer" LLM to analyze a neuron's top activation samples and its projections into the vocabulary. The explainer then generates a textual description (e.g., "This neuron activates on French prepositions").
  3. Neuron Grouping: LLMs are used again to cluster these described neurons into functional "super-neurons" based on language (e.g., French-related) or semantics (e.g., horror-related).

By manipulating these identified circuits—turning them up, down, or off—the researchers could prove their causal role in language generation.

Datasets

The study utilized a wide array of open-source datasets for both discovery and evaluation:

  • CounterFact: Used to build contrastive pairs (e.g., "Angola is located in..." vs. "Angola liegt in...") to isolate language-specific neurons.
  • XLSum: A multilingual summarization dataset used to measure how much performance drops when specific neurons are deactivated.
  • Language Confusion Benchmark (LCB): Used to measure the baseline rate of unintended code-switching.
  • Aya Dataset: A massive multilingual instruction-tuning dataset used for the targeted fine-tuning experiments.
  • Task-Specific Sets: FLORES-200 (translation), MIFEval (instruction following), XQuAD/MKQA/JaQuAD (QA), and UltraChat (conversation) were used to test the generalizability of their findings across different types of AI interaction.

Key Insights and Ideas

  • The Two-Regime Architecture: Multilingual generation isn't a monolithic process. It relies on two distinct regimes:
  • The Language Regime: Acts like a "lingual key," detecting and promoting the intended language.
  • The Semantic Regime: Handles language-agnostic concepts (the "what" rather than the "how").
  • Competition, Not Confusion: Code-switching isn't the model "forgetting" the language; it's a failure of hierarchy. In normal generation, the two regimes converge smoothly. In code-switching scenarios, the semantic circuit dominates, bypassing the language-specific pathways to drive the output directly.
  • Extreme Sparsity: The circuits governing these complex behaviors are tiny. The researchers found that multilingual capabilities are concentrated in less than 0.2% of the model's neurons.
  • English as the "Internal Language": The results support the theory that LLMs often perform internal reasoning in a dominant language (usually English) before "translating" that thought through language-specific neurons in the final layers.

Key Results

  • Causal Necessity: Deactivating just 0.018% of identified language neurons led to a staggering 93.9% drop in multilingual generation performance, proving these neurons are critical "bottlenecks."
  • Effective Mitigation: By fine-tuning only the identified language sub-circuits (~0.19% of neurons), the researchers reduced the code-switching rate by 20.8% (measured by Language Consistency Rate).
  • Attribution Ratios: In successful generations, language neurons have 2.37x more influence (attribution) than semantic neurons. In code-switched cases, this lead narrows significantly to 1.21x, providing a clear mathematical signal for when a model is about to fail.
  • Steerability: The authors showed they could "recover" a correct language response by manually up-weighting the language super-neurons, demonstrating that these circuits are highly steerable.

Limitations and Future Work

  • Component Scope: This study focused primarily on MLP (Multi-Layer Perceptron) neurons. The authors acknowledge that future work needs to incorporate attention blocks and cross-token interactions to get a truly complete picture of the circuit.
  • Reasoning Integration: While they localized where language is selected, they haven't yet fully mapped how the model integrates complex reasoning with that multilingual knowledge.
  • Intervention Strength: The researchers noted they often had to use "overcompensation" (clamping neurons to negative values rather than just zero) to see effects, suggesting their current circuit maps are still missing some secondary pathways.

Summary updated

Abstract

Unintended code-switching, which refers to the phenomenon where LLM unexpectedly switch languages, poses a fundamental challenge in the multilingual capabilities in LLMs. However, the fundamental properties of their underlying circuits, such as what they consist of, where they emerge in the network, and how to mitigate their effects, remain unexplored. Existing works on the mechanistic interpretability depend on additional training (e.g., sparse autoencoders) or manual annotation, both of which pose limitations in real-world scenarios. In this work, we introduce a scalable circuit discovery framework that causally localizes multilingual neurons, describes their functional patterns, and groups neurons into circuits. We find that the circuits for multilingual generation fall into two different regimes: a language regime which acts as a lingual key to detect language patterns, and a semantic regime which functions as a contextual value to retrieving language-agnostic semantics. These two regimes, in normal cases, converge smoothly to make final predictions, but in code-switching scenarios, semantics dominate the circuit, overriding typical language pathways and destabilizing outputs. Furthermore, we fine-tune the identified language sub-circuit ($\sim0.019$\% of all neurons), reducing the code-switching rate by $20.8$\% with minimal parameter updates, validating the effectiveness of the discovered circuits for practical scalability. Our work serves as a preliminary exploration of multilingual generation circuits, offering actionable insights for neuron-based mechanistic interpretability.
BibTeX
@misc{xiao2026how,
  author = {Yuxin Xiao and Zhen Huang and Wenxiao Wang and Binbin Lin and Xiaofei He and Xu Shen and Jieping Ye},
  title = {{How Do Language Models Speak Languages? A Case Study on Unintended Code-Switching}},
  year = {2026},
  url = {https://openreview.net/forum?id=HIXPyQ1aMq},
  howpublished = {OpenReview},
  note = {Submitted to ICLR 2026},
}
Figure