TL;DR
TreeTracer is a novel visual analytics tool that exposes hidden biases in Large Language Models (LLMs) by aggregating hundreds of stochastic generation paths into a unified, syntax-aligned Sankey diagram. By combining systematic prompt perturbation with contrastive inference, it reveals subtle representational harms and biases lurking in low-probability generation branches that standard single-output auditing methods completely miss.
What Problem Does This Paper Address?
As LLMs are increasingly deployed in high-stakes domains like healthcare and hiring, understanding their embedded social biases is critical. However, auditing these biases is uniquely challenging because text generation is inherently stochastic.
Standard evaluation methods typically rely on inspecting a single top-scoring output or calculating static automated metrics (like perplexity or BLEU). These approaches create a statistical blind spot: they obscure the underlying probability distributions and fail to capture biases hidden in lower-probability generation branches. Furthermore, traditional bias audits rely on rigid, predefined sentence templates that fail to capture the diversity of real-world syntactic variations where bias naturally manifests.
Methods
The authors introduce TreeTracer, a visual analytics workspace built around a six-step computational pipeline designed to handle hundreds of stochastic text generations:
- Prompt Augmentation and Ontology Injection: The tool isolates a target token in a base prompt and systematically replaces it with terms from a semantic ontology (e.g., swapping male and female names).
- Text Generation and Token Alignment: The system runs multiple stochastic generations and uses a geometric mean strategy to merge subword tokens back into whole words without unfairly penalizing longer words.
- Constituency Parsing: Each generation is parsed into a grammatical structure using the Stanza NLP library.
- Structural Clustering: To prevent visual clutter, sentences sharing the same syntactic template are grouped using tree-alignment algorithms, retaining only the top structures as a visual backbone.
- Semantic Classification: A secondary helper LLM dynamically categorizes generated tokens into contextual semantic classes (e.g., distinguishing between a river "bank" and a financial "bank").
- Tree Construction: Identical tokens sharing the same semantic context are merged into a hierarchical structure.
To make comparison rigorous, TreeTracer introduces a custom Sankey-style visualization that intentionally breaks standard flow-conservation rules. It decouples Node Height (representing global probability across all generated samples) from Link Width (local confidence within the selected structural subset). This ensures that even if a biased token appears in a rare syntactic structure that gets pruned, its overall probability mass remains visually prominent.
Finally, the tool utilizes Contrastive Inference. It forces the model to calculate counterfactual probabilities for a token across both original prompt conditions, revealing the true internal probability distribution even for words that the decoding algorithm dropped.
Datasets
Rather than relying on static datasets, TreeTracer dynamically generates ontologies using:
- ConceptNet: A multilingual knowledge graph used to bootstrap word lists via breadth-first search queries.
- Instruction-Tuned LLMs: Used to generate highly contextual, domain-specific word lists (e.g., Non-Western Male Names or Modern Occupations).
- Human-in-the-Loop Overrides: Users can manually edit, filter, or reclassify terms to prevent the helper LLM's own biases from polluting the audit.
The system was evaluated using three models: GPT-2 XL (as an unaligned baseline), Apertus-8B-Base, and Apertus-70B-Instruct-2509.
Key Insights and Ideas
- Bias Hides in the Long Tail: Evaluating only the top-1 completion misses where probabilistic trajectories shift mid-sentence. Biases often manifest as subtle shifts in probability mass rather than total output changes.
- The Counterfactual Blind Spot: The absence of a word in a generated text does not mean its internal probability is zero. Contrastive probing is required to uncover the model's true latent associations.
- Syntactic Rigidity: Unaligned models like GPT-2 XL suffer from "syntactic-domain spurious correlation." When given a semantically unusual prompt (e.g., asking where a food item is geographically located), the model blindly follows learned grammatical templates, confidently outputting nonsensical phrases like "Sushi is located at the front entrance of the park."
Key Results
The authors validated TreeTracer through several case studies and a user study:
- Gender Bias: In Apertus-8B-Base, changing the prompt subject from male to female names caused the probability mass to heavily concentrate in caregiving and educational roles. Contrastive analysis showed that the token "teacher" had a 60.2% counterfactual preference for female names, while "professional" had a 68.6% preference for male names.
- Toxicity: Auditing GPT-2 XL revealed that prompts containing Arab geographic names frequently flowed into semantic clusters labeled "Political & Religious Extremism," showing an 80.5% counterfactual preference for the token "religious" compared to Western geographic names.
- Safety Alignment: The tool successfully visualized how the aligned Apertus-70B model bottlenecks dangerous medical queries into hard refusal nodes, whereas GPT-2 XL readily provided instructions on how to ingest poison.
- User Study: A study involving seven computer science students evaluating TreeTracer against a baseline text-generation tool showed that TreeTracer significantly reduced cognitive overload. The tool achieved a strong System Usability Scale (SUS) score of 76.9, well above the industry average of 68.
Limitations and Future Work
- Computational Overhead: Generating, parsing, and calculating Tree Edit Distance for hundreds of stochastic paths is computationally expensive and scales poorly as the generation pool grows.
- Dependency on Helper Models: The pipeline relies on an auxiliary LLM for semantic classification and ontology generation, introducing a risk that the helper model's own biases might skew the analysis.
- The Butterfly Effect: TreeTracer perturbs target ontologies systematically but does not yet account for how minor, non-perturbed variations in prompt phrasing or punctuation might drastically alter model behavior. Future work aims to incorporate structural stability testing with micro-variations.
Summary updated