arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2401.16467cs.SEcs.AIcs.CLcs.LGcs.PL
收藏

ReGAL:通过重构程序发现可泛化的抽象

ReGAL: Refactoring Programs to Discover Generalizable Abstractions

UNC Chapel Hill(北卡罗来纳大学教堂山分校)

Elias Stengel-Eskin, Archiki Prasad, Mohit Bansal

AI总结:

本文提出无梯度方法 ReGAL,通过代码重构从少量程序中学习可复用函数库,使 LLM 在多个程序合成数据集上的预测准确率显著提升。

摘要:

虽然大语言模型(LLMs)越来越多地被用于程序合成,但它们缺乏开发有用抽象所需的全局视角;它们通常一次预测一个程序,常常重复相同的功能。从零开始生成冗余代码既低效又容易出错。为了解决这个问题,我们提出了面向可泛化抽象学习的重构方法(ReGAL),这是一种无梯度的方法,通过代码重构(即在不改变代码执行输出的情况下重组代码)来学习可复用函数库。ReGAL 从一小组现有程序中学习,通过执行迭代验证并改进其抽象。我们发现 ReGAL 发现的共享函数库使程序在多个不同领域中更容易被预测。在五个数据集上——LOGO 图形生成、日期推理、TextCraft(一个基于 Minecraft 的文本游戏)、MATH 和 TabMWP——无论是开源还是专有的大语言模型,在使用 ReGAL 函数预测程序时准确率都有所提升。对于 CodeLlama-13B,ReGAL 使 LOGO 上的绝对准确率提高了 11.5%,日期理解提高了 26.1%,TextCraft 提高了 8.1%,在三个领域中的两个领域超过了 GPT-3.5。我们的分析表明,ReGAL 的抽象封装了频繁使用的子程序以及环境动态。

英文摘要:

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 five datasets -- LOGO graphics generation, Date reasoning, TextCraft (a Minecraft-based text-game) MATH, and TabMWP -- 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 LOGO, 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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑