ReGAL: Refactoring Programs to Discover Generalizable Abstractions

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Stengel-Eskin, Elias, Prasad, Archiki, Bansal, Mohit
Format: Preprint
Publié: 2024
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866913379522707456
author Stengel-Eskin, Elias
Prasad, Archiki
Bansal, Mohit
author_facet Stengel-Eskin, Elias
Prasad, Archiki
Bansal, Mohit
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2401_16467
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle ReGAL: Refactoring Programs to Discover Generalizable Abstractions
Stengel-Eskin, Elias
Prasad, Archiki
Bansal, Mohit
Software Engineering
Artificial Intelligence
Computation and Language
Machine Learning
Programming Languages
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.
title ReGAL: Refactoring Programs to Discover Generalizable Abstractions
topic Software Engineering
Artificial Intelligence
Computation and Language
Machine Learning
Programming Languages
url https://arxiv.org/abs/2401.16467