Do Influence Functions Work on Large Language Models?

Zhe Li, Wei Zhao, Yige Li, Jun Sun

Abstract

Influence functions are important for quantifying the impact of individual training data points on a model's predictions. Although extensive research has been conducted on influence functions in traditional machine learning models, their application to large language models (LLMs) has been limited. In this work, we conduct a systematic study to address a key question: do influence functions work on LLMs? Specifically, we evaluate influence functions across multiple tasks and find that they consistently perform poorly in most settings. Our further investigation reveals that their poor performance can be attributed to: (1) inevitable approximation errors when estimating the iHVP component due to the scale of LLMs, (2) uncertain convergence during fine-tuning, and, more fundamentally, (3) the definition itself, as changes in model parameters do not necessarily correlate with changes in LLM behavior. Thus, our study suggests the need for alternative approaches for identifying influential samples.

1. Introduction

As Large Language Models (LLMs) are increasingly deployed in sensitive domains, understanding the provenance of specific model outputs becomes critical. Data attribution aims to trace a model's prediction back to the training examples that most influenced it. While "leave-one-out" retraining is computationally prohibitive for LLMs, Influence Functions (IFs) have emerged as a popular mathematical shortcut. By utilizing gradients and the Hessian matrix (second-order derivatives), IFs estimate influence without retraining. This study evaluates whether these classical methods maintain their utility at the scale of 7-billion parameter models.

2. Methodology

The researchers evaluated several state-of-the-art influence function methods, including DataInf, LiSSA, and Hessian-free (gradient matching). These were benchmarked against RepSim (Representation Similarity), a simpler baseline that identifies influential data based on the similarity of internal vector representations. To handle the computational complexity of 7B-parameter models like Llama-2 and Mistral, the study employed LoRA (Low-Rank Adaptation), restricting the analysis to a subset of trainable parameters.

Evaluation focused on three primary challenges:

  • Harmful Data Identification: Detecting "poisoned" samples that compromise safety alignment.
  • Class Attribution: Identifying training samples belonging to the same category as a test input.
  • Backdoor Detection: Finding training points with hidden triggers that force specific behaviors.

3. Why Influence Functions Fail on LLMs

The study identifies three fundamental reasons for the failure of IFs in the context of LLMs:

  1. The Hessian Identity Crisis: In high-dimensional LLM parameter spaces, the Hessian matrix is often sparse. To ensure invertibility, a "damping" term is added. At LLM scales, this damping causes the inverse Hessian to behave like an identity matrix, reducing complex IFs to simple gradient matching and negating their theoretical advantages.
  2. The Convergence Trap: IFs assume the model has reached a stable local minimum. However, LLM fine-tuning is often stopped early or exhibits fluctuations, resulting in "noisy" gradients that degrade influence estimates.
  3. Behavior vs. Parameters: Most critically, IFs measure influence based on changes to internal parameters ($\theta$). The authors found that in LLMs, significant behavioral shifts (e.g., a 90% increase in harmfulness) can occur with negligible parameter changes. Conversely, large parameter shifts may not alter behavior at all, making parameter-based metrics a poor proxy for influence.

4. Results and Discussion

Empirical results across multiple benchmarks—including Emotion classification, Grammar transformations, and MathQA—demonstrate that influence functions are consistently outperformed by the RepSim baseline.

Performance comparison of Llama2-7b and Mistral-7b across tasks, showing RepSim significantly outperforming Hessian-based influence functions in both accuracy and coverage.

In safety-critical tasks, the accuracy of IF methods plummeted as the ratio of benign to harmful data increased. While RepSim maintained high accuracy in identifying harmful samples, IF methods often failed in realistic, unbalanced scenarios. Furthermore, the researchers observed that models with drastically different safety profiles exhibited nearly identical parameter norms ($\lVert\Delta\theta\rVert_2$), confirming that measuring parameter change is the "wrong ladder" for understanding LLM behavior.

5. Conclusion

The findings suggest that traditional gradient-Hessian influence functions are ill-suited for the scale and training dynamics of LLMs. The research community should pivot toward more robust representation-based attribution methods or develop new frameworks that prioritize behavioral shifts over raw parameter changes.

Summary updated

BibTeX
@misc{li2024do,
  author = {Zhe Li and Wei Zhao and Yige Li and Jun Sun},
  title = {{Do Influence Functions Work on Large Language Models?}},
  year = {2024},
  eprint = {2409.19998},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2409.19998},
}
Figure