Predicting Human Visual Attention on Words in Source Code
This paper introduces a novel computational model that significantly outperforms existing baselines and advanced AI systems in predicting human visual attention on source code by utilizing a specialized loss function to align neural network internal attention with empirical eye-tracking data across Java and C programming languages.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you are trying to understand how a human brain works while they are reading a book. You can't just ask them, "What are you thinking about right now?" because they might not know, or they might lie. So, scientists use a special camera to watch their eyes. This is called eye-tracking. It's like having a tiny spotlight that follows where a person looks, showing us exactly which words they stare at, which ones they skip, and how long they pause. In the world of computer science, this is a big deal because software engineers spend their lives staring at source code—the text-based instructions that tell computers what to do. But code isn't just a story; it's a puzzle. Engineers don't read it like a novel; they jump back and forth, re-reading lines, and hunting for clues. Understanding where they look helps us build better tools, design clearer screens, and even teach computers to think more like humans.
Now, here is the tricky part: computers are usually really bad at guessing what humans are looking at. They might think a long, complicated word is the most important, while a human engineer knows the short, boring word next to it is actually the key to the whole program. This paper is about teaching a computer to stop guessing and start "seeing" like a human programmer. The researchers built a special kind of computer brain (a model) that learned from watching real humans read code. They didn't just tell the computer, "Here is the code, guess the next word." Instead, they gave it a secret cheat sheet: a map of where human eyes actually landed. They taught the computer to compare its own internal "gaze" with the human's real gaze, adjusting its thinking until the two matched up.
The main discovery is that this new computer model is surprisingly good at mimicking human attention. When the researchers tested it against three different groups of programmers (some reading Java code, some reading C code), the computer's predictions were much closer to what humans actually did than any previous computer model. In fact, on some tests, the computer was 64% and even 467% better at guessing where a human would look than the old standard methods. It didn't just get the numbers right; it learned the pattern of human thought.
But the researchers didn't stop there. They wanted to see if this "human-like" attention could help the computer do a harder job: predicting the exact sequence of eye movements, known as a scanpath. Imagine trying to predict the exact path a hiker will take through a forest, step by step. The computer, trained with human eye data, was able to predict these paths better than other famous AI models (like GPT-5 and Claude) and better than the previous best computer program on the reading task. While it also showed improvements on the writing task, the researchers noted that these specific gains were not statistically significant compared to the previous best computer program, though they still outperformed the commercial models. This suggests that when we teach computers to pay attention the way humans do, they don't just become better at reading; they start to understand the process of thinking itself.
However, the authors are careful not to say they have solved the mystery of the human mind. They admit their model is an "estimator" of what a group of people usually does, not a perfect copy of any single person's brain. It also has limits; it works best on smaller chunks of code and might get confused if the code is too huge to fit in its memory at once. But the results are a strong hint that by watching how our eyes move, we can teach machines to see the world a little more like we do.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.