TroVE: Inducing Verifiable and Efficient Toolboxes for Solving Programmatic Tasks

Zhiruo Wang, Graham Neubig, Daniel Fried

Abstract

Large Language Models (LLMs) often solve complex reasoning tasks by generating verbose, "primitive" code that is difficult for humans to audit and prone to logic errors. We introduce TroVE (Inducing Verifiable and Efficient Toolboxes), a training-free framework that allows LLMs to curate their own libraries of reusable, high-level functions. By employing agreement-based selection and periodic toolbox trimming, TroVE produces solutions that are more accurate, concise, and 31% faster for humans to verify than standard code-generation approaches.

Introduction

When tasked with data analysis or mathematical reasoning, LLMs typically default to writing code using basic language primitives (e.g., standard Python or pandas operations). This often results in "spaghetti code"—long, repetitive scripts where small errors can easily go unnoticed. While human developers manage complexity through modularity, existing AI "tool-making" approaches often require expensive fine-tuning or result in bloated, redundant libraries.

Comparison of TroVE with primitive and existing tool-making methods.

TroVE addresses these challenges by enabling LLMs to build a "toolbox" on-the-fly. Unlike previous methods, TroVE is training-free and focuses on maintaining a lean, high-utility library that facilitates both model performance and human oversight.

The TroVE Framework

TroVE operates in a streaming fashion, interacting with a shared function library as it encounters new problems. For each task, the model can choose between three operational modes:

  1. IMPORT: Reuse an existing high-level function from the toolbox.
  2. CREATE: Define a new modular function and add it to the toolbox.
  3. SKIP: Revert to standard primitive-based coding.

To manage the library effectively, TroVE utilizes two core mechanisms:

  • Agreement-Based Selection: The model generates multiple candidate solutions across different modes. TroVE executes these and selects the answer with the highest consensus (self-consistency). In cases of ties, it prioritizes the solution with the fewest operations, naturally incentivizing abstraction.
  • Toolbox Trimming: To prevent "library bloat," TroVE periodically prunes underutilized functions. The retention threshold scales logarithmically with the number of tasks processed, ensuring the toolbox remains manageable and relevant.

Experimental Evaluation

The authors evaluated TroVE across 11 datasets in three domains: Mathematics (MATH), Table Question Answering (TabMWP, WTQ, HiTab), and Visual Reasoning (GQA). The framework was tested using both open-source models like CodeLlama-7B and proprietary models like GPT-4.

Results and Insights

TroVE consistently outperformed baselines while maintaining toolboxes that were 79-98% smaller than those generated by instance-wise methods. A key finding is that conciseness serves as a proxy for correctness; by pushing for abstraction, TroVE reduces the "surface area" for potential bugs.

Comparison between error-prone primitive code and concise, modular TroVE solutions.

Furthermore, modular code significantly improves human-in-the-loop efficiency. In user studies, humans were 31% faster and 13% more accurate at verifying TroVE-generated solutions compared to primitive code. As shown in the figure above, replacing verbose data slicing with a named function like calc_rate_of_change makes logic errors much easier to spot.

Limitations and Future Work

While effective, TroVE faces a "cold start" problem where early tasks in a stream do not benefit from a mature library. Additionally, the system currently relies on a predefined set of basic primitives. Future research could explore inducing these primitives from scratch and implementing more robust self-verification to prevent flawed functions from "poisoning" the toolbox.

Conclusion

TroVE demonstrates that LLMs can autonomously develop efficient, human-readable toolboxes without additional training. By prioritizing modularity and simplicity, the framework bridges the gap between raw code generation and professional software engineering practices.

Summary updated

BibTeX
@inproceedings{wang2024trove,
  author = {Zhiruo Wang and Graham Neubig and Daniel Fried},
  title = {{TroVE: Inducing Verifiable and Efficient Toolboxes for Solving Programmatic Tasks}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=DCNCwaMJjI},
}
Figure