TL;DR
HYSYNTH is a hybrid program synthesis framework that combines the "intuition" of Large Language Models (LLMs) with the precision of symbolic search. By distilling LLM samples into a task-specific, context-free grammar, it guides a bottom-up search to find correct programs in complex domains where LLMs alone often fail.
What Problem Does This Paper Address?
Program synthesis—automatically generating code to solve a task based on input-output examples—is a classic challenge in AI. Currently, two main approaches exist, both with significant flaws:
- Neural Approaches (LLMs): Models like GPT-4 are surprisingly good at writing code, but they lack precision. In unfamiliar or highly specific Domain-Specific Languages (DSLs), they often produce "almost right" code that fails on edge cases or contains minor syntax errors.
- Symbolic Approaches (Combinatorial Search): These methods are perfectly precise but suffer from the "state space explosion." As the desired program grows in complexity, the number of possible combinations becomes astronomical, making search infeasible.
The authors identify a specific tension: efficient search algorithms (like bottom-up search) require "context-free" structures to reuse work, but powerful LLMs use unlimited context. HYSYNTH bridges this gap by using the LLM to create a simplified, context-free "surrogate model" that tells the search engine which parts of the language are most likely to be useful for a specific problem.
Methods
The HYSYNTH pipeline operates in three main steps:
- LLM Sampling: Given a task (like a grid puzzle or a string transformation), the system prompts an LLM to generate multiple candidate solutions.
- Learning a PCFG: HYSYNTH parses these LLM-generated programs to learn a Probabilistic Context-Free Grammar (PCFG). Crucially, it uses a "non-strict mode"—even if the LLM's code is syntactically broken, HYSYNTH performs lexical analysis to see which operators (e.g.,
update_color,is_neighbor) the LLM used most frequently. - Guided Bottom-Up Search: The learned PCFG is used to assign "costs" to different code components. The search engine then explores the space of possible programs, prioritizing those built from the high-probability components suggested by the LLM.
This approach allows the search to be "guided" by the LLM's high-level reasoning while maintaining the formal correctness guarantees of symbolic search.
Datasets
The authors evaluated HYSYNTH on 299 tasks across three diverse domains:
- ARC (Abstraction and Reasoning Corpus): A benchmark for human-like reasoning consisting of grid-based puzzles.
- TENSOR: Tensor manipulation tasks (TensorFlow) sourced from StackOverflow and real-world Google scenarios.
- STRING: String manipulation tasks from the SYGUS benchmark, typical of spreadsheet automation.
Key Insights and Ideas
- LLMs as Intuition Engines: The core "aha moment" is that LLMs are excellent at identifying the vocabulary needed for a solution, even if they can't quite get the grammar right. By counting how often an LLM uses specific functions, HYSYNTH extracts a "task-specific prior" that drastically narrows the search space.
- The Context-Free Bridge: Bottom-up search is efficient because it factorizes the search space (reusing subprograms). LLMs are not context-free. By approximating the LLM with a PCFG, the authors make these two incompatible technologies work together.
- Robustness to Hallucination: Because the LLM is only providing guidance, its "hallucinations" (inventing functions or making logic errors) don't break the system. The symbolic search will simply ignore components that don't lead to a valid solution.
Key Results
HYSYNTH significantly outperformed both standalone LLMs and traditional synthesizers:
- Overall Success: HYSYNTH solved 58% of all tasks, compared to just 6% for LLMs alone and 40% for unguided symbolic search.
- Speedup: In the ARC domain, LLM guidance provided a 4x speedup, solving a motivating example in one minute that took unguided search 4.5 minutes.
- TENSOR Domain Mastery: In the TENSOR domain, HYSYNTH solved 96% of tasks. Notably, it eliminated the need for users to manually provide constants (like specific numbers or booleans), which was a major limitation of previous state-of-the-art tools like TFCODER.
Limitations and Future Work
- Synthesizer Implementation: While the search logic is general, HYSYNTH still requires a hand-written synthesizer/interpreter for each new DSL.
- LLM Cost: Sampling 100 completions from a model like GPT-4o for every task is computationally expensive and adds latency.
- Quality of Guidance: If the LLM is completely misled by a prompt and suggests entirely irrelevant operators, the guided search can actually be slower than a simple unguided search.
- Future Directions: The authors suggest moving toward more expressive, context-dependent surrogate models that could provide even more precise guidance without sacrificing search efficiency.
Summary updated