Code Language Models (CodeLLMs) traditionally learn attention based solely on statistical input-output token correlations ("machine attention"). In contrast, human developers rely on intuition, selectively fixating on semantically salient tokens during program comprehension. We present EyeMulator, a model-agnostic technique to align CodeLLM attention with human visual attention without architectural changes. By extracting scan paths from eye-tracking data, we derive token-level attention weights used to augment the loss function during fine-tuning. This induces the model to mimic human focus. Our evaluation across StarCoder, Llama-3.2, and DeepSeek-Coder shows that EyeMulator significantly outperforms baselines, achieving gains of over 30 CodeBLEU points in translation and up to 22 BERTScore points in summarization. Ablation studies confirm that these gains stem directly from replicating human attention dynamics. Artifacts are available at https://zenodo.org/records/17205682.
翻译:代码语言模型(CodeLLM)传统上仅基于输入-输出统计词符相关性(“机器注意力”)来学习注意力机制。相比之下,人类开发者在程序理解过程中依赖直觉,选择性聚焦于语义显著的词符。我们提出EyeMulator——一种无需架构修改即可将代码语言模型注意力与人类视觉注意力对齐的模型无关技术。通过从眼动追踪数据中提取扫描路径,我们推导出词符级注意力权重,用于增强微调期间的损失函数。这种方法引导模型模仿人类注意力焦点。我们在StarCoder、Llama-3.2和DeepSeek-Coder上的评估表明,EyeMulator显著优于基线方法,在代码翻译任务中CodeBLEU分数提升超过30点,在摘要任务中BERTScore提升高达22点。消融研究证实,这些收益直接源于对人类注意力动态的复现。相关工件可通过https://zenodo.org/records/17205682获取。