Explaining Patterns in Data with Language Models via Interpretable Autoprompting

Chandan Singh, John Xavier Morris, Jyoti Aneja, Alexander M Rush, Jianfeng Gao

TL;DR

Instead of training a model or tuning opaque vector embeddings, interpretable autoprompting (iPrompt) uses a frozen large language model (LLM) to inspect dataset input–output pairs and generate human-readable instructions explaining the underlying task. By alternating between generating candidate explanations and reranking them based on predictive performance, iPrompt discovers fluent prompts that generalize across models, rival human-written instructions, and can even extract semantic concepts from neuroscience fMRI data.

What Problem Does This Paper Address?

Prompting is the standard way to steer LLMs, but writing good prompts by hand is tedious. While automated prompt search methods exist, they usually yield either continuous soft embeddings (which humans cannot read) or discrete token combinations via gradient search (e.g., AutoPrompt) that degenerate into ungrammatical, gibberish token sequences like addedthe +the use worked.

The authors invert the standard prediction setup: instead of asking an LLM to predict an output given a task prompt and an input, can a fixed LLM discover and articulate a natural-language description that explains the pattern connecting inputs to outputs?

Methods

The authors frame interpretable autoprompting as a discrete search problem over the space of fluent strings $S$, seeking a prompt $\hat{s}$ that maximizes data log-likelihood under a pre-trained LLM $f$:

$$\hat{s} = \arg\max_{s \in S} \sum_{i=1}^{n} f(\text{render}(s, x_i, y_i))$$

To enforce fluency without sacrificing predictive power, iPrompt implements an iterative local search with three phases:

  1. Proposal: Given data instances formatted with an explanatory prefix template (e.g., "To compute the output from the input, ___"), the LLM generates a batch of candidate prompt continuations via suffix decoding.
  2. Reranking: Each candidate prompt is evaluated across dataset examples according to data likelihood. The highest-scoring candidates are retained.
  3. Exploration: The top-ranked candidates are randomly truncated and used as prefix seeds for the LLM to decode new candidate completions.

Unlike gradient-guided discrete search methods, iPrompt operates purely via standard LLM inference (forward passes), eliminating the need for gradient computation through input embeddings.

       [ Input Data Examples ]
                  │
                  ▼
         ┌─────────────────┐
    ┌───►│ 1. Proposal     │ (Generate fluent candidate prompts via LLM)
    │    └────────┬────────┘
    │             ▼
    │    ┌─────────────────┐
    │    │ 2. Reranking    │ (Score candidates on data likelihood)
    │    └────────┬────────┘
    │             ▼
    │    ┌─────────────────┐
    └─── │ 3. Exploration  │ (Truncate best candidates & re-expand)
         └────────┬────────┘
                  │ (Converged)
                  ▼
      [ Fluent, Interpretable Prompt ]

Datasets

The authors benchmarked iPrompt across four distinct collections:

  • Inverse Synthetic Math (10 tasks): Arithmetic and functional operations (e.g., Add two, Multiply two, Fibonacci, Square).
  • Inverse Allen NLI (10 tasks): Crowdsourced NLP tasks from Natural Instructions V2 with verifiable descriptions (e.g., Country capital, Antonyms, Check edibility, SQL query generation).
  • Sentiment Classification (4 datasets): Real-world benchmarks including SST-2, Rotten Tomatoes, IMDB, and Financial Phrasebank.
  • Natural-Language fMRI (20 voxel sets): Brain response data from Huth et al. (2016), using the top-15 words that excite specific fMRI voxels to uncover semantic tuning categories in the human cortex.

Key Insights and Ideas

  • Prompt generation preserves syntax: By having the LLM itself draft and expand candidate phrases, prompts remain grammatically natural rather than collapsing into adversarial word salads.
  • Model scale determines prompt sensitivity: Probing GPT-2, GPT-Neo, GPT-J, and GPT-3 revealed that smaller models fail to differentiate between prompts, whereas large models (GPT-J 6B and GPT-3 175B) exhibit sharp accuracy gains only when supplied with semantically correct prompts.
  • Interpretability aids cross-model transfer: Because iPrompt produces actual natural language instructions, prompts discovered on a 6B model (GPT-J) transfer effectively to different model families and scales (such as OPT-6.7B, GPT-20B, and GPT-3 175B), outperforming the transferability of AutoPrompt's ungrammatical tokens.
  • Unsupervised scientific concept discovery: Applied to fMRI voxel data, iPrompt extracted recurring categories (material, color, surface, fabric) without supervision. Projecting these concepts onto the cortical surface produced spatially smooth semantic maps, matching neuroscientific expectations without having received spatial coordinates.

Key Results

  • Ground-Truth Pattern Recovery (GPT-J 6B):
  • Synthetic Math: iPrompt achieved 0.71 Mean Reciprocal Rank (MRR) and 80% top-prompt correctness, compared to AutoPrompt (0.30 MRR / 30% correctness) and average suffix decoding (0.07 MRR / 20% correctness).
  • Allen NLI: iPrompt achieved 0.30 MRR and 30% correctness (AutoPrompt achieved 0.17 MRR and 0% correctness).
  • Model Generalization (Tested on GPT-3 175B):
  • On math tasks, iPrompt reached 62.1% zero-shot accuracy versus 40.8% for AutoPrompt and 28.4% with no prompt (human-written prompts reached 76.0%).
  • Outperforming Human Prompts on Sentiment:
  • Tested on GPT-3, iPrompt surpassed human-crafted prompts on Financial Phrasebank (65.0% vs. 54.1%) and SST-2 (83.6% vs. 60.4%).

Limitations and Future Work

  • Computational Overhead: The search process requires iterative generation and forward scoring passes over multiple dataset examples, making it computationally intensive.
  • Struggles on Complex Tasks: On complex language tasks (such as Allen NLI), top-prompt correctness dropped to 30%, and performance degraded on long-document inputs (e.g., IMDB).
  • Search Horizons: Prompts were restricted to fixed token budgets (6 to 16 tokens), which can limit the richness of extracted instructions.
  • Future Directions: Incorporating targeted prompt templates (e.g., extracting feature importance), applying iPrompt to multimodal settings (such as generating vision task descriptions), and developing more efficient combinatorial search routines.

Summary updated

BibTeX
@inproceedings{singh2023explaining,
  author = {Chandan Singh and John Xavier Morris and Jyoti Aneja and Alexander M Rush and Jianfeng Gao},
  title = {{Explaining Patterns in Data with Language Models via Interpretable Autoprompting}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=GvMuB-YsiK6},
}
Figure