Patchscopes: A Unifying Framework for Inspecting Hidden Representations of Language Models

Asma Ghandeharioun, Avi Caciularu, Adam Pearce, Lucas Dixon, Mor Geva

Introduction

Large Language Models (LLMs) have demonstrated remarkable capabilities, yet their internal decision-making processes remain largely opaque. Understanding how these models represent information in their hidden layers is a central challenge in interpretability. Traditional methods like linear probing require labeled datasets and are restricted to predefined classes, while vocabulary projection techniques (e.g., Logit Lens) often fail in early and middle layers where representations have not yet converged to specific tokens.

The Patchscopes Framework

Patchscopes addresses these limitations by using the LLM itself as a "translator" for its own internal states. The framework consists of a modular four-step process designed to verbalize hidden representations into human-readable text.

The four-step Patchscopes framework: Source computation, Transformation, Target setup, and Patching.
  1. Source Computation: The model processes a source prompt (e.g., "Amazon's former CEO..."), and a hidden representation $h$ is extracted from a specific layer.
  2. Transformation: The representation $h$ may undergo an optional transformation (such as an affine mapping) to ensure compatibility with the target context.
  3. Target Setup: A separate inference pass is initiated with a "target prompt" designed to elicit specific information (e.g., a few-shot identity prompt like "cat -> cat; apple -> apple; ?").
  4. The Patch: The internal representation of a placeholder token in the target prompt is replaced with the (transformed) representation $h$. The model then generates a completion based on this "patched" state.

Experimental Results

The researchers evaluated Patchscopes across various benchmarks, including The Pile, WikiText-103, and PopQA. A key finding is that Patchscopes significantly outperforms existing decoding methods.

Performance comparison of Patchscopes (Token Identity) vs. Logit Lens and Tuned Lens across multiple models.

As shown in Figure 3, Patchscopes (referred to as "Token Identity") achieves up to 98% higher precision in middle layers compared to the Logit Lens. This suggests that the model's generative head is a far more expressive decoder of internal states than simple linear projections. Furthermore, in zero-shot attribute extraction tasks, Patchscopes performed comparably to or better than supervised logistic regression probes without requiring any training data.

Key Insights and Applications

Beyond simple decoding, Patchscopes enables several advanced interpretability tasks:

  • Entity Resolution: By using "description" prompts, researchers can observe how a model's understanding of an entity (e.g., "Alexander the Great") evolves from generic concepts in early layers to specific historical figures in later layers.
  • Cross-Model Inspection: Hidden states from smaller models can be patched into larger, more capable models. This allows the "smarter" model to act as a high-resolution lens, explaining the internal states of the "weaker" model with greater clarity.
  • Latent Error Correction: Patchscopes can diagnose and fix reasoning failures. In multi-hop reasoning tasks, the framework improved accuracy from 19.57% to 50% by manually "rerouting" internal representations to ensure the model correctly passes information between logical steps.

Limitations

While powerful, the framework faces challenges such as "placeholder contamination," where the original representation of the target prompt's placeholder token influences the output in very deep layers. Additionally, cross-model patching currently requires learned mappings to align layers between different architectures. Future work aims to extend Patchscopes to multi-token sequences and more complex internal "thoughts."

Summary updated

BibTeX
@inproceedings{ghandeharioun2024patchscopes,
  author = {Asma Ghandeharioun and Avi Caciularu and Adam Pearce and Lucas Dixon and Mor Geva},
  title = {{Patchscopes: A Unifying Framework for Inspecting Hidden Representations of Language Models}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=5uwBzcn885},
}
Figure