[论文解读] EyeLayer: Integrating Human Attention Patterns into LLM-Based Code Summarization
EyeLayer 将基于人眼凝视的注意力先验引入到代码摘要的解码器和编码器模型中,在不同架构上均获得一致的提升,BLEU-4 最高提升至 13.17%。
Code summarization is the task of generating natural language descriptions of source code, which is critical for software comprehension and maintenance. While large language models (LLMs) have achieved remarkable progress on this task, an open question remains: can human expertise in code understanding further guide and enhance these models? We propose EyeLayer, a lightweight attention-augmentation module that incorporates human eye-gaze patterns, as a proxy of human expertise, into LLM-based code summarization. EyeLayer models human attention during code reading via a Multimodal Gaussian Mixture, redistributing token embeddings based on learned parameters (μ_i, σ_i^2) that capture where and how intensively developers focus. This design enables learning generalizable attention priors from eye-tracking data and incorporating them into LLMs seamlessly, without disturbing existing representations. We evaluate EyeLayer across diverse model families (i.e., LLaMA-3.2, Qwen3, and CodeBERT) covering different scales and architectures. EyeLayer consistently outperforms strong fine-tuning baselines across standard metrics, achieving gains of up to 13.17% on BLEU-4. These results demonstrate that human gaze patterns encode complementary attention signals that enhance the semantic focus of LLMs and transfer effectively across diverse models for code summarization.
研究动机与目标
- 评估人类注意力信号是否能超越标准微调而提升基于 LLM 的代码摘要性能。
- 提出一个轻量、可迁移的注意力增强模块,使用眼动数据作为先验。
- 展示该方法在不同模型家族与规模上的泛化能力。
- 发布实现和数据集以支持可复现性。
提出的方法
- 引入多模态高斯 EyeLayer,通过学习的高斯混合重新分配代码标记嵌入。
- 从紧凑的代码嵌入中预测高斯参数 (mu_k, sigma_k^2),并使用稀疏门控机制选择活动模态。
- 在解码器端 Transformer 的隐藏状态中通过因果感知的残差扰动注入人类对齐的注意力,同时保持因果性。
- 通过三阶段的 AST-to-subtoken 对齐管线,将眼动追踪数据桥接到子词表示。
- 在代码摘要数据和辅助眼动对齐数据上联合训练,使用 L_gen + L_align,并结合 PCGrad 来管理冲突梯度。
- 在 CodeXGLUE Java 基准上对五种模型(CodeBERT、LLaMA-3.2 1B/3B、Qwen-3 1.7B/4B)进行评估,指标包括 BLEU-4、ROUGE-L、METEOR、BERTScore。

实验结果
研究问题
- RQ1RQ1:EyeLayer 是否在标准有监督微调基础上提升代码摘要质量?
- RQ2RQ2:EyeLayer 在 Transformer 堆叠中的位置如何影响性能?
- RQ3RQ3:EyeLayer 对编码器-only 架构的泛化能力如何?
- RQ4RQ4:多模态设计对性能的贡献是什么?
主要发现
| Model | BLEU-4 | ROUGE-L | METEOR | BERTScore |
|---|---|---|---|---|
| Llama3.2-1B | 14.31 | 22.12 | 27.45 | 87.55 |
| Llama3.2-1B + EyeLayer | 16.18 | 23.51 | 29.33 | 88.51 |
| Llama3.2-3B | 15.64 | 24.57 | 29.83 | 88.29 |
| Llama3.2-3B + EyeLayer | 16.86 | 25.25 | 31.04 | 88.72 |
| Qwen3-1.7B | 13.36 | 21.39 | 26.60 | 86.04 |
| Qwen3-1.7B + EyeLayer | 15.12 | 26.67 | 32.03 | 86.38 |
| Qwen3-4B | 15.24 | 23.73 | 29.45 | 85.87 |
| Qwen3-4B + EyeLayer | 17.22 | 25.30 | 31.31 | 86.27 |
- EyeLayer 在所有评估模型和指标上均呈现一致改进。
- BLEU-4 的提升在某些模型(如 Qwen-3 4B)可达 1.98 点。
- Qwen-3-1.7B 在 ROUGE-L 和 METEOR 上有显著提升(分别为 5.28 和 5.43)。
- 带 EyeLayer 的解码器模型在词汇与语义指标(BLEU、ROUGE、METEOR、BERTScore)上均有提升。
- 该方法展示了跨架构的迁移能力和对大规模 LLM 以及较小编码器的可扩展性。
- EyeLayer 在所评估的设置中实现了最高达 13.17% 的绝对 BLEU-4 增益(如摘要中所述)。

更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。