ULTra: Unveiling Latent Token Interpretability in Transformer-Based Understanding

Hesam Hosseini, Ghazal Hosseini Mighan, Amirabbas Afzali, Sajjad Amini, Amir Houmansadr · DOI · OpenReview

Introduction

Transformers have revolutionized artificial intelligence, yet their internal decision-making processes remain largely opaque. While most interpretability research focuses on the final output—explaining why a model predicts a specific class—this approach overlooks the complex intermediate processing occurring within hidden layers. The ULTra (Unveiling Latent Token Interpretability) framework addresses this gap by investigating whether individual "latent tokens" in intermediate layers possess inherent semantic awareness. By tracing the influence of these tokens back to the original input, ULTra reveals how Transformers organize information into meaningful concepts long before reaching a final prediction.

Methodology: The ULTra Framework

ULTra operates through a two-step process designed to visualize the "receptive field" of specific latent embeddings.

The ULTra framework: A backward trace from a target latent token through attention matrices to generate input-space explanation maps.

1. The Backward Trace

After a standard forward pass, a target latent token is selected. A scalar function of this token’s embedding (such as its vector norm or sum) is defined as a signal. This signal is then backpropagated through the attention matrices of preceding layers. This process creates "contribution maps" that quantify how much each input element influenced the specific latent representation.

2. Explanation Mapping

These contribution maps are aggregated across layers to produce a high-resolution heatmap in the input space. This heatmap serves as an "explanation map," pinpointing the exact regions of an image or text string that the latent token represents.

The authors propose three variants of the framework:

  • ULTra$_S$ and ULTra$_E$: Training-free versions that utilize simple summation or energy (norm) functions for the backward trace.
  • ULTra$_W$: A lightweight version that learns a transformation matrix $W$ using a Self-Consistency loss. This approach "sharpens" semantic focus by rewarding the model for maintaining stable latent representations when non-essential input regions are perturbed.

Experimental Setup

The framework was evaluated across diverse benchmarks to test its versatility:

  • Computer Vision: Tasks included unsupervised semantic segmentation on datasets such as COCO-Stuff 27, PASCAL VOC 2012, Potsdam-3, and Cityscapes.
  • Natural Language Processing: The Llama-2-7B model was interpreted using the TL;DR dataset of Reddit post summaries.
  • Baselines: ULTra was compared against established unsupervised methods, including DINO, STEGO, and PiCIE.

Key Insights and Results

ULTra demonstrates that latent tokens are not merely abstract vectors but "semantic specialists." In complex scenes, different tokens naturally focus on distinct objects or fine-grained details, such as a specific part of an animal or the background.

Visualization of latent token explanation maps and resulting binary masks for unsupervised semantic segmentation.

Unsupervised Semantic Segmentation

A major finding is that ULTra enables state-of-the-art unsupervised semantic segmentation without any fine-tuning. By applying hierarchical clustering to the generated explanation maps, the system can automatically identify and segment objects. On the COCO-Stuff dataset, ULTra$_W$ achieved a 38.2 mIoU, significantly outperforming previous benchmarks like STEGO (28.2 mIoU).

The "Sweet Spot" of Model Depth

The research highlights that semantic precision is not linear with depth. Segmentation performance typically peaks in the mid-to-late layers. While the final layers provide high-level abstraction, they often lose the spatial precision required for accurate segmentation, suggesting that the most "meaningful" spatial representations reside in the intermediate layers.

Cross-Modal Versatility and Faithfulness

The framework proves equally effective for Large Language Models (LLMs). Using the Comprehensiveness metric, the authors showed that tokens identified as important by ULTra are indeed critical for the model's confidence during text generation. This confirms that the interpretability provided by ULTra is faithful to the model's internal logic.

Limitations and Future Directions

Despite its success, ULTra faces challenges regarding computational overhead. Generating a full segmentation map requires a separate backward pass for every token, which can be time-consuming for high-resolution inputs. Additionally, the method's sensitivity to patch size in Vision Transformers can make clustering difficult when dealing with a very high number of tokens.

Future work will focus on optimizing the framework through gradient approximations or parallel processing. There is also significant potential in applying ULTra to model alignment, helping researchers understand the internal reasoning of LLMs during Reinforcement Learning from Human Feedback (RLHF).

Summary updated

BibTeX
@article{hosseini2025ultra,
  author = {Hesam Hosseini and Ghazal Hosseini Mighan and Amirabbas Afzali and Sajjad Amini and Amir Houmansadr},
  title = {{ULTra: Unveiling Latent Token Interpretability in Transformer-Based Understanding}},
  journal = {Accepted by TMLR},
  year = {2025},
  url = {https://openreview.net/forum?id=vL3pmJjGDQ},
}
Figure