Language Confusion Gate: Language-Aware Decoding Through Model Self-Distillation

Collin Zhang, Fei Huang, Chenhan Yuan, Junyang Lin
10/20/2025
cs.CL

Official code: collinzrj/language_confusion_gate (5 stars, last commit 2025-10-23).

Abstract

Large language models (LLMs) often experience language confusion, which is the unintended mixing of languages during text generation. Current solutions to this problem either necessitate model retraining or cannot differentiate between harmful confusion and acceptable code-switching. This paper introduces the Language Confusion Gate (LCG), a lightweight, plug-in solution that filters tokens during decoding without altering the base LLM. The LCG is trained using norm-adjusted self-distillation to predict appropriate language families and apply masking only when needed. Our method is based on the findings that language confusion is infrequent, correct-language tokens are usually among the top predictions, and output token embedding norms are larger for high-resource languages, which biases sampling. When evaluated across various models, including Qwen3, GPT-OSS, Gemma3, Llama3.1, LCG decreases language confusion significantly, often by an order of magnitude, without negatively impacting task performance. Code is available at https://github.com/collinzrj/language_confusion_gate.

View on arXivView PDF

Code Implementations(1)

50Shell, PythonOct 20, 202512 months ago

Similar Papers

Cite this paper

@article{zhang2025language,
  title  = {Language Confusion Gate: Language-Aware Decoding Through Model Self-Distillation},
  author = {Collin Zhang and Fei Huang and Chenhan Yuan and Junyang Lin},
  year   = {2025},
  eprint = {2510.17555},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2510.17555v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2510.17555.svg)](https://codeofpaper.com/paper/2510.17555)

Discussion