用轻量门控机制消除大模型生成中的语言混杂问题
Language Confusion Gate: Language-Aware Decoding Through Model Self-Distillation
- 通过自蒸馏训练门控模块,仅在必要时屏蔽错误语言的词元
- 在多个模型上将语言混淆降低一个数量级,不影响任务表现
- 适合需要多语言输出控制的场景,如跨语言对话系统
大型语言模型在文本生成中常出现语言混淆,即无意中混合多种语言。现有方法要么需要重新训练模型,要么无法区分有害混淆与可接受的语码转换。本文提出语言混淆门(LCG),一种轻量级、可插拔的解码阶段过滤方案,不修改基础模型。LCG基于归一化调整的自蒸馏训练,仅在必要时预测并屏蔽语言家族。研究发现:语言混淆发生频率低,正确语言的词元通常位于前几项预测中,且高资源语言的输出词元嵌入范数更大,导致采样偏差。在Qwen3、GPT-OSS、Gemma3、Llama3.1等模型上评估显示,LCG显著降低语言混淆,降幅常达一个数量级,且未损害任务性能。代码已公开于https://github.com/collinzrj/language_confusion_gate。
原文摘要 · Abstract (English)
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.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。