Whodunit:将代码分类为人类编写或GPT-4生成——基于CodeChef问题的案例研究
Whodunit: Classifying Code as Human Authored or GPT-4 Generated -- A case study on CodeChef problems
AI总结:
本研究针对AI生成代码引发的学术不端担忧,基于CodeChef数据集用代码风格计量学和机器学习分类器区分GPT-4与人类编写的代码,取得了优异的分类效果。
摘要:
基于GPT-4等大语言模型构建的GitHub Copilot、ChatGPT等人工智能(AI)助手正在革新编程任务的执行方式,也引发了关于代码是否由生成式AI模型编写的疑问。这类问题对教育工作者而言尤为重要,他们担心这些工具会催生一种新的学术不端形式,即学生将AI生成的代码当作自己的作业提交。本研究探讨了利用代码风格计量学与机器学习区分GPT-4生成代码和人类编写代码的可行性。研究数据集包含来自CodeChef的人类编写解决方案,以及由GPT-4生成的AI编写解决方案。我们的分类器性能优于基线模型,F1分数和AUC-ROC分数均达到0.91。排除可被利用特征(如空行、空白符)的分类器变体仍表现良好,F1分数和AUC-ROC分数为0.89。我们还针对编程问题的难度评估了分类器性能,发现简单和中等难度问题的分类效果几乎无差异,仅在较难问题上性能略有下降。本研究表明,代码风格计量学是区分GPT-4生成代码与人类编写代码的一种有前景的方法。
英文摘要:
Artificial intelligence (AI) assistants such as GitHub Copilot and ChatGPT, built on large language models like GPT-4, are revolutionizing how programming tasks are performed, raising questions about whether code is authored by generative AI models. Such questions are of particular interest to educators, who worry that these tools enable a new form of academic dishonesty, in which students submit AI generated code as their own work. Our research explores the viability of using code stylometry and machine learning to distinguish between GPT-4 generated and human-authored code. Our dataset comprises human-authored solutions from CodeChef and AI-authored solutions generated by GPT-4. Our classifier outperforms baselines, with an F1-score and AUC-ROC score of 0.91. A variant of our classifier that excludes gameable features (e.g., empty lines, whitespace) still performs well with an F1-score and AUC-ROC score of 0.89. We also evaluated our classifier with respect to the difficulty of the programming problem and found that there was almost no difference between easier and intermediate problems, and the classifier performed only slightly worse on harder problems. Our study shows that code stylometry is a promising approach for distinguishing between GPT-4 generated code and human-authored code.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。