arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2510.13849cs.CLcs.LG

在潜在空间中进行语言引导以缓解无意的代码切换

Language steering in latent space to mitigate unintended code-switching

Skolkovo Institute of Science and Technology(斯克罗夫诺伊科学与技术研究所);Voronezh State University(沃罗涅日州立大学)

Andrey Goncharov, Nikolai Kondusov, Alexey Zaytsev

AI总结:

本文提出了一种轻量级的推理时间方法,通过主成分分析在平行翻译中识别语言方向,引导令牌嵌入沿这些轴控制语言身份,有效缓解代码切换并保持语义,计算开销小且仅需少量平行数据。

摘要:

多语言大语言模型(LLMs)常常表现出幻觉,如无意的代码切换,降低了在下游任务中的可靠性。我们提出潜在空间语言引导,一种轻量级的推理时间方法,通过主成分分析(PCA)在平行翻译中识别语言方向,并引导令牌嵌入沿这些轴以控制语言身份。我们的方法在保持语义的同时缓解代码切换,计算开销极小且仅需少量平行数据进行校准。实验表明,使用单个主成分可实现95-99%的语言分类准确率,并在Qwen2.5和Llama-3.2模型上多种语言对中将下一个令牌分布分歧减少高达55%。基于生成的评估进一步显示,在四个语言对上,Llama-3.2模型的代码切换指数减少63-99%(p < 0.001)。我们还分析了语言表示的层间演变,发现语言身份集中在最终层,具有近完美的线性可分离性。

英文摘要:

Multilingual Large Language Models (LLMs) often exhibit hallucinations such as unintended code-switching, reducing reliability in downstream tasks. We propose latent-space language steering, a lightweight inference-time method that identifies language directions via Principal Component Analysis (PCA) on parallel translations and steers token embeddings along these axes to control language identity. Our approach mitigates code-switching while preserving semantics with negligible computational overhead and requires only minimal parallel data for calibration. Empirically, we achieve 95-99\% language classification accuracy using a single principal component and reduce next-token distributional divergence by up to 55\% across multiple language pairs on Qwen2.5 and Llama-3.2 models. Generation-based evaluation on Llama-3.2 further demonstrates 63--99\% reduction in Code-Switching Index across four language pairs ($p < 0.001$). We further analyze the layer-wise evolution of language representations, revealing that language identity concentrates in final layers with near-perfect linear separability.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑