TL;DR
LILO (Library Induction from Language Observations) is a neurosymbolic framework that builds human-readable, domain-specific code libraries by combining LLM-guided program synthesis with symbolic compression. By automatically documenting discovered code abstractions using an "AutoDoc" module, LILO creates a virtuous cycle where the system becomes increasingly better at solving complex tasks while maintaining an interpretable codebase.
What Problem Does This Paper Address?
While Large Language Models (LLMs) are excellent at generating snippets of code, they struggle with the "art of refactoring"—the process of identifying recurring patterns and consolidating them into reusable, readable libraries.
Existing "library learning" algorithms, most notably DreamCoder, attempt to solve this by searching for common sub-expressions and turning them into anonymous lambda abstractions. However, DreamCoder is computationally expensive (requiring months of CPU time) and produces libraries that are essentially "black boxes" of unreadable code. Conversely, purely neural approaches often fail to capture the deep, symbolic structure required for complex, multi-step programming tasks in novel domains. LILO aims to bridge this gap by making learned libraries both powerful and interpretable.
Methods
LILO operates in an iterative "search-compress-document" loop, as illustrated in the overview below:
The framework consists of three primary modules:
- Dual-System Synthesis: LILO uses a "fast" LLM-guided search to generate initial solutions based on natural language descriptions. It then uses a "slow" enumerative search to find precise, domain-specific expressions that the LLM might miss.
- Compression (STITCH): LILO integrates STITCH, a high-performance symbolic compression system. STITCH identifies optimal $\lambda$-abstractions (reusable logic) across the entire corpus of solved tasks, making the codebase more concise.
- Auto-documentation (AutoDoc): This is the key innovation. Because STITCH outputs anonymous functions (like
fn_42), LLMs struggle to use them in future tasks. AutoDoc prompts an instruction-tuned LLM to analyze these anonymous functions and their usage examples to generate human-readable names and docstrings.
This documentation isn't just for humans; it allows the LLM to "understand" and deploy the new library functions in subsequent synthesis rounds.
Datasets
The authors evaluated LILO on three challenging inductive program synthesis benchmarks:
- REGEX: String editing tasks using regular expressions (e.g., "if the word starts with a vowel, replace it with 'b'").
- CLEVR: Scene reasoning and visual question answering (e.g., "how many red objects are to the right of the green cylinder?").
- LOGO: 2D turtle graphics composition, requiring the system to draw complex shapes like snowflakes and staircases.
Key Insights and Ideas
- Documentation as De-obfuscation: The authors found that providing an LLM with anonymous abstractions actually degraded performance. The LLM viewed them as "code obfuscation." AutoDoc acts as a de-obfuscator, unlocking the LLM's ability to leverage the learned library.
- Neurosymbolic Synergy: Symbolic tools (STITCH) are far more efficient at finding structural patterns than LLMs, but LLMs are far better at assigning semantic meaning to those patterns. LILO delegates the "math" of compression to the symbolic engine and the "meaning" to the neural engine.
- Deep Refactoring: Because LILO uses STITCH, it can perform "deep refactoring"—re-deriving the entire library at every iteration. This allows the system to discard suboptimal abstractions discovered early in the learning process.
Key Results
LILO significantly outperformed both the state-of-the-art DreamCoder and purely neural baselines across all domains.
- Performance: In the REGEX domain, LILO solved 93.2% of tasks, compared to only 45.6% for DreamCoder. In the LOGO domain, LILO solved 73.9%, nearly doubling DreamCoder's 36.9%.
- Efficiency: LLM-guided search proved to be orders of magnitude more sample-efficient than symbolic search. The authors estimate that one round of LILO synthesis is roughly equivalent to 48 CPU-hours of DreamCoder search in terms of cost, while yielding much better results.
- Interpretability: As shown in the library inspection below, LILO learns high-level concepts and assigns them readable names and documentation. For example, in the string editing domain, it identifies and names abstractions like
vowel_regexandreplace_substr, building them hierarchically from simpler primitives.
Limitations and Future Work
- Semantic Errors: AutoDoc occasionally produces incorrect or ambiguous documentation (e.g., misidentifying which angle is being incremented in a graphics function).
- Sequential Bias: Because AutoDoc works sequentially, it can sometimes "double down" on an initial naming error, leading to a cascade of confusing documentation in the library.
- Future Directions: The authors suggest incorporating self-consistency and verification techniques to improve AutoDoc. They also aim to extend LILO from domain-specific languages to modern imperative languages like Python.
Summary updated