Skip to main content
QUICK REVIEW

[論文レビュー] LLM-Assisted Code Cleaning For Training Accurate Code Generators

Naman Jain, Tianjun Zhang|arXiv (Cornell University)|Nov 25, 2023
Software Engineering Research被引用数 4
ひとこと要約

本論文は、訓練データをより読みやすく、モジュラー化されたものに変換することで、コード生成性能を向上させる、新しいLLM支援型データクリーニングパイプラインを提案する。変数名の変更、複雑なコードのヘルパー関数への分解、自然言語による計画の挿入を通じて、元のデータセットと比較してCodeLLaMa-7Bの正確性を最大30%向上させた。これは、清浄化されたデータの15%しか使用しないモデルでさえ、より大きな閉鎖型モデル(例:AlphaCode)を上回ることを示している。

ABSTRACT

Natural language to code generation is an important application area of LLMs and has received wide attention from the community. The majority of relevant studies have exclusively concentrated on increasing the quantity and functional correctness of training sets while disregarding other stylistic elements of programs. More recently, data quality has garnered a lot of interest and multiple works have showcased its importance for improving performance. In this work, we investigate data quality for code and find that making the code more structured and readable leads to improved code generation performance of the system. We build a novel data-cleaning pipeline that uses these principles to transform existing programs by 1.) renaming variables, 2.) modularizing and decomposing complex code into smaller helper sub-functions, and 3.) inserting natural-language based plans via LLM based transformations. We evaluate our approach on two challenging algorithmic code generation benchmarks and find that fine-tuning CodeLLaMa-7B on our transformed modularized programs improves the performance by up to 30% compared to fine-tuning on the original dataset. Additionally, we demonstrate improved performance from using a smaller amount of higher-quality data, finding that a model fine-tuned on the entire original dataset is outperformed by a model trained on 15% of our cleaned dataset. Even in comparison to closed-source models, our models outperform the much larger AlphaCoder models.

研究の動機と目的

  • 機能的な正しさを越えて、データ品質の向上によってコード生成性能を向上させること。
  • 訓練データにおける読みやすさ、モジュラリティ、構造的明確さがモデル性能に与える影響を調査すること。
  • 既存のコードデータセットを高品質でより構造的なバージョンに変換する、自動的でLLM駆動のパイプラインを開発すること。
  • 高品質なデータがデータ効率性を向上させることを実証し、大規模なトレーニングセットの必要性を低減すること。
  • プログラミングのベストプラクティスを特定・適用するデータクリーニングのフレームワークを確立すること。

提案手法

  • 指示微調整済みLLMを用いて、3段階の反復的変換を実施:文脈に適した変数名の変更、複雑なコードを小さなヘルパー関数にモジュラー化、コメントとしてトップダウンの自然言語計画の挿入。
  • 各変換を自然言語のプロンプトと入出力の例を用いて実施し、元のプログラムと変換後のプログラムとの間で機能的同等性を保証する。
  • コードを完全から生成するのではなく、既存のプログラムをLLMで精練するほうが容易であることに着目し、新規生成ではなく改良を重視する。
  • ベンチマークデータセット(APPSおよびCode-Contests)のプログラムを、清浄化済み、モジュラー化済み、計画付きのバージョンに変換して、並列データセットを構築する。
  • 元のデータセットと変換済みデータセットの両方でCodeLLaMa-7Bを微調整し、性能向上を評価する。
  • 入出力の例を用いた検証により、変換後のプログラムが元のプログラムと同じ出力を生成することを保証する。
Figure 1: The overview of our code cleaning approach . We apply instruction-tuned LLMs to transform existing datasets by providing natural language prompts and use input-output examples to maintain function equivalence between original and transformed programs. Our cleaning approach works in three s
Figure 1: The overview of our code cleaning approach . We apply instruction-tuned LLMs to transform existing datasets by providing natural language prompts and use input-output examples to maintain function equivalence between original and transformed programs. Our cleaning approach works in three s

実験結果

リサーチクエスチョン

  • RQ1データクリーニングによるコードの読みやすさとモジュラリティの向上が、コード生成モデルの性能に与える影響は何か?
  • RQ2より小さな高品質データセットが、より大きな低品質データセットを上回る性能を示せるか?
  • RQ3変数名の変更、モジュラー化、計画コメントの挿入といったLLMベースの変換が、モデルの汎化性能および機能的正しさにどの程度向上効果をもたらすか?
  • RQ4コードに自然言語の計画コメントを含めることで、単なるコードと比較してモデル性能が向上するか?
  • RQ5プログラミングのベストプラクティスを重視するデータクリーニング技術が、コード生成タスクにおけるデータ効率性を向上させられるか?

主な発見

  • 清浄化・モジュラー化されたデータセットで微調整したCodeLLaMa-7Bの性能は、元のデータセットで微調整した場合と比較して最大30%向上した。
  • 清浄化データセットのわずか15%で微調整したモデルが、元のデータセットの全量で微調整したモデルを上回った。これは、顕著なデータ効率性の向上を示している。
  • 変数名の改善、モジュラー関数、トップダウンの計画コメントを含む清浄化データセットにより、モデル出力のコードがより構造的で読みやすくなった。
  • より大きな閉鎖型モデル(例:AlphaCode)でさえ、清浄化データで微調整したCodeLLaMa-7Bは、アルゴリズム的コード生成ベンチマークで優れた性能を示した。
  • LLMベースのクリーニングパイプラインは、機能的正しさを保持したまま、既存のプログラムを高品質なバージョンに成功して変換した。これは、入出力テストによる検証で確認された。
  • 本手法は、データサイズとは無関係に、構造性と読みやすさといったデータ品質が、コード生成性能に測定可能で顕著な影響を及ぼすことを示している。
Figure 3: Effect of quality on data-efficiency of the model . Finetuning on 15% of clean $\mathcal{D}_{modular}$ dataset results in similar performance as finetuning on the entire $\mathcal{D}_{original}$ dataset.
Figure 3: Effect of quality on data-efficiency of the model . Finetuning on 15% of clean $\mathcal{D}_{modular}$ dataset results in similar performance as finetuning on the entire $\mathcal{D}_{original}$ dataset.

より良い研究を、今すぐ始めましょう

論文の読解から最終レビューまで、研究時間を劇的に削減しましょう。

クレジットカード登録不要

このレビューはAIが作成し、人間の編集者が確認しました。