[Paper Review] EyeLayer: Integrating Human Attention Patterns into LLM-Based Code Summarization
EyeLayer adds human eye-gaze–based attention priors to decoder- and encoder-based models for code summarization, yielding consistent gains across architectures and up to 13.17% BLEU-4 improvement.
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.
Motivation & Objective
- Motivate whether human attention signals can enhance LLM-based code summarization beyond standard fine-tuning.
- Propose a lightweight, transferable attention-augmentation module that uses eye-tracking data as priors.
- Demonstrate generalization of the approach across diverse model families and scales.
- Release implementation and datasets to support reproducibility.
Proposed method
- Introduce Multimodal Gaussian EyeLayer that redistributes code token embeddings via a learned Gaussian mixture.
- Predict Gaussian parameters (mu_k, sigma_k^2) from a compact code embedding and use a sparse gating mechanism to select active modes.
- Inject human-aligned attention through causal-aware, residual perturbations to hidden states in decoder-only transformers while preserving causality.
- Bridge eye-tracking data to subtoken representations via a three-stage AST-to-subtoken alignment pipeline.
- Jointly train on code summarization data and auxiliary eye-tracking alignment data using L_gen + L_align with PCGrad to manage conflicting gradients.
- Evaluate across five models (CodeBERT, LLaMA-3.2 1B/3B, Qwen-3 1.7B/4B) on CodeXGLUE Java benchmarks with BLEU-4, ROUGE-L, METEOR, and BERTScore.

Experimental results
Research questions
- RQ1RQ1: Does EyeLayer improve code summarization quality over standard supervised fine-tuning?
- RQ2RQ2: How does EyeLayer's position within the transformer stack affect performance?
- RQ3RQ3: How well does EyeLayer generalize to encoder-only architectures?
- RQ4RQ4: What is the contribution of the multimodal design to performance?
Key findings
- EyeLayer yields consistent improvements across all evaluated models and metrics.
- BLEU-4 improvements reach up to 1.98 points for some models (e.g., Qwen-3 4B).
- Qwen-3-1.7B shows substantial ROUGE-L and METEOR gains (5.28 and 5.43, respectively).
- Decoder-only models with EyeLayer show gains across lexical and semantic metrics (BLEU, ROUGE, METEOR, BERTScore).
- The approach demonstrates cross-architecture transferability and scalability to large LLMs and smaller encoders.
- EyeLayer achieves up to 13.17% absolute BLEU-4 gain on the evaluated setups (as stated in abstract).

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.