Exposing the Unsaid: Visualizing Hidden LLM Bias through Stochastic Path Aggregation

Matteo Pelossi, Rita Sevastjanova, Thilo Spinner, Mennatallah El-AssadyarXiv 2026

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.

Fig. 1: We introduce TREETRACER, a visual analytics approach for bias detection through aggregated comparison. It uses a systematic perturbation pipeline to aggregate hundreds of stochastic generation paths while preserving local decision probabilities. We then visualize the resulting probability trees with a novel Sankey adaptation, combine side-by-side ontology-driven views with a custom contrastive inference mode that computes counterfactual probabilities across contexts for rigorous bias analysis.

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:

  1. 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).
  2. 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.
  3. Constituency Parsing: Each generation is parsed into a grammatical structure using the Stanza NLP library.
  4. 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.
  5. 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").
  6. Tree Construction: Identical tokens sharing the same semantic context are merged into a hierarchical structure.
Fig. 2: We employ a perturbation pipeline to produce augmented variants of the initial prompt (1). Each variant is submitted to an LLM (2). We then derive constituency parse trees for every text generation (3) and cluster them with a structure-aware clustering method (4). Merging nodes (6) using a semantic token taxonomy (5) yields a Sankey-style tree whose layout tracks semantic change across the generated outputs.

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.
Fig. 4: The users can filter branches by hovering over the nodes. A tooltip displays the prefix of the selected node, the ontology words that lead to this generation, and their probabilities.

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

Abstract

Large Language Models (LLMs) exhibit representational and syntactic biases that are difficult to evaluate due to the stochastic nature of text generation. Standard auditing methods rely on a single output inspection or static automated metrics. These approaches obscure the underlying probability distributions and fail to capture biases hidden in lower-probability generation branches. This paper introduces TreeTracer, a visual analytics tool designed to evaluate LLM bias through aggregated comparison. Using a systematic perturbation analysis pipeline, the tool replaces ontology-defined terms in each input prompt, aggregates hundreds of stochastic generations into a syntax-aligned hierarchical structure, and then performs classification-aware node merging with an auxiliary language model. The resulting structure is visualized through a custom Sankey diagram. By juxtaposing two ontology-driven trees, the workspace enables direct comparison between semantic contexts and supports systematic bias detection. Because any visualization reflects only a subset of the model's learned behavior, the system further applies contrastive inference to compute and directly display counterfactual token probabilities across contexts, reducing the risk of misinterpreting the presence of bias. We validate the workspace through case studies comparing an unaligned baseline model GPT-2 XL against the constitutionally aligned Apertus models. The visual aggregation successfully exposes hidden representational harms, such as counterfactual pronoun suppression and conversational marginalization of individuals. A preliminary user study confirms that the aggregated comparative interface reduces cognitive load and effectively supports analysts in detecting systemic biases.
BibTeX
@misc{pelossi2026exposing,
  author = {Matteo Pelossi and Rita Sevastjanova and Thilo Spinner and Mennatallah El-Assady},
  title = {{Exposing the Unsaid: Visualizing Hidden LLM Bias through Stochastic Path Aggregation}},
  year = {2026},
  eprint = {2606.19344},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2606.19344},
}
Figure