人类与大语言模型如何处理易混淆代码?
How do Humans and LLMs Process Confusing Code?
AI总结:
为探究人类与大型语言模型(LLMs)对代码的理解是否存在差异,本研究通过实证对比两者对清晰与易混淆代码的理解,发现两者易被同类代码混淆,并提出数据驱动的LLM方法识别引发人类困惑的代码区域。
摘要:
如今,人类与基于大型语言模型(LLMs)的编程助手已在日常编程任务中协作。显然,LLMs与程序员理解代码方式的不一致会导致误解、效率低下、代码质量低及漏洞。该领域的关键问题是人类与LLMs是否会被同类代码混淆,这不仅指导LLMs在软件工程工作流中的集成选择,还为LLMs的改进提供参考。为此,我们开展实证研究,比较LLM与人类程序员对清晰及易混淆代码的理解:对LLM用困惑度衡量理解,对人类用神经生理反应(尤其是基于脑电图的注视相关电位)。结果发现,LLM困惑度峰值的位置与幅度均与人类表示困惑的神经生理反应相关,表明两者易被同类代码混淆;基于此,我们提出了一种数据驱动的LLM方法,用于识别引发人类困惑的代码区域。
英文摘要:
Already today, humans and programming assistants based on large language models (LLMs) collaborate in everyday programming tasks. Clearly, a misalignment between how LLMs and programmers comprehend code can lead to misunderstandings, inefficiencies, low code quality, and bugs. A key question in this space is whether humans and LLMs are confused by the same kind of code. This would not only guide our choices of integrating LLMs in software engineering workflows, but also inform about possible improvements of LLMs. To this end, we conducted an empirical study comparing an LLM to human programmers comprehending clean and confusing code. We operationalized comprehension for the LLM by using LLM perplexity, and for human programmers using neurophysiological responses (in particular, EEG-based fixation-related potentials). We found that LLM perplexity spikes correlate both in terms of location and amplitude with human neurophysiological responses that indicate confusion. This result suggests that LLMs and humans are similarly confused about the code. Based on these findings, we devised a data-driven, LLM-based approach to identify regions of confusion in code that elicit confusion in human programmers.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。