CodeChain: Towards Modular Code Generation Through Chain of Self-revisions with Representative Sub-modules

要約

大規模言語モデル (LLM) は、HumanEval や MBPP ベンチマークのような単純なプログラミング タスクを解決するのにすでにかなり熟練しています。
ただし、これらのモデルにとって、より複雑で競争力のあるプログラミング タスクを解決することは依然として非常に困難です。これはおそらく、ソリューションを論理的なサブタスクやサブモジュールに分解するのではなく、モノリシックなコード ブロックとしてソリューションを生成する傾向があるためと考えられます。
一方、経験豊富なプログラマーは、複雑なタスクを解決するために抽象化されたモジュール化されたコードを本能的に作成し、以前に開発されたモジュールを再利用することがよくあります。
このギャップに対処するために、私たちは CodeChain を提案します。CodeChain は、自己改訂のチェーンを通じてモジュール化されたコード生成を引き出す推論用の新しいフレームワークであり、それぞれが以前の反復で生成されたいくつかの代表的なサブモジュールによって導かれます。
具体的には、CodeChain はまず、思考連鎖プロンプトを通じてモジュール化されたコードを生成するように LLM に指示します。
次に、次の 2 つのステップを繰り返すことによって自己改訂のチェーンを適用します。1) 生成されたサブモジュールを抽出してクラスタリングし、より汎用的で再利用可能な実装としてクラスタの代表を選択します。2) 元のチェーンを拡張します。
これらの選択されたモジュール実装を使用してプロンプトを表示し、新しいモジュール化されたソリューションを再生成するように LLM に指示します。
以前に開発および検証されたサブモジュールを再利用するように LLM を自然に促すことで、CodeChain は生成されたソリューションのモジュール性と正確性の両方を大幅に向上させ、APPS で 35%、CodeContests で 76% の相対 pass@1 改善を達成できることがわかりました。

これは、OpenAI LLM と WizardCoder のようなオープンソース LLM の両方で有効であることが示されています。
また、プロンプトのさまざまな方法、クラスターの数、モデルのサイズ、プログラムの品質などを使用した包括的なアブレーション研究も実施し、CodeChain の成功を支える有用な洞察を提供します。

要約(オリジナル)

Large Language Models (LLMs) have already become quite proficient at solving simpler programming tasks like those in HumanEval or MBPP benchmarks. However, solving more complex and competitive programming tasks is still quite challenging for these models – possibly due to their tendency to generate solutions as monolithic code blocks instead of decomposing them into logical sub-tasks and sub-modules. On the other hand, experienced programmers instinctively write modularized code with abstraction for solving complex tasks, often reusing previously developed modules. To address this gap, we propose CodeChain, a novel framework for inference that elicits modularized code generation through a chain of self-revisions, each being guided by some representative sub-modules generated in previous iterations. Concretely, CodeChain first instructs the LLM to generate modularized codes through chain-of-thought prompting. Then it applies a chain of self-revisions by iterating the two steps: 1) extracting and clustering the generated sub-modules and selecting the cluster representatives as the more generic and re-usable implementations, and 2) augmenting the original chain-of-thought prompt with these selected module-implementations and instructing the LLM to re-generate new modularized solutions. We find that by naturally encouraging the LLM to reuse the previously developed and verified sub-modules, CodeChain can significantly boost both modularity as well as correctness of the generated solutions, achieving relative pass@1 improvements of 35% on APPS and 76% on CodeContests. It is shown to be effective on both OpenAI LLMs as well as open-sourced LLMs like WizardCoder. We also conduct comprehensive ablation studies with different methods of prompting, number of clusters, model sizes, program qualities, etc., to provide useful insights that underpin CodeChain’s success.

arxiv情報

著者 Hung Le,Hailin Chen,Amrita Saha,Akash Gokul,Doyen Sahoo,Shafiq Joty
発行日 2023-10-13 10:17:48+00:00
arxivサイト arxiv_id(pdf)

提供元, 利用サービス

arxiv.jp, Google

カテゴリー: cs.AI, cs.CL, cs.PL パーマリンク