Where Did It Go Wrong? Attributing Undesirable LLM Behaviors via Representation Gradient Tracing

Zhe Li, Wei Zhao, Yige Li, Jun Sun
9/26/2025
cs.CLcs.AIcs.LG

Official code: plumprc/RepT (5 stars, last commit 2025-10-22).

Abstract

Large Language Models (LLMs) have demonstrated remarkable capabilities, yet their deployment is frequently undermined by undesirable behaviors such as generating harmful content, factual inaccuracies, and societal biases. Diagnosing the root causes of these failures poses a critical challenge for AI safety. Existing attribution methods, particularly those based on parameter gradients, often fall short due to prohibitive noisy signals and computational complexity. In this work, we introduce a novel and efficient framework that diagnoses a range of undesirable LLM behaviors by analyzing representation and its gradients, which operates directly in the model's activation space to provide a semantically meaningful signal linking outputs to their training data. We systematically evaluate our method for tasks that include tracking harmful content, detecting backdoor poisoning, and identifying knowledge contamination. The results demonstrate that our approach not only excels at sample-level attribution but also enables fine-grained token-level analysis, precisely identifying the specific samples and phrases that causally influence model behavior. This work provides a powerful diagnostic tool to understand, audit, and ultimately mitigate the risks associated with LLMs. The code is available at https://github.com/plumprc/RepT.

View on arXivView PDF

Code Implementations(1)

plumprc/RepTOfficial100%

Attributing Undesirable LLM Behaviors via Representation Gradient Tracing

50PythonAug 22, 202512 months ago

Similar Papers

Cite this paper

@article{li2025where,
  title  = {Where Did It Go Wrong? Attributing Undesirable LLM Behaviors via Representation Gradient Tracing},
  author = {Zhe Li and Wei Zhao and Yige Li and Jun Sun},
  year   = {2025},
  eprint = {2510.02334},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2510.02334v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2510.02334.svg)](https://codeofpaper.com/paper/2510.02334)

Discussion