ANPL: Towards Natural Programming with Interactive Decomposition

Di Huang, Ziyuan Nan, Xing Hu, Pengwei Jin, Shaohui Peng, Yuanbo Wen, Rui Zhang, Zidong Du, Qi Guo, Yewen Pu, Yunji Chen

Introduction & TL;DR

ANPL (Abstracted Natural Programming Language) is an interactive system that allows users to generate complex code by combining a structural "sketch" (Python logic) with natural language "holes" (sub-modules). By enabling users to recursively decompose difficult problems into simpler, LLM-solvable parts, ANPL achieves a 75% success rate on the notoriously difficult Abstraction and Reasoning Corpus (ARC) benchmark, significantly outperforming vanilla LLM interactions.

The Challenge of LLM Code Generation

While Large Language Models (LLMs) like GPT-4 are impressive at generating code, they often fail at "one-shot" generation for complex, user-specific tasks. When an LLM makes a mistake in a long program, it is incredibly difficult for a user to fix it without the LLM "hallucinating" new errors elsewhere.

The core challenges in current AI-assisted programming are:

  1. Complexity: LLM-generated programs can have tangled dataflows that are hard to modify locally.
  2. Ambiguity: Natural language descriptions are often too vague to guide an LLM toward a specific, precise fix.
  3. Reasoning Gaps: LLMs struggle with tasks requiring novel abstract reasoning, such as those found in ARC.

The authors propose that the solution lies in structured decomposition: letting humans handle the high-level logic while offloading the tedious implementation of sub-functions to the LLM.

The ANPL Approach: Sketching and Holes

ANPL borrows the "sketching" paradigm from traditional program synthesis and adapts it for the LLM era.

The ANPL interactive workflow, showing how users decompose tasks into sketches and holes, and debug them iteratively.

An ANPL program consists of two main components:

  • The Sketch: Precise Python code that defines the control flow (loops, conditionals) and data flow (how variables move between functions).
  • The Holes: Function modules defined only by natural language descriptions (e.g., find the largest blue object).

The Interactive Workflow: If the compiler fails to produce a working program, the user has three ways to debug locally without breaking the rest of the program:

  1. Redecompose: Turn a failing "hole" into its own sub-sketch with even smaller holes.
  2. Explain & Modify: Tweak the natural language description of a hole.
  3. Provide I/O: Give the system specific input-output examples for a single hole, allowing the LLM to "resynthesize" that specific module in isolation.

The ANPL Compiler ensures that the user's high-level sketch remains intact while the LLM iterates on the implementation of the holes.

Core Innovations

  • Decoupling Logic from Implementation: The "aha moment" of ANPL is recognizing that humans are much better at high-level decomposition than writing boilerplate, while LLMs are the opposite. ANPL creates a formal interface where these two strengths meet.
  • Recursive Debugging: Because every "hole" is essentially a standalone ANPL program, the system allows for localized debugging. You can fix a bug in a sub-module without the LLM ever seeing—or breaking—the main program logic.
  • Stability through Structure: By forcing the dataflow to be explicit in the sketch, the system prevents the "cascading errors" common in long-form chat interactions with LLMs.
  • Thinking in Decomposition: The authors found that using ANPL actually improved user performance even when they switched back to vanilla LLMs, suggesting that the "sketch and hole" mindset is a superior way for humans to approach AI-assisted programming.

Performance and Results

The system was evaluated primarily on the ARC (Abstraction and Reasoning Corpus), a visual task benchmark requiring deductive reasoning from few examples, designed to be easy for humans but notoriously hard for AI. Additional evaluations were run on APPS and HumanEval to test general software engineering capabilities.

Solving rate over time, demonstrating ANPL's superior performance compared to baseline interactions.
  • ARC Performance: Programmers using ANPL solved 75.0% of tasks, compared to 58.4% using a vanilla LLM (GPT-3.5) interaction.
  • One-Shot Superiority: Even without human interaction, the ANPL framework outperformed vanilla GPT-3.5 (23.5% vs 16.8% solving rate).
  • HumanEval Gains: On the HumanEval benchmark, ANPL paired with GPT-4 achieved an accuracy of 86.59%, surpassing the original GPT-4's 67% and other state-of-the-art methods like Reflexion (80.1%).
  • Efficiency: ANPL solutions required significantly fewer lines of code from the user (average of ~10 lines) compared to the final Python output (~26 lines), effectively reducing the "coding burden."

Alongside the system, the authors released DARC (Decomposition of ARC), a new dataset containing 300 instances of human-decomposed ARC tasks, providing a roadmap of how humans programmatically break down abstract problems.

Future Directions

While highly effective, ANPL has room for growth. Users still have to read the Python code generated by the LLM to debug "holes," which can become a bottleneck if the LLM uses obscure libraries. Future work may focus on generating concise summaries of hole implementations.

Additionally, writing effective natural language descriptions for holes still requires skill. The authors propose creating a "natural language library" where users can share and reuse successful descriptions. Finally, expanding beyond pure Python to integrate "neural holes" (like object detectors) could further enhance the system's ability to tackle complex domains like robotics and chip design.

Summary updated

BibTeX
@inproceedings{huang2023anpl,
  author = {Di Huang and Ziyuan Nan and Xing Hu and Pengwei Jin and Shaohui Peng and Yuanbo Wen and Rui Zhang and Zidong Du and Qi Guo and Yewen Pu and Yunji Chen},
  title = {{ANPL: Towards Natural Programming with Interactive Decomposition}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=RTRS3ZTsSj},
}
Figure