title: ReGAL: Refactoring Programs to Discover Generalizable Abstractions
summary: 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.
paper_authors._id: 65b9b2401d610bfed4889bc8
paper_authors.name: Elias Stengel-Eskin
paper_authors.status: claimed_verified
paper_authors.statusLastChangedAt: 2024-01-31T14:00:51.048Z
paper_authors._id: 61781c4caf41befe8ff060e8
paper_authors.avatarUrl: /avatars/8871d7b046fc28cbc8638228da8e9737.svg
paper_authors.fullname: Elias Stengel-Eskin
paper_authors.type: user
paper_authors.user: esteng
paper_authors._id: 65b9b2401d610bfed4889bc9
paper_authors.name: Archiki Prasad
paper_authors.status: claimed_verified
paper_authors.statusLastChangedAt: 2024-01-31T08:58:43.025Z
paper_authors._id: 607aeae5d2cd8c150e6ae074
paper_authors.avatarUrl: /avatars/a087743b98b6fe2181283a9610db4ec4.svg
paper_authors.fullname: Archiki Prasad
paper_authors.type: user
paper_authors.user: archiki
paper_authors._id: 65b9b2401d610bfed4889bca
paper_authors.name: Mohit Bansal
paper_title: ReGAL: Refactoring Programs to Discover Generalizable Abstractions
paper_summary: 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.
paper_ai_keywords: Refactoring Generalizable Abstraction Learning (ReGAL) gradient-free method reusable functions code refactorization shared function libraries accuracy increases