Interactive Prompt Debugging with Sequence Salience

Ian Tenney, Ryan Mullins, Bin Du, Shree Pandya, Minsuk Kahng, Lucas DixonarXiv 2024

Abstract

We present Sequence Salience, a visual tool for interactive prompt debugging with input salience methods. Sequence Salience builds on widely used salience methods for text classification and single-token prediction, and extends this to a system tailored for debugging complex LLM prompts. Our system is well-suited for long texts, and expands on previous work by 1) providing controllable aggregation of token-level salience to the word, sentence, or paragraph level, making salience over long inputs tractable; and 2) supporting rapid iteration where practitioners can act on salience results, refine prompts, and run salience on the new output. We include case studies showing how Sequence Salience can help practitioners work with several complex prompting strategies, including few-shot, chain-of-thought, and constitutional principles. Sequence Salience is built on the Learning Interpretability Tool, an open-source platform for ML model visualizations, and code, notebooks, and tutorials are available at http://goo.gle/sequence-salience.

Introduction

Large Language Models (LLMs) are often treated as "black boxes," leaving prompt engineers to rely on a "guess-and-check" cycle when models produce unexpected results. While Input Salience (IS) methods exist to highlight influential tokens, they are often impractical for modern LLM usage due to the scale of long prompts and the abstraction gap between sub-word tokens and high-level instructions.

Sequence Salience addresses these challenges by providing an interactive visual debugging environment. It allows developers to understand and refine complex prompts by highlighting which input segments most influence specific outputs, bridging the gap between raw model data and a developer's mental model.

Methodology

Built as a module for the open-source Learning Interpretability Tool (LIT), Sequence Salience focuses on usability and rapid iteration. Its technical core includes:

  • Gradient-based Salience: Utilizing methods like GradNormL2 and Grad · Input, the tool generates attributions efficiently with a single inference call.
  • Dynamic Aggregation: A standout feature that allows users to group token-level scores into words, sentences, lines, or paragraphs, significantly reducing cognitive load for long-context analysis.
  • Teacher Forcing Mode: Enables "what-if" debugging by computing salience for user-provided target sequences, even if they weren't generated by the model.
  • Interactive Loop: A Datapoint Editor is integrated directly alongside the salience map, facilitating a tight feedback loop: edit prompt, run model, see salience, and repeat.
The Sequence Salience interface facilitates a four-step workflow: editing prompts, selecting target sequences, configuring granularity, and analyzing specific segments.

Case Studies and Key Insights

The tool's utility was demonstrated through case studies involving few-shot prompting, Chain-of-Thought (CoT) reasoning, and Constitutional AI principles.

Granularity and Debugging

By providing a running-text view that aggregates scores into sentences, the tool makes it immediately obvious which part of a prompt is driving model behavior. For example, salience analysis revealed that a model was ignoring a recommendation because a preceding "Analysis" line in a few-shot example contained a logical error—a copy-paste mistake by the developer.

A sentence-level salience map showing how a specific "Analysis" line in the prompt heavily influences the model's recommendation.

Verifying Instructions and Side-by-Side Comparison

Sequence Salience allows developers to verify if a model is "listening" to specific instructions, such as "Constitutional Principles" (e.g., "be brief and to the point"). Furthermore, by pinning one version of a prompt and comparing it to a revised version, developers can see exactly how focus shifts. In math problem debugging, removing verbose annotations was shown to shift the model's focus more strongly onto the actual numerical operands.

Conclusion

Sequence Salience provides a practical, efficient way for practitioners to debug complex LLM prompts across various strategies. While salience methods are heuristics rather than causal proofs, they offer invaluable insights into the internal state of the model. The system currently supports popular open models like Gemma, Llama 2, and Mistral, with future work aimed at exploring more causally-robust methods and multi-modal support.

Summary updated

BibTeX
@misc{tenney2024interactive,
  author = {Ian Tenney and Ryan Mullins and Bin Du and Shree Pandya and Minsuk Kahng and Lucas Dixon},
  title = {{Interactive Prompt Debugging with Sequence Salience}},
  year = {2024},
  eprint = {2404.07498},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2404.07498},
}
Figure