DAGER: Exact Gradient Inversion for Large Language Models

Ivo Petrov, Dimitar I. Dimitrov, Maximilian Baader, Mark Niklas Müller, Martin Vechev
5/24/2024
cs.LGcs.DC

No official code found. Best implementation: insait-institute/dager-gradient-inversion (20 stars, Apache-2.0, last commit 2025-08-13).

Abstract

Federated learning works by aggregating locally computed gradients from multiple clients, thus enabling collaborative training without sharing private client data. However, prior work has shown that the data can actually be recovered by the server using so-called gradient inversion attacks. While these attacks perform well when applied on images, they are limited in the text domain and only permit approximate reconstruction of small batches and short input sequences. In this work, we propose DAGER, the first algorithm to recover whole batches of input text exactly. DAGER leverages the low-rank structure of self-attention layer gradients and the discrete nature of token embeddings to efficiently check if a given token sequence is part of the client data. We use this check to exactly recover full batches in the honest-but-curious setting without any prior on the data for both encoder- and decoder-based architectures using exhaustive heuristic search and a greedy approach, respectively. We provide an efficient GPU implementation of DAGER and show experimentally that it recovers full batches of size up to 128 on large language models (LLMs), beating prior attacks in speed (20x at same batch size), scalability (10x larger batches), and reconstruction quality (ROUGE-1/2 > 0.99).

View on arXivView PDF

Code Implementations(1)

Apache-2.0

Code for the NeurIPS 2024 submission: "DAGER: Extracting Text from Gradients with Language Model Priors"

206Shell, PythonOct 18, 20241 years agoApache-2.0

Similar Papers

Cite this paper

@article{petrov2024dager,
  title  = {DAGER: Exact Gradient Inversion for Large Language Models},
  author = {Ivo Petrov and Dimitar I. Dimitrov and Maximilian Baader and Mark Niklas Müller and Martin Vechev},
  year   = {2024},
  eprint = {2405.15586},
  archivePrefix = {arXiv},
  doi    = {10.48550/arXiv.2405.15586},
  url    = {http://arxiv.org/abs/2405.15586v2},
  journal = {NEURIPS 2024 2024}
}

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/2405.15586.svg)](https://codeofpaper.com/paper/2405.15586)

Discussion