[論文レビュー] An Empirical Study of the Non-determinism of ChatGPT in Code Generation
この論文は、CodeContests、APPS、HumanEvalにおけるChatGPTのコード生成の高い非決定性を経験的に示し、零温度が決定性を保証しないことを示し、タスク特徴との相関を分析する。
There has been a recent explosion of research on Large Language Models (LLMs) for software engineering tasks, in particular code generation. However, results from LLMs can be highly unstable; nondeterministically returning very different codes for the same prompt. Non-determinism is a potential menace to scientific conclusion validity. When non-determinism is high, scientific conclusions simply cannot be relied upon unless researchers change their behaviour to control for it in their empirical analyses. This paper conducts an empirical study to demonstrate that non-determinism is, indeed, high, thereby underlining the need for this behavioural change. We choose to study ChatGPT because it is already highly prevalent in the code generation research literature. We report results from a study of 829 code generation problems from three code generation benchmarks (i.e., CodeContests, APPS, and HumanEval). Our results reveal high degrees of non-determinism: the ratio of coding tasks with zero equal test output across different requests is 75.76%, 51.00%, and 47.56% for CodeContests, APPS, and HumanEval, respectively. In addition, we find that setting the temperature to 0 does not guarantee determinism in code generation, although it indeed brings less non-determinism than the default configuration (temperature=1). These results confirm that there is, currently, a significant threat to scientific conclusion validity. In order to put LLM-based research on firmer scientific foundations, researchers need to take into account non-determinism in drawing their conclusions.
研究の動機と目的
- 複数のベンチマークにわたるChatGPTのコード生成における非決定性の程度を定量化する。
- コード生成における非決定性に対する温度の影響を評価する。
- 異なるプロンプト設定(マルチリクエスト対シングルリクエスト)間で非決定性を比較する。
- コード作成タスクの特徴(例:指示の長さ)と非決定性との相関を探る。
- 実証的ソフトウェア工学研究で非決定性を考慮するための研究者への指針を提供する。
提案手法
- 3つのベンチマーク(CodeContests、APPS、HumanEval)それぞれで、コードタスクごとに5つのコード候補を生成するためにChatGPT(gpt-3.5-turboおよびgpt-4)を使用する。
- APIレスポンスからコードを抽出するためにMarkdown形式のPython3コードをプロンプトする。
- 意味論をテストパス率、出力同等性率(OER)および例外を除くOERで評価する。
- コード候補間の表現的類似度をLCSとLevenshtein編集距離で測定する。
- ASTベースの方法(pycode_similar with Unified_Diff and Tree_Diff)を用いて構造的類似性を測定する。
- 温度(0、1、2)とGPT-3.5対GPT-4の比較の影響を調査する。

実験結果
リサーチクエスチョン
- RQ1RQ1: ChatGPTのコード生成は意味論・統計・構造の観点でどれほど非決定的か。
- RQ2RQ2: 温度はコード生成の非決定性の程度にどう影響するか。
- RQ3RQ3: 5つの候補を別々のリクエストから取る場合と1つのリクエストからトップ1候補を5つ得る場合で、非決定性はどう異なるか。
- RQ4RQ4: 指示の長さや難易度などのコード作成タスクの特徴と非決定性指標との相関はあるか。
- RQ5RQ5: GPT-4の非決定性はGPT-3.5と比べてどうか。
主な発見
- 高い非決定性の脅威が観察される:上位5候補のテスト出力が等しくない確率は72.73%、60.40%、および65.85%のタスクである(CodeContests、APPS、HumanEval)。
- 全データセットで候補間のテストパス率の最大差が1.00に達し、HumanEval問題の48.17%でこの最大差が現れる。
- 零温度は決定性を保証しない。とはいえ、温度0は温度1よりも決定性が高く、温度2はしばしばコード全体を一様に悪化させる。
- 長いコーディング指示は統語的・構造的類似性および平均正確性と負の相関を示す。
- 調査された文献全体で、LLMベースのコード生成研究の中で非決定性を実験で考慮しているものは21.1%–22.4%にすぎない。
- 構造的類似性は候補間で比較的高いままである(United_Diff: CodeContests 0.46, APPS 0.52, HumanEval 0.69; Tree_Diff: CodeContests 0.60, APPS 0.68, HumanEval 0.72)。

より良い研究を、今すぐ始めましょう
論文設計から論文執筆まで、研究時間を劇的に削減しましょう。
クレジットカード登録不要
このレビューはAIが作成し、人間の編集者が確認しました。