Unveiling LLMs: The Evolution of Latent Representations in a Dynamic Knowledge Graph

Marco Bronzini, Carlo Nicolini, Bruno Lepri, Jacopo Staiano, Andrea Passerini

TL;DR

This paper introduces a novel framework that uses activation patching to visualize how Large Language Models (LLMs) store and evolve factual knowledge across their layers. By representing this knowledge as a dynamic graph, the authors gain insights into LLMs' reasoning processes, revealing how word-level facts transform into claim-specific understanding and identifying potential error sources.

What Problem Does This Paper Address?

LLMs are remarkably good at recalling facts, but how they internally represent and use this knowledge for tasks like claim verification remains a significant mystery. Researchers want to understand the "black box" of LLM reasoning to build more reliable and interpretable AI. Specifically, this paper aims to answer:

  1. What factual knowledge do LLMs use to verify claims?
  2. How does this knowledge change as information passes through different layers of the model?
  3. Are there distinct patterns in this knowledge evolution?

Methods

The core of the paper is an end-to-end framework that decodes factual knowledge from LLM latent representations without requiring additional training or external models.

  • Activation Patching: This technique involves altering a specific token's representation during an LLM's inference process. By strategically replacing a token's internal state with a synthesized representation of the input sentence, the researchers can probe what knowledge is being activated.
  • Summary Representation: Instead of patching individual tokens, the authors create a "summary" of the input sentence's token representations using a weighted sum. This approach leverages the additive property of token representations and is more efficient than patching every token.
  • Dynamic Knowledge Graph: The extracted factual information (represented as ground predicates like IsDate(Christmas Day, December 25)) is then organized into a dynamic knowledge graph. The layers of the LLM serve as the temporal dimension of this graph, allowing researchers to visualize the evolution of knowledge.

Datasets

The framework was evaluated using claims from two well-known claim verification datasets:

  • FEVER: Focuses on factual claims.
  • CLIMATE-FEVER: Deals with real-world claims related to climate change, often requiring more common-sense reasoning.

The authors filtered these datasets to exclude claims that were too short or too long, or those lacking sufficient information.

Key Insights and Ideas

  • Knowledge Evolution is Layer-Dependent: The study clearly shows that factual knowledge isn't static within an LLM. Early layers tend to focus on syntactic information and basic entity recognition, while later layers build upon this to form more complex, claim-specific understanding.
  • Word-Level to Claim-Level Transformation: The research demonstrates a progression from general word-based factual knowledge in earlier layers to more specific, claim-related facts in deeper layers.
  • Entity Centrality in Reasoning: Local analysis highlights how specific entities within a claim play a crucial role in the LLM's reasoning process.
  • Representation Errors and Biases: The framework can uncover instances where LLMs make erroneous evaluations due to misinterpretations or biases, such as confusing entities or exhibiting unexpected focus on in-context examples.
  • Potential for Catastrophic Forgetting/Attention Shifts: In later layers, the model sometimes exhibits degraded performance or shifts attention to irrelevant parts of the input, suggesting potential issues like catastrophic forgetting or attention mechanism limitations.

Key Results

  • Classification Performance: The LLM (LLaMA 2 7B) achieved decent performance on claim verification, with ROC AUC scores of 0.68 for FEVER and 0.74 for CLIMATE-FEVER. However, performance varied significantly between true and false claims, with lower recall for true claims.
  • Local Interpretability: The dynamic knowledge graphs revealed specific instances of reasoning, such as the confusion between Charlemagne and Charles V in one claim, and the misattribution of an acronym to a different entity in another.
  • Global Interpretability: Analysis of graph similarities across layers identified distinct clusters, suggesting "transaction points" where the nature of the encoded knowledge shifts. Early layers (L1-L3) were found to focus on syntax and entity resolution, while later layers (L4 onwards) showed a higher rate of valid factual information generation.

Limitations and Future Work

  • Qualitative Evaluation: The current evaluation of generated factual information is primarily qualitative, lacking a definitive ground truth for comparison.
  • Model and Task Specificity: The insights gained are specific to the tested LLM (LLaMA 2) and the claim verification task. Different architectures or tasks might yield different patterns.
  • Future Directions: The authors suggest extending the framework by:
  • Varying the considered tokens to study information flow.
  • Conducting more advanced graph-related analyses.
  • Quantifying the relevance of generated factual information to the input claim.

Summary updated

BibTeX
@inproceedings{bronzini2024unveiling,
  author = {Marco Bronzini and Carlo Nicolini and Bruno Lepri and Jacopo Staiano and Andrea Passerini},
  title = {{Unveiling LLMs: The Evolution of Latent Representations in a Dynamic Knowledge Graph}},
  booktitle = {COLM},
  year = {2024},
  url = {https://openreview.net/forum?id=dWYRjT501w},
}
Figure