[Paper Review] CRAFT: Customizing LLMs by Creating and Retrieving from Specialized Toolsets
CRAFT builds task-specific toolsets of executable code snippets, and retrieves them via multi-view matching to augment LLMs without fine-tuning, improving performance on vision-language, tabular, and mathematical reasoning tasks.
Large language models (LLMs) are often augmented with tools to solve complex tasks. By generating code snippets and executing them through task-specific Application Programming Interfaces (APIs), they can offload certain functions to dedicated external modules, such as image encoding and performing calculations. However, most existing approaches to augment LLMs with tools are constrained by general-purpose APIs and lack the flexibility for tailoring them to specific tasks. In this work, we present CRAFT, a general tool creation and retrieval framework for LLMs. It creates toolsets specifically curated for the tasks and equips LLMs with a component that retrieves tools from these sets to enhance their capability to solve complex tasks. For each task, we collect specific code solutions by prompting GPT-4 to solve the training examples. Following a validation step ensuring the correctness, these solutions are abstracted into code snippets to enhance reusability, and deduplicated for higher quality. At inference time, the language model retrieves snippets from the toolsets and then executes them or generates the output conditioning on the retrieved snippets. Our method is designed to be flexible and offers a plug-and-play approach to adapt off-the-shelf LLMs to unseen domains and modalities, without any finetuning. Experiments on vision-language, tabular processing, and mathematical reasoning tasks show that our approach achieves substantial improvements compared to strong baselines. In addition, our in-depth analysis reveals that: (1) consistent performance improvement can be achieved by scaling up the number of tools and the capability of the backbone models; (2) each component of our approach contributes to the performance gains; (3) the created tools are well-structured and reliable with low complexity and atomicity. The code is available at https://github.com/lifan-yuan/CRAFT.
Motivation & Objective
- Motivate the need to tailor LLMs to specialized domains using curated tools rather than general-purpose APIs.
- Propose a full pipeline for offline tool creation, validation, and deduplication to generate high-quality, reusable tools.
- Develop a multi-view retrieval mechanism that selects tools based on problem text, API names, and docstrings to guide inference.
- Demonstrate parameter-free adaptation (no finetuning) and evaluate on diverse tasks to show scalability and robustness.
Proposed method
- Construct a toolset offline by sampling problems, generating executable Python solutions with GPT-4, and keeping only correct ones.
- Abstract solutions into general, reusable tools by renaming variables and wrapping inputs to promote cross-domain applicability.
- Validate tools by testing abstracted functions on original problems and discarding failures.
- Deduplicate tools by grouping by function name and input count and selecting the most general tool within each group.
- Retrieve tools at inference via multi-view matching over (problem, function name, docstring) using SimCSE-based similarity, and use majority voting to assemble the final set of tools for a given task.
- Instantiate retrieved tools as executable code snippets added to the LLM prompt, enabling tool invocation during solution generation.
- Evaluate end-to-end with GPT-3.5-Turbo (and GPT-4 in secondary analysis) across VQA, tabular processing, and algebraic reasoning, comparing to various baselines.
Experimental results
Research questions
- RQ1Can a large, curated set of executable tools improve LLM performance on tasks that require external tools without model finetuning?
- RQ2Does a multi-view retrieval strategy (problem text, API name, docstring) outperform simpler retrieval methods in selecting relevant tools?
- RQ3How do tool creation, abstraction, validation, and deduplication individually contribute to overall performance?
- RQ4How does toolset size and backbone model capability influence gains from CRAFT?
- RQ5What are the characteristics (complexity, diversity) of the produced toolsets and how do they affect reliability?
Key findings
- CRAFT achieves significant improvements over strong baselines, with notable gains on vision-language tasks.
- Performance improves as the number of tools and backbone capability increase.
- Each component (abstraction, problem/name/docstring matching) contributes to gains; removal of any view degrades performance.
- Created tools tend to have low cyclomatic complexity and high diversity, indicating reliability and broad applicability.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.