Revealing the Unwritten: Visual Investigation of Beam Search Trees to Address Language Model Prompting Challenges

Thilo Spinner, Rebecca Kehlbeck, Rita Sevastjanova, Tobias Stähle, Daniel A. Keim, Oliver Deussen, Andreas Spitz, Mennatallah El-AssadyarXiv 2023

Abstract

The growing popularity of generative language models has amplified interest in interactive methods to guide model outputs. Prompt refinement is considered one of the most effective means to influence output among these methods. We identify several challenges associated with prompting large language models, categorized into data- and model-specific, linguistic, and socio-linguistic challenges. A comprehensive examination of model outputs, including runner-up candidates and their corresponding probabilities, is needed to address these issues. The beam search tree, the prevalent algorithm to sample model outputs, can inherently supply this information. Consequently, we introduce an interactive visual method for investigating the beam search tree, facilitating analysis of the decisions made by the model during generation. We quantitatively show the value of exposing the beam search tree and present five detailed analysis scenarios addressing the identified challenges. Our methodology validates existing results and offers additional insights.

Introduction

Prompt engineering has emerged as a critical yet opaque discipline in the era of Large Language Models (LLMs). While users frequently iterate on prompts to achieve desired outputs, the underlying reasons for a model's failure—or its sensitivity to minor textual changes—often remain hidden. Standard text generation typically only reveals the "winning" sequence of tokens, discarding the vast amount of probabilistic data generated during the inference process. This "black box" nature makes it difficult to distinguish between a model's lack of knowledge and a failure in the decoding process where a correct answer was narrowly defeated by a hallucination.

Methodology: Visualizing the Beam Search Tree

To address these challenges, we introduce generAItor, a visual analytics tool designed to expose the Beam Search Tree (BST). Beam search is the standard algorithm used by LLMs to maintain the $k$ most likely sequences at each generation step. While traditional systems discard non-winning paths, generAItor preserves and visualizes them as an interactive roadmap of the model's decision-making process.

The visual grammar of the Beam Search Tree (BST) in generAItor, highlighting main branches, runner-up candidates, and transition probabilities.

The tool incorporates several key technical features:

  • Branch Ranking (Algorithm 1): A novel ranking system that identifies the most significant alternative paths, preventing users from being overwhelmed by low-probability noise.
  • Comparative Visualization: A dual-view mode that allows researchers to run two variations of a prompt side-by-side to pinpoint exactly where the model's internal logic diverges.
  • Semantic Highlighting: Nodes are colored based on word embeddings, allowing for the visual identification of thematic clusters (e.g., occupations or sentiments) within the tree.

Addressing Prompting Challenges

Our investigation identifies five core challenges that are difficult to debug using standard text output alone:

  1. Prompt Sensitivity: Minor changes, such as adding a leading space or a period, can radically alter the output.
  2. Surface Form Competition: Multiple valid tokens for the same concept (e.g., "U.S." vs. "United States") can split the probability mass, allowing an incorrect but more concentrated token to win.
  3. Negation: Models often struggle with negative constraints (e.g., "Do not use the word X"), frequently resulting in the forbidden word appearing in the output.
  4. Quantifiers: The handling of words like "all," "some," or "few" varies significantly across model scales.
  5. Bias: Stereotypical associations often reside just below the surface in high-probability runner-up branches.
Comparative visualization of prompt sensitivity: The tool shows how minor variations in the prompt (like adding a space) cause the model's output paths to diverge significantly.

Key Insights and Results

Our analysis using models like BLOOM-3b and RedPajama-INCITE revealed several striking phenomena. Notably, we observed a "Negation Backfire": explicitly telling a model not to use a word often increases that word's probability. The BST shows that the model recognizes the forbidden term in the prompt and mistakenly "primes" itself to generate it.

Quantitatively, we found that the most valuable alternative information is almost always contained within the top two runner-up branches (Rank 1 and 2). Looking deeper into the tree (Rank 4+) rarely yielded useful insights, as those paths tended to dissipate quickly. Furthermore, we demonstrated that "correct" keywords often appear in runner-up branches with high normalized probabilities ($p > 0.3$), proving that standard generation methods discard a significant amount of valid information.

Limitations and Future Work

The primary limitation of this methodology is the "API Wall"; it requires access to internal token probabilities, which is currently only possible with open-source models. Future work will explore using this visual framework to "steer" models interactively, allowing users to manually select runner-up branches to correct the model's path in real-time. Additionally, expanding the study to non-English linguistic phenomena will be essential for a global understanding of LLM behavior.

Summary updated

BibTeX
@misc{spinner2023revealing,
  author = {Thilo Spinner and Rebecca Kehlbeck and Rita Sevastjanova and Tobias Stähle and Daniel A. Keim and Oliver Deussen and Andreas Spitz and Mennatallah El-Assady},
  title = {{Revealing the Unwritten: Visual Investigation of Beam Search Trees to Address Language Model Prompting Challenges}},
  year = {2023},
  eprint = {2310.11252},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2310.11252},
}
Figure