Papers
Topics
Authors
Recent
Gemini 2.5 Flash
Gemini 2.5 Flash
41 tokens/sec
GPT-4o
59 tokens/sec
Gemini 2.5 Pro Pro
41 tokens/sec
o3 Pro
7 tokens/sec
GPT-4.1 Pro
50 tokens/sec
DeepSeek R1 via Azure Pro
28 tokens/sec
2000 character limit reached

Do Large Language Models Pay Similar Attention Like Human Programmers When Generating Code? (2306.01220v2)

Published 2 Jun 2023 in cs.SE, cs.HC, and cs.LG

Abstract: LLMs have recently been widely used for code generation. Due to the complexity and opacity of LLMs, little is known about how these models generate code. We made the first attempt to bridge this knowledge gap by investigating whether LLMs attend to the same parts of a task description as human programmers during code generation. An analysis of six LLMs, including GPT-4, on two popular code generation benchmarks revealed a consistent misalignment between LLMs' and programmers' attention. We manually analyzed 211 incorrect code snippets and found five attention patterns that can be used to explain many code generation errors. Finally, a user study showed that model attention computed by a perturbation-based method is often favored by human programmers. Our findings highlight the need for human-aligned LLMs for better interpretability and programmer trust.

User Edit Pencil Streamline Icon: https://streamlinehq.com
Authors (5)
  1. Bonan Kou (5 papers)
  2. Shengmai Chen (2 papers)
  3. Zhijie Wang (36 papers)
  4. Lei Ma (195 papers)
  5. Tianyi Zhang (262 papers)
Citations (7)
X Twitter Logo Streamline Icon: https://streamlinehq.com