Skip to main content
QUICK REVIEW

[论文解读] A Comparative Study of Code Generation using ChatGPT 3.5 across 10 Programming Languages

Alessio Buscemi|arXiv (Cornell University)|Aug 8, 2023
Artificial Intelligence in Healthcare and Education被引用 16
一句话总结

本文研究 ChatGPT 3.5 在使用 40 个编码任务覆盖 10 种语言时生成可执行代码的能力,分析时间、代码长度及局限性。

ABSTRACT

Large Language Models (LLMs) are advanced Artificial Intelligence (AI) systems that have undergone extensive training using large datasets in order to understand and produce language that closely resembles that of humans. These models have reached a level of proficiency where they are capable of successfully completing university exams across several disciplines and generating functional code to handle novel problems. This research investigates the coding proficiency of ChatGPT 3.5, a LLM released by OpenAI in November 2022, which has gained significant recognition for its impressive text generating and code creation capabilities. The skill of the model in creating code snippets is evaluated across 10 various programming languages and 4 different software domains. Based on the findings derived from this research, major unexpected behaviors and limitations of the model have been identified. This study aims to identify potential areas for development and examine the ramifications of automated code generation on the evolution of programming languages and on the tech industry.

研究动机与目标

  • 评估 ChatGPT 3.5 在 10 种编程语言中的代码生成能力。
  • 评估 40 项编码任务的执行成功率和时间性能。
  • 分析生成代码的长度、变异性及自动代码生成的实际局限性。
  • 识别语言相关的优点、缺点以及伦理/技术方面的关注点。

提出的方法

  • 通过 OpenAI API(Turbo,角色设定为“软件开发者”,温度为 1)查询 ChatGPT 3.5。
  • 使用覆盖 DS、Games、Security 和 Algos 分类的固定 40 任务语料库。
  • 对每个任务在 10 种语言中进行每语言每任务 10 次测试(总计 4,000 次测试)。
  • 对输出进行后处理,提取代码、测试和语言特定的格式;将结果分类为六种状态。
  • 测量每个任务每种语言相对于该语言的任务均值(P_l)而言的时间。
  • 记录 LoC 和 NoC 以评估代码长度和变异性。
Figure 1: Status of the output generated by ChatGPT for the 4,000 tests, grouped by programming language and category.
Figure 1: Status of the output generated by ChatGPT for the 4,000 tests, grouped by programming language and category.

实验结果

研究问题

  • RQ1ChatGPT 3.5 在不同编程语言中生成正确且可执行代码的表现如何?
  • RQ2影响代码生成质量和成功率的语言相关因素有哪些(抽象层级、训练流行度)?
  • RQ3各语言生成代码的时间特征和代码长度特征如何?
  • RQ4在任务和语言跨越的自动代码生成中存在哪些限制与伦理考量?

主要发现

  • 在 4000 次运行中有 1833 次(45.8%)生成了可执行代码,结果因语言而异。
  • Julia 的执行成功率最高(81.5%),而 C++ 的最低(7.3%)。
  • 高级、动态类型语言通常表现优于底层、静态类型语言;训练语料的流行度也影响表现。
  • 时间性能因语言而异;例如 C++ 中 palindromeInteger 最快(4.83 s),而 C 中 randomForest 最慢(140.7 s)。
  • 代码长度(LoC/NoC)与执行时间没有明显相关性,并在各语言之间呈现较高变异性。
  • ChatGPT 3.5 显示出显著的局限性,包括对任务理解不一致、偶尔不遵循指令,以及在某些任务中的伦理担忧。
Figure 2: $P_{\ell}$ of each language.
Figure 2: $P_{\ell}$ of each language.

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。