Function-constrained Program Synthesis

要約

本研究では、(1)大規模言語モデル(LLM)がプログラミングタスクを解く際にユーザー提供のコードを活用できるようにする手法と、(2)LLMが生成した初期コードが不十分な場合に、将来のコード生成を支援するモジュール型サブ関数を反復的に生成する手法を紹介する。Pythonのような汎用プログラミング言語でコンピュータプログラムを生成することは、プロンプトで提供されたコードを使用するよう指示された場合、LLMにとって課題となる。コード固有のLLM(GitHub Copilot、CodeLlama2など)は、開発環境で利用可能なすべてのコードを利用することで、コード補完をリアルタイムで生成することができる。しかし、コード固有のLLMがコンテキスト内のコードのみを使用するように制限することは簡単ではありません。なぜなら、モデルはユーザーが提供したコードを使用するように明示的に指示されないため、ユーザーはモデルがコンテキストに組み込むべきコードの断片を正確に強調表示することができないからです。さらに、現在のシステムは効果的なリカバリ方法を欠いており、ユーザーは十分な解決策に達するまで、修正されたプロンプトでモデルを反復的に再プロンプトすることを余儀なくされる。我々の方法は、コード生成を明示的な関数セットに制限し、自動生成されたサブ関数によって失敗した試行からのリカバリを可能にすることで、従来のLLMによるコード生成とは異なる。LLMが動作するコードを生成できない場合、モジュール化されたサブ関数を生成し、その後の関数コード生成の試みを支援する。我々の手法の副産物として、関連するタスクを解決できる再利用可能なサブ関数のライブラリーがあり、効率性が経験とともにスケールするソフトウェアチームを模倣している。また、従来のゼロショット評価と比較して、LLMのコーディング能力をより厳密に推定する、新しい「ハーフショット」評価パラダイムを導入する。我々の提案する評価手法は、モデルが構造化された形式で解を出力することを促し、コーディング能力が低いと誤解される可能性のある構文エラーを減少させる。

要約(オリジナル)

This work introduces (1) a technique that allows large language models (LLMs) to leverage user-provided code when solving programming tasks and (2) a method to iteratively generate modular sub-functions that can aid future code generation attempts when the initial code generated by the LLM is inadequate. Generating computer programs in general-purpose programming languages like Python poses a challenge for LLMs when instructed to use code provided in the prompt. Code-specific LLMs (e.g., GitHub Copilot, CodeLlama2) can generate code completions in real-time by drawing on all code available in a development environment. However, restricting code-specific LLMs to use only in-context code is not straightforward, as the model is not explicitly instructed to use the user-provided code and users cannot highlight precisely which snippets of code the model should incorporate into its context. Moreover, current systems lack effective recovery methods, forcing users to iteratively re-prompt the model with modified prompts until a sufficient solution is reached. Our method differs from traditional LLM-powered code-generation by constraining code-generation to an explicit function set and enabling recovery from failed attempts through automatically generated sub-functions. When the LLM cannot produce working code, we generate modular sub-functions to aid subsequent attempts at generating functional code. A by-product of our method is a library of reusable sub-functions that can solve related tasks, imitating a software team where efficiency scales with experience. We also introduce a new ‘half-shot’ evaluation paradigm that provides tighter estimates of LLMs’ coding abilities compared to traditional zero-shot evaluation. Our proposed evaluation method encourages models to output solutions in a structured format, decreasing syntax errors that can be mistaken for poor coding ability.

arxiv情報

著者 Patrick Hajali,Ignas Budvytis
発行日 2023-12-04 06:24:02+00:00
arxivサイト arxiv_id(pdf)

提供元, 利用サービス

arxiv.jp, DeepL

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