TLDR: EyeMulator is a new technique that improves Code Language Models (CodeLLMs) by training them to mimic how human software developers visually pay attention to code. It uses previously collected eye-tracking data to assign special weights to code tokens during the fine-tuning process of LLMs. This approach, which requires no architectural changes to the LLM and no eye-tracking during actual use, significantly boosts performance on tasks like code translation, completion, and summarization by helping the models focus on the most relevant parts of the code, similar to human intuition.
Code Language Models, often called CodeLLMs, have become essential tools in software development, assisting with tasks from generating code to finding bugs. These models learn by focusing on certain parts of the input, a process known as ‘machine attention.’ However, this machine attention is purely based on statistical patterns from training data. Human developers, on the other hand, possess an intuitive understanding of which parts of the code are most important, and this intuition is often reflected in their visual attention – where their eyes linger on the screen.
A new research paper introduces EyeMulator, an innovative technique designed to bridge this gap by training CodeLLMs to mimic human visual attention. The core idea is to infuse the model’s learning process with insights from how humans actually read and understand code.
How EyeMulator Works
EyeMulator doesn’t require any changes to the fundamental architecture of the CodeLLM, making it a flexible and ‘plug-and-play’ solution. Instead, it intervenes during the fine-tuning phase of the model’s training. Here’s a simplified breakdown of its process:
- Leveraging Human Gaze Data: The technique starts by using a publicly available dataset of eye-tracking experiments from software engineering tasks. This data captures where and for how long human programmers look at different parts of code.
- Extracting Attention Patterns: From this raw eye-tracking data, EyeMulator extracts two key types of information: semantic salience priors and n-gram gaze-transition tables. Semantic salience priors indicate how important different types of code tokens (like variable declarations or function calls) are to human attention. N-gram gaze-transition tables capture the sequential flow of human attention, showing common patterns of how developers move their eyes between different code elements.
- Weighting Code Tokens: These extracted human attention patterns are then used to assign special weights to each token in the input examples during LLM fine-tuning. Tokens that humans tend to focus on more, or that are part of significant gaze patterns, receive higher weights.
- Gaze-Informed Fine-Tuning: The LLM is then fine-tuned using a custom loss function that rewards the model for emphasizing the same tokens that a human would. This process effectively teaches the model to ‘see’ code with a human-like focus. Crucially, once trained, the EyeMulator-enhanced model no longer needs eye-tracking data during its inference (when it’s actually generating or analyzing code).
Significant Performance Boosts
The researchers evaluated EyeMulator on three common software engineering tasks: code translation, code completion, and code summarization. They tested it with several strong LLM baselines, including StarCoder, Llama-3.2, and DeepSeek-Coder.
The results were impressive, showing substantial performance improvements across all tasks and models. For instance, EyeMulator significantly boosted BERTScore for summarization, and CodeBLEU and H-Exact metrics for translation and completion. Ablation studies, where individual components of EyeMulator were removed, confirmed that each part—semantic priors, rarity weighting, and higher-order n-gram transitions—contributes meaningfully to these gains.
Interestingly, the study also found that attention patterns derived from human ‘writing’ sessions were more beneficial for code completion, while patterns from ‘reading’ sessions were more effective for translation and summarization. The full EyeMulator model, which integrates both reading and writing priors, achieved the best overall performance.
Also Read:
- Enhancing Language Models with New Vocabulary for Specialized Tasks
- Navigating the Landscape of Automated Code Review: A Comprehensive Analysis
A Sharper Focus for LLMs
Analysis of the models’ internal attention distributions revealed that EyeMulator helps CodeLLMs develop a more focused and semantically grounded understanding of code. For translation and completion, it helps the model ignore irrelevant context and sharpen its focus on direct token alignments. For summarization, it encourages deeper attention to core logic constructs, leading to more precise and contextually rich descriptions.
This research presents a compelling step towards creating more human-aware AI tools for software development. By teaching CodeLLMs to mimic the intuitive visual attention of human programmers, EyeMulator enhances their ability to understand and generate code more effectively. You can read the full research paper, EyeMulator: Improving Code Language Models by Mimicking Human Visual Attention, for more technical details.


