While large language models (LLMs) now excel at code generation, a key aspect of software development is the art of refactoring: consolidating code into libraries of reusable and readable programs. In this paper, we introduce LILO, a neurosymbolic framework that iteratively synthesizes, compresses, and documents code to build libraries tailored to particular problem domains. LILO combines LLM-guided program synthesis with recent algorithmic advances in automated refactoring from Stitch: a symbolic compression system that efficiently identifies optimal lambda abstractions across large code corpora. To make these abstractions interpretable, we introduce an auto-documentation (AutoDoc) procedure that infers natural language names and docstrings based on contextual examples of usage. In addition to improving human readability, we find that AutoDoc boosts performance by helping LILO's synthesizer to interpret and deploy learned abstractions. We evaluate LILO on three inductive program synthesis benchmarks for string editing, scene reasoning, and graphics composition. Compared to existing neural and symbolic methods - including the state-of-the-art library learning algorithm DreamCoder - LILO solves more complex tasks and learns richer libraries that are grounded in linguistic knowledge.
翻译:尽管大语言模型(LLMs)在代码生成方面已表现出色,但软件开发的关键环节在于重构艺术:将代码整合为可复用、可读的程序库。本文提出LILO——一种神经符号框架,通过迭代综合、压缩与文档化代码,构建针对特定问题领域的定制化库。LILO将LLM引导的程序综合与Stitch的自动重构算法相结合:Stitch是一种符号压缩系统,能在大规模代码语料库中高效识别最优的lambda抽象。为使这些抽象具备可解释性,我们引入自动文档化(AutoDoc)过程,基于上下文使用示例推断自然语言名称与文档字符串。除提升人类可读性外,我们发现AutoDoc通过帮助LILO综合器解释并部署所学抽象,进一步提升了性能。我们在字符串编辑、场景推理与图形合成三个归纳程序综合基准上评估LILO。相较于现有神经与符号方法(包括最先进的库学习算法DreamCoder),LILO能解决更复杂的任务,并学习到更丰富、植根于语言知识的库。