DataInf: Efficiently Estimating Data Influence in LoRA-tuned LLMs and Diffusion Models

Yongchan Kwon, Eric Wu, Kevin Wu, James Zou

Understanding why a Large Language Model (LLM) or a Diffusion model produces a specific output is one of the most pressing challenges in AI transparency. If a model generates a biased response or a factually incorrect image, which training examples are to blame? Traditionally, researchers have turned to influence functions to answer this, but these methods are notoriously slow and often break down when scaled to billions of parameters.

In their ICLR 2024 paper, Kwon et al. introduce DataInf, a computationally efficient method for estimating data influence that is specifically optimized for the modern era of parameter-efficient fine-tuning (PEFT).

TL;DR

DataInf provides a closed-form, easy-to-compute approximation for influence functions, making it possible to perform data attribution on massive models like Llama-2 and Stable Diffusion. It is orders of magnitude faster than previous iterative methods and is particularly effective when models are fine-tuned using techniques like LoRA.

What Problem Does This Paper Address?

The "influence function" is a classic statistical tool used to quantify how much a specific training point affects a model's final parameters. Mathematically, it involves calculating the inverse of the Hessian matrix (the matrix of second-order derivatives of the loss function).

For a model with $d$ parameters, the Hessian is a $d \times d$ matrix. For a 7-billion parameter model, this matrix is far too large to store, let alone invert. Existing approximations like LiSSA (Linear time-Stochastic Second-Order Algorithm) use iterative solvers to bypass the full inversion, but these are often numerically unstable, slow, and struggle to converge in high-dimensional spaces. This makes it nearly impossible for developers to debug training data at scale.

Methods

DataInf simplifies the influence calculation through a clever mathematical "swap."

  1. Fisher Information Approximation: Instead of the true Hessian, the authors use the second moment of gradients (the Fisher Information Matrix), which is standard for deep learning.
  2. The DataInf Trick: The core innovation is swapping the order of matrix inversion and averaging. Instead of trying to invert the average of many rank-one matrices (which is computationally expensive), DataInf approximates this by taking the average of the inverses of individual rank-one matrices (which is much easier).
  3. Sherman-Morrison Formula: By adding a small damping term ($\lambda I$), each individual matrix becomes an identity matrix plus a rank-one update. This allows the use of the Sherman-Morrison formula, providing a closed-form solution that avoids iterative loops entirely.

The authors provide a theoretical error analysis showing that the approximation error scales with $O(d^2)$, where $d$ is the number of trainable parameters. This makes DataInf a perfect match for LoRA (Low-Rank Adaptation), where only a tiny fraction of the model's parameters are actually updated during fine-tuning.

Datasets

The authors evaluated DataInf across several domains:

  • Classification (GLUE): MRPC, SST2, WNLI, and QQP were used to test mislabeled data detection.
  • Text Generation (Llama-2-13B-chat): Custom datasets for sentence transformations and math word problems (with and without reasoning steps).
  • Image Generation (Stable Diffusion v1.5):
    • Style Transfer: Using datasets for cartoons, pixel art, and sketches.
  • Subject Generation: Using the DreamBooth dataset (31 unique subjects like specific dogs or backpacks).

Key Insights and Ideas

  • LoRA Synergy: DataInf turns the "curse of dimensionality" into a strength. Because it works best when the number of trainable parameters is small, it is uniquely suited for the current industry standard of fine-tuning large models via LoRA.
  • Stability over Iteration: Methods like LiSSA are prone to "exploding" or failing to converge. Because DataInf is a direct, closed-form calculation, it is significantly more robust and consistent across different model architectures.
  • Efficiency Gains: By avoiding the need to store or iteratively process large Hessian-vector products, DataInf reduces both time and memory complexity to levels comparable to simple first-order gradient methods (Hessian-free), but with much higher accuracy.

Key Results

  • Speed: On the GLUE-QQP dataset, DataInf computed influence scores for 4,500 points in just 13 seconds. In comparison, LiSSA took 70 seconds, and the "Exact" method took over 3 hours (11,279 seconds).
  • Accuracy: DataInf showed a much higher correlation with exact influence scores than other approximations across various LoRA ranks.
Correlation of DataInf vs. baselines across different LoRA ranks.
  • Data Debugging: DataInf was significantly better at identifying mislabeled training examples. It achieved higher AUC scores for detecting noisy data while remaining orders of magnitude faster than the "Exact" baseline.
Mislabeled data detection performance (AUC) vs. Runtime.
  • Generative AI Attribution: In Llama-2 and Stable Diffusion, DataInf successfully retrieved the most relevant training examples for specific prompts. For instance, when Llama-2 solved a math problem, DataInf correctly identified other math problems in the training set as the most influential.

Limitations and Future Work

While DataInf is a major step forward, the authors note a few limitations:

  • Full-Parameter Tuning: Because the error bound depends on the number of parameters ($d$), DataInf might be less accurate for full-parameter fine-tuning of massive models compared to LoRA-tuned ones.
  • Damping Parameter: The method relies on a damping parameter ($\lambda$), which currently requires some heuristic tuning.
  • Evaluation Metrics: Quantifying "influence" in generative tasks is still an open research area. The authors used proxies like "class detection AUC," but more robust metrics for open-ended generation are needed.

Overall, DataInf represents a practical bridge between theoretical data attribution and the reality of massive, modern generative models.

Summary updated

BibTeX
@inproceedings{kwon2024datainf,
  author = {Yongchan Kwon and Eric Wu and Kevin Wu and James Zou},
  title = {{DataInf: Efficiently Estimating Data Influence in LoRA-tuned LLMs and Diffusion Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=9m02ib92Wz},
}
Figure