Why Do Large Language Models Switch to English During Chinese Reasoning?

    This article explains why large language models often drift from Chinese into English in the middle of chain-of-thought reasoning. It frames the behavior through code-switching in bilingual speakers and traces it to three causes: uneven language distribution in pretraining data, the path-dependent nature of token-by-token reasoning, and decoding settings combined with weak prompt constraints. It then outlines practical fixes at the prompt, decoding, context, output, and evaluation layers, including sample constraint text and a Python language-detection guard, and closes with common misconceptions to avoid.

    Why Do Large Language Models Switch to English During Chinese Reasoning?

    When developers use large language models for Chinese tasks, they often run into a familiar pattern: the question is in Chinese, the first part of the model’s reasoning is in Chinese, and then an English passage appears midway through, or the entire conclusion comes back in English. The first instinct is usually “the model has a bug” or “the context got corrupted.” From a mechanism standpoint, though, this is neither a random failure nor a necessary sign of degraded capability. It is a common outcome of multilingual modeling, autoregressive chain-of-thought generation, and the decoding process working together.

    1. An Intuitive Analogy: Code-Switching in Bilingual Speakers

    Linguistics has a concept called code-switching, where bilingual speakers mix two languages within the same stretch of speech. A speaker who is fluent in both Mandarin and a regional dialect may naturally drop dialect words into standard Mandarin, for example: “I’m going to the beach, I’m going to dig for clams, I’m going to the aquarium.” The sentence frame is standard, but individual words come from a different language system. This is not a slip; it is the result of two language systems being active at the same time.

    A large language model’s “multilingual native tongue” behaves very similarly. In a model trained on multilingual corpora, Chinese and English are not in a “primary language versus foreign language” relationship. They are closer to two expression systems that are both strongly activated. When a task reaches a reasoning stage that demands precision, abstraction, and low ambiguity, the model tends to draw on the language with the strongest training signal for that stage, producing mixed output: a Chinese frame with English terms or English paragraphs.

    2. Cause One: Uneven Language Distribution in Pretraining Data

    English makes up a significantly larger share of publicly available high-quality corpora, especially in mathematics, code, formal reasoning, and academic writing. This has two direct consequences:

    • Terminology anchors skew English: Some concepts are bound more tightly to their English forms inside the model, while the Chinese expression requires an extra step. English is therefore more likely to surface at high-information-density points.
    • The “low-entropy path” of reasoning skews English: During generation, the model favors continuations with more concentrated probability that feel more natural. At certain reasoning nodes, an English fragment is that low-entropy path.

    It is worth stressing that this is a statistical tendency created by corpus distribution, not evidence that the model “understands English better.” Chinese corpora also supply plenty of training signal for Chinese semantic understanding, local knowledge, and cultural context.

    3. Cause Two: Chain-of-Thought Generation Amplifies Language Drift

    Chain-of-thought reasoning is generated token by token in an autoregressive manner, and each step is conditioned on what has already been generated. This makes language choice path-dependent: once an English term or short English phrase appears midway, subsequent content is conditioned on it and continues to expand from there. The drift reinforces itself and grows larger.

    You can think of it as a kind of “language inertia”:

    1. Step n: Chinese reasoning → needs to express "attention head"
    2. Step n+1: outputs the English term (higher probability)
    3. Step n+2: conditioned on the English term → following sentence structure turns English
    4. Step n+3: the whole conclusion becomes English

    In addition, when a task is broken into subproblems, the model may switch its “internal working language” between subtasks, using the more effortless language locally and then summarizing in the main language. Externally, this looks like the language jumping back and forth.

    4. Cause Three: Decoding Strategy and Insufficient Prompt Constraints

    • Sampling randomness: When temperature is high and the top-p range is wide, low-probability cross-language tokens are more likely to be selected.
    • Conflicting prompt signals: The system prompt is in Chinese, the retrieved reference material is in English, and the context also contains code and English logs. The model treats all of these as language cues and may “follow” one of them.
    • Lack of hard constraints: If the prompt only says something soft like “please answer in Chinese,” the constraint is diluted over a long reasoning chain.

    5. Engineering-Side Remedies

    1. Prompt Layer: Write Language Requirements as Executable Constraints

    1. Requirements:
    2. 1. Use Simplified Chinese for all reasoning and answers;
    3. 2. When an English term is necessary, use the form "Chinese (English)" on first
    4. appearance, then use Chinese consistently afterward;
    5. 3. Keep code, variable names, and raw log text as-is; do not translate them;
    6. 4. If the output language drifts away from Chinese, correct it immediately and continue.

    At the same time, keep the language of the system prompt, user input, and reference material consistent to reduce conflicting signals.

    2. Decoding Layer: Lower the Probability of Drift

    • Lower the temperature moderately and narrow the sampling space;
    • For scenarios with high demands on factual accuracy and stability, prefer more deterministic decoding methods;
    • Control the length of a single generation and advance long tasks in segments to avoid accumulating inertia.

    3. Context Layer: Govern Retrieved Content

    For retrieval-augmented scenarios, normalize the language first: unify the summary language, convert English material into Chinese key points before feeding it into the chain, and keep a necessary glossary of original terms. The “purer” the context, the more stable the model’s language anchors.

    4. Output Layer: Detection and Automatic Correction

    1. def zh_ratio(text: str) -> float:
    2. zh = sum(1 for ch in text if '\u4e00' <= ch <= '\u9fff')
    3. letters = sum(1 for ch in text if ch.isascii() and ch.isalpha())
    4. return zh / max(zh + letters, 1)
    5. def guard(text: str, threshold: float = 0.5) -> str:
    6. if zh_ratio(text) < threshold:
    7. # Trigger a rewrite: append a language-correction instruction and regenerate
    8. return "REWRITE_WITH_ZH_CONSTRAINT"
    9. return text

    In a production pipeline, place language detection in post-processing. Once the score falls below the threshold, trigger regeneration with a correction instruction. This is more controllable than fixing things manually after the fact.

    5. Evaluation Layer: Make Language Consistency a Metric

    Add “language consistency rate” and “Chinese-English term mixing rate” to the regression evaluation set, covering mathematics, code, long-document summarization, and multi-turn dialogue. Only then can you tell whether a change is a real improvement or a random fluctuation.

    6. Deployment Suggestions on the Cloud

    If you deploy this capability in an enterprise application, you can build a complete engineering loop on general-purpose cloud infrastructure: use a container platform to host the inference service and a post-processing gateway, use object storage to keep evaluation sets and prompt template versions, use a message queue to smooth traffic spikes and chain together the “generate-detect-rewrite” pipeline, and use logging and monitoring with alerting to continuously track trends in language consistency and rewrite trigger rates. Baidu AI Cloud offers corresponding product categories for these general capabilities, which can be combined as needed without introducing extra purpose-built components for a single phenomenon.

    7. Common Misconceptions

    • Mistaking it for capability regression: Language switching is not equivalent to reasoning correctness, and the two need to be evaluated separately.
    • Only patching the prompt: Without changing decoding and context, the problem easily recurs over long chains.
    • Over-suppressing English terms: Forcing translations of proper nouns actually adds ambiguity. The right approach is “list both on first use, then unify.”

    Conclusion

    English suddenly appearing in Chinese reasoning is essentially the combined result of the model’s multilingual systems being simultaneously active, the path dependence of the reasoning chain, and decoding randomness. It is an explainable, measurable, and governable engineering problem. Write the constraints into the prompt, compress randomness into a suitable range, normalize the language of the context, turn detection and rewriting into a pipeline, and bring language consistency into evaluation. Then the output will converge stably to the target language while preserving the precision of necessary technical terms.