ChatPaper.aiChatPaper

ReGAL: Programma's Refactoren om Generaliseerbare Abstracties te Ontdekken

ReGAL: Refactoring Programs to Discover Generalizable Abstractions

January 29, 2024
Auteurs: Elias Stengel-Eskin, Archiki Prasad, Mohit Bansal
cs.AI

Samenvatting

Hoewel grote taalmodellen (LLMs) steeds vaker worden gebruikt voor programma-synthese, ontbreekt het hen aan het globale overzicht dat nodig is om nuttige abstracties te ontwikkelen; ze voorspellen doorgaans programma's één voor één, waarbij vaak dezelfde functionaliteit wordt herhaald. Het genereren van redundante code vanaf nul is zowel inefficiënt als foutgevoelig. Om dit aan te pakken, stellen we Refactoring for Generalizable Abstraction Learning (ReGAL) voor, een gradient-vrije methode voor het leren van een bibliotheek met herbruikbare functies via code-refactoring, d.w.z. het herstructureren van code zonder de uitvoer ervan te veranderen. ReGAL leert van een kleine set bestaande programma's, waarbij het iteratief de abstracties verifieert en verfijnt via uitvoering. We ontdekken dat de gedeelde functiebibliotheken die door ReGAL worden ontdekt, programma's gemakkelijker maken om te voorspellen in diverse domeinen. Op drie datasets (LOGO-graphicsgeneratie, Datumredenering en TextCraft, een op Minecraft gebaseerd tekstspel), verbeteren zowel open-source als propriëtaire LLMs in nauwkeurigheid bij het voorspellen van programma's met ReGAL-functies. Voor CodeLlama-13B resulteert ReGAL in absolute nauwkeurigheidsstijgingen van 11,5% op graphics, 26,1% op datuminterpretatie en 8,1% op TextCraft, waarbij het GPT-3.5 overtreft in twee van de drie domeinen. Onze analyse toont aan dat de abstracties van ReGAL veelgebruikte subroutines evenals omgevingsdynamiek omvatten.
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.
PDF102December 15, 2024