ReGAL: 汎用可能な抽象化を発見するためのプログラムリファクタリング
ReGAL: Refactoring Programs to Discover Generalizable Abstractions
January 29, 2024
著者: Elias Stengel-Eskin, Archiki Prasad, Mohit Bansal
cs.AI
要旨
大規模言語モデル(LLM)はプログラム合成にますます使用されるようになっているが、有用な抽象化を開発するために必要なグローバルな視点を欠いている。一般的に、LLMは一度に一つのプログラムを予測し、同じ機能を繰り返すことが多い。ゼロから冗長なコードを生成することは非効率的でエラーが発生しやすい。この問題に対処するため、我々はコードリファクタリング(実行結果を変えずにコードを再構築すること)を介して再利用可能な関数のライブラリを学習する勾配不要の手法であるRefactoring for Generalizable Abstraction Learning(ReGAL)を提案する。ReGALは既存のプログラムの小さなセットから学習し、実行を通じてその抽象化を反復的に検証・洗練する。ReGALによって発見された共有関数ライブラリは、多様なドメインにわたってプログラムを予測しやすくすることがわかった。LOGOグラフィックス生成、日付推論、およびMinecraftベースのテキストゲームであるTextCraftの3つのデータセットにおいて、オープンソースおよびプロプライエタリのLLMは、ReGAL関数を使用したプログラムを予測する際に精度が向上した。CodeLlama-13Bでは、ReGALによりグラフィックスで11.5%、日付理解で26.1%、TextCraftで8.1%の絶対精度向上が見られ、3つのドメインのうち2つでGPT-3.5を上回った。我々の分析によると、ReGALの抽象化は頻繁に使用されるサブルーチンと環境のダイナミクスをカプセル化している。
English
While large language models (LLMs) are increasingly being used for program
synthesis, they lack the global view needed to develop useful abstractions;
they generally predict programs one at a time, often repeating the same
functionality. Generating redundant code from scratch is both inefficient and
error-prone. To address this, we propose Refactoring for Generalizable
Abstraction Learning (ReGAL), a gradient-free method for learning a library of
reusable functions via code refactorization, i.e. restructuring code without
changing its execution output. ReGAL learns from a small set of existing
programs, iteratively verifying and refining its abstractions via execution. We
find that the shared function libraries discovered by ReGAL make programs
easier to predict across diverse domains. On three datasets (LOGO graphics
generation, Date reasoning, and TextCraft, a Minecraft-based text game), both
open-source and proprietary LLMs improve in accuracy when predicting programs
with ReGAL functions. For CodeLlama-13B, ReGAL results in absolute accuracy
increases of 11.5% on graphics, 26.1% on date understanding, and 8.1% on
TextCraft, outperforming GPT-3.5 in two of three domains. Our analysis reveals
ReGAL's abstractions encapsulate frequently-used subroutines as well as
environment dynamics.