Dataset Size Recovery from LoRA Weights

Mohammad Salama, Jonathan Kahana, Eliahu Horwitz, Yedid HoshenarXiv 2024 · DOI

Introduction

The rapid adoption of Low-Rank Adaptation (LoRA) for fine-tuning large-scale generative models has introduced new privacy and business considerations. While existing research focuses on model inversion and membership inference, these attacks often lack a critical piece of information: the size of the original training dataset. Knowing the dataset size is essential for determining the success of data recovery efforts and for establishing fair usage-based pricing models in commercial settings. This paper introduces the task of Dataset Size Recovery and presents DSiRe, a method to estimate the number of training samples directly from LoRA weights.

Methodology: The DSiRe Framework

DSiRe (Dataset Size Recovery) leverages the observation that fine-tuning weights contain a "fingerprint" of the training process. The method treats the weight matrices of a fine-tuned model as diagnostic signals.

The DSiRe pipeline: extracting singular values from LoRA weights and using an ensemble of kNN classifiers to predict dataset size.

The process involves three main stages:

  1. Feature Extraction: For each layer in the LoRA-enhanced model, Singular Value Decomposition (SVD) is performed to extract the singular value spectrum and the Frobenius norm.
  2. Layer-wise Classification: A k-Nearest Neighbor (kNN) classifier is trained for each layer using a reference library of weights from models with known dataset sizes.
  3. Ensemble Voting: During inference, each layer provides a prediction, and a final estimate ($n^*$) is reached through a majority vote across all layers. This ensemble approach ensures robustness against noise in individual weight matrices.

The LoRA-WiSE Benchmark

To evaluate DSiRe, the authors introduced LoRA-WiSE (LoRA Weight Size Evaluation), a comprehensive benchmark consisting of over 25,000 weight snapshots from more than 2,000 independent LoRA models. The benchmark spans three data ranges—Low (1–6 images), Medium (1–50 images), and High (1–1,000 images)—and includes weights from Stable Diffusion 1.5 and 2.0 across multiple LoRA ranks.

Spectral Signatures of Overfitting

The core insight behind DSiRe is that dataset size leaves a distinct physical trace in the weight matrices. Models trained on smaller datasets tend to converge more rapidly and overfit more intensely, resulting in higher "energy" within the LoRA matrices.

The relationship between dataset size and weight characteristics. (a) Weight magnitudes decrease as dataset size increases. (b) Singular value spectra show higher values for smaller training sets.

As shown in Figure 3, both the overall magnitude of the weights and the specific distribution of singular values are highly correlated with the number of training samples. Furthermore, the researchers identified that the decoder (up-blocks) of the Stable Diffusion UNet is significantly more sensitive to dataset size than the encoder, suggesting that concept adaptation is primarily localized in these layers.

Results and Performance

DSiRe demonstrates high precision across all evaluated scales:

  • Low Range: Achieves a Mean Absolute Error (MAE) of 0.36 images and nearly 70% exact accuracy.
  • Medium Range: Achieves an MAE of 1.48 images with over 86% accuracy.
  • High Range: Maintains 91.9% accuracy in classifying dataset sizes into broad categories.

The method generalizes well across different model architectures and LoRA ranks, indicating that the spectral signature of dataset size is a fundamental property of the fine-tuning process.

Discussion and Limitations

While effective, DSiRe currently depends on a reference library of weights. Although accuracy remains high even with a small reference set, developing a "data-free" estimation method is a key area for future research. Additionally, simple data augmentations like horizontal flipping can significantly degrade prediction accuracy, suggesting a potential defense mechanism for users seeking to protect their dataset privacy. Future work will also explore whether these spectral signatures persist in massive foundation models like GPT-4 or SDXL.

Summary updated

BibTeX
@misc{salama2024dataset,
  author = {Mohammad Salama and Jonathan Kahana and Eliahu Horwitz and Yedid Hoshen},
  title = {{Dataset Size Recovery from LoRA Weights}},
  year = {2024},
  eprint = {2406.19395},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2406.19395},
}
Figure