Tree Prompting: Efficient Task Adaptation without Fine-Tuning

Chandan Singh, John X. Morris, Alexander M. Rush, Jianfeng Gao, Yuntian Deng

Abstract

Adapting language models (LMs) to specific tasks typically requires either in-context learning (ICL) or gradient-based fine-tuning. However, ICL is constrained by rigid context windows and often fails with smaller models, while fine-tuning is computationally expensive and requires access to model weights. This paper introduces Tree Prompting, a novel framework that treats an LM as a feature generator within a decision tree structure. By routing inputs through a sequence of prompts, Tree Prompting enables small models to leverage large supervised datasets effectively. The method achieves performance competitive with fine-tuning while maintaining inference efficiency and providing an interpretable decision-making path.

Introduction

Prompting has revolutionized how we interact with Large Language Models (LLMs), yet it faces two significant hurdles. First, the context length bottleneck limits the number of examples a model can process, often capping the benefits of available supervised data. Second, model scale sensitivity means that while massive models like GPT-4 excel at few-shot learning, smaller models (e.g., GPT-2) often struggle to grasp complex tasks without direct weight updates.

Fine-tuning offers a solution but comes with high computational costs and is often impossible for proprietary models accessed via APIs. Tree Prompting addresses this middle ground, offering a way to utilize supervised training data to guide a model's behavior without altering its underlying parameters.

Methodology

Tree Prompting conceptualizes the language model as a router within a classic decision tree framework. Instead of a single, monolithic prompt, the system constructs a tree where each node represents a specific prompt-LM interaction.

1. The Tree Structure and Routing

In this framework, an input instance begins at the root node. At each node, the LM processes the input using a specific prompt. The model's output—mapped through a "verbalizer" (a function that converts text or logits into discrete binary choices)—determines whether the instance moves to the left or right child node. This process repeats until the instance reaches a leaf node, which assigns the final classification label.

2. Learning the Tree

To determine the optimal split at each node, the authors employ a bagging-inspired approach. They generate a pool of candidate prompts by sampling random subsets of few-shot examples from the training data. The system then uses the Classification and Regression Tree (CART) algorithm, specifically Gini impurity, to select the prompt that most effectively partitions the data at that specific node.

3. Extensions: Ensembles and Instructions

The research further explores Tree Ensembles, such as Random Forests or Gradient Boosting, to improve robustness. Additionally, the authors investigate Instruction Prompts, where nodes utilize human-curated or GPT-generated questions (e.g., "Is the tone of this text angry?") to make the decision logic more transparent and interpretable.

Experimental Evaluation

The researchers evaluated Tree Prompting across 13 diverse text classification datasets, including sentiment analysis (SST2, IMDB), topic classification (AGNews, DBPedia), and natural language inference (CB, RTE). The experiments primarily utilized the GPT-2 family of models to test the framework's efficacy on smaller architectures.

Key Results

  • Performance Gains for Small Models: The most significant improvement was observed in smaller models. For instance, GPT-2 Small’s accuracy rose from approximately 44% with standard prompting to over 60% using Tree Prompting.
  • Competitiveness with Fine-Tuning: On GPT-2 Large, Tree Prompting was competitive with full gradient-based fine-tuning, outperforming it on 5 out of 10 evaluated tasks.
  • Inference Efficiency: Unlike standard ensemble prompting, which requires running every prompt for every input, Tree Prompting only executes a number of prompts equal to the depth of the tree. This makes it significantly faster than other ensembling methods while maintaining high accuracy.
  • Data Scaling: Tree Prompting scales effectively with the size of the training set. While standard few-shot prompting performance plateaus quickly due to context limits, Tree Prompting continues to improve as more data is provided to refine the tree structure.

Discussion and Interpretability

A unique advantage of Tree Prompting is its inherent interpretability. Because each node is a human-readable prompt, the "logic" of the model becomes a visible path. In a sentiment task, one might observe the model first asking about the general subject matter before branching into specific questions about cinematography or acting, providing a clear audit trail for the final classification.

Limitations and Future Work

Despite its successes, Tree Prompting requires more training data than simple few-shot learning to build a robust tree, making it less ideal for extremely low-data regimes. Additionally, the initial construction of the tree is computationally intensive, as many candidate prompts must be evaluated across the training set. Currently, the method is optimized for classification; extending this logic to generative tasks like summarization or translation remains a primary goal for future research. The authors also suggest exploring non-binary trees and dynamic prompt evolution during the tree-building process.

Summary updated

BibTeX
@inproceedings{singh2023tree,
  author = {Chandan Singh and John X. Morris and Alexander M. Rush and Jianfeng Gao and Yuntian Deng},
  title = {{Tree Prompting: Efficient Task Adaptation without Fine-Tuning}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.emnlp-main.384},
}
Figure