专家与大型语言模型中的主观代码偏好
Subjective Code Preferences in Experts and Large Language Models
AI总结:
通过收集约3000对Python代码片段并由73位专家评分,研究LLM在四个主观偏好轴(复杂度、注释、模块化、可读性)上的表现,发现模型在自然语言与代码评估中存在不一致,且表现出位置偏差和极化评分。
摘要:
大型语言模型(LLM)在编码任务中越来越受欢迎,而主观编码偏好是适应程序员个人需求的关键因素。现有研究忽略了这一特性,主要关注代码正确性。在本研究中,我们提出了四个主观编码偏好轴——复杂度、注释、模块化和可读性——这些轴基于常见的工程习惯,并由25名软件工程师验证。我们收集了一个包含约3000对Python代码片段的数据集,反映了这些轴,并由73位专家在李克特量表上评分。利用我们的数据集,我们研究了LLM如何处理主观编码偏好。我们向13个LLM展示同一编程任务的成对解决方案,首先是文本描述,然后是具体代码片段。我们发现,模型在自然语言中往往偏好一个选项,但在评估代码时却偏好相反。更一致的模型(即在言行选择上连贯的模型)经常表现出位置偏差:交换选项顺序会改变偏好的选项。然后,我们使用五个最一致的模型重新注释数据集。与人类相比,模型显示出极化的李克特分布和显著的评分差异。对GPT-5的案例研究揭示了对外部假设的依赖和脆弱的推理。
英文摘要:
Large Language Models (LLMs) have become increasingly popular for coding tasks, with subjective coding preferences being an essential element to adapt to programmers' personal needs. Existing work overlooks such characteristics and mainly focuses on code correctness. In this study, we propose a typification of four subjective coding preference axes - complexity, commenting, modularity, and readability - motivated by common engineering habits and validated by 25 software engineers. We collect a dataset of ~3,000 paired Python code snippets reflecting these axes, annotated by 73 experts who rate their preferences on a Likert scale. Using our dataset, we study how LLMs handle subjective coding preferences. We present 13 LLMs with pairs of solutions to the same programming task, first as textual descriptions and then as concrete code snippets. We find that models often prefer one option in natural language but the opposite when evaluating code. More consistent models (i.e., those that are coherent in their choices between deeds and words) frequently reveal positional bias: swapping the order of options changes the preferred alternative. We then use the five most consistent models to re-annotate the dataset. Compared to humans, models show polarized Likert distributions and notable divergence in ratings. A case study on GPT-5 reveals reliance on external assumptions and brittle reasoning.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。