Differential Privacy for LLMs
DP-SGD is still the standard. It injects noise into gradient updates and gets a formal (epsilon, delta) guarantee in return, at a real cost in compute, memory, and utility. Parameter-efficient DP fine-tuning (LoRA + DP-SGD) is the common 2025 configuration (ACM 2025). The evidence on leakage pulls in two directions: canary-based membership inference (Duan et al., 2024) reports limited success against language models, while training-data extraction (Carlini et al., 2021; Nasr et al., 2025) recovers a lot of verbatim memorization. A March 2025 paper (arXiv:2503.06808) argues the gap comes from what each one measures, inserted canaries versus the most extractable data. Its new canary designs allow loss-based MIA without shadow models and give the first nontrivial DP audit of an LLM trained on real data with realistic DP guarantees. Two alternatives to DP training are PMixED (arXiv:2403.15638), which does private prediction at inference time with a mixture of experts over next-token distributions, and DP synthetic data generation (Google Research 2024). One emerging attack to know about is Differential Privacy Reversal via LLM Feedback, which exploits confidence-score leakage.
Learning Objectives
- Define (epsilon, delta)-differential privacy and state the DP-SGD recipe.
- Explain the 2024-2025 tension: canary MIA vs training-data extraction give different pictures.
- Describe PMixED and why inference-time private prediction is an alternative to DP training.
- Describe the Differential Privacy Reversal via LLM Feedback attack.
The Problem
LLMs memorize. Carlini et al. (2021) showed that production language models will reproduce verbatim training text when prompted for it. Differential privacy is the formal defense: train so the output is provably insensitive to any single training example. The 2024-2025 evidence says DP-SGD is necessary, but the ε values people deploy may not match the threat model they care about.
The Concept
(ε, δ)-differential privacy
A randomized algorithm M is (ε, δ)-DP if for any two datasets differing in one example and any event S: P(M(D) in S) <= e^ε * P(M(D') in S) + δ.
Interpretation: the output distribution is close enough (parametrized by ε) that the contribution of any single individual cannot be reliably inferred, except with probability δ.
DP-SGD
Abadi et al. 2016. The standard recipe:
- Sample a mini-batch.
- Compute per-example gradients.
- Clip each per-example gradient to a threshold C.
- Sum the clipped gradients and add Gaussian noise with std σ * C.
- Use the noisy sum to update parameters.
Privacy cost is tracked by an accountant (Moments Accountant, Rényi DP accountant). Reported ε values in the LLM literature vary widely by threat model, data sensitivity, and utility target; there is no universally "safe" default ε. Published examples span roughly ε ≈ 1–10 in some LLM training settings, but treat those as illustrations, not recommended defaults. Lower ε generally needs more noise, and more noise tends to cost utility.
LoRA + DP-SGD
Full DP-SGD on a frontier model is prohibitive. LoRA (Hu et al. 2022) confines the updates to a small adapter, which shrinks per-example gradient storage. LoRA + DP-SGD is the common 2025 configuration. The DP guarantee covers the adapter, and the base model stays fixed.
The 2024-2025 tension
Two lines of evidence:
- Canary MIA (Duan et al. 2024). Insert unique canaries into training data, measure whether a membership-inference attacker can identify them. It reports limited success on language models, which suggests MIA is hard.
- Training-data extraction (Carlini 2021, Nasr et al. 2025). Prompt the model with a prefix; measure whether it recovers verbatim text from training. It reports substantial memorization, which suggests that in the sense that matters, MIA is easy.
The March 2025 paper (arXiv:2503.06808) resolves it by pointing out that the two measure different things. MIA asks "is example e in D?" on inserted canaries. Extraction asks "what can I recover of D?" For privacy, the "most extractable" example is the one that counts, and canaries under-report it because nobody optimized them to be extractable.
The paper also introduces new canary designs. They support loss-based MIA without shadow models, and they yield the first nontrivial DP audit of an LLM trained on real data with realistic DP guarantees.
Alternatives to DP training
- PMixED (arXiv:2403.15638). Private prediction at inference time. Mixture of experts on next-token distributions; each expert sees a shard of training data; aggregation adds noise for DP. Avoids DP training entirely.
- DP synthetic data generation (Google Research 2024). LoRA-fine-tune with DP-SGD, sample synthetic data, train a downstream classifier on the synthetic data.
Both sidestep the utility cost of full DP training, and the price is a different threat model.
Differential Privacy Reversal via LLM Feedback
This is an emerging 2025 attack. It uses a DP-trained model's confidence scores as an oracle to re-identify individuals. Outputs can look clean while the confidence distributions still leak.
The defense is to withhold confidences, or to truncate or quantize them before exposure. That is a separate requirement on top of (ε, δ)-DP training.
Where this fits in Phase 18
Lessons 20-21 cover bias and fairness, this lesson covers privacy, Lesson 23 covers provenance via watermarking, and Lesson 27 covers the regulatory data-provenance layer.
Use It
main.py runs a DP-SGD toy on a 2-feature binary logistic regression with 500 training and 200 test points. It sweeps the noise multiplier σ over 0.0, 0.5, 1.0, 2.0, and 4.0 with the clipping norm C fixed at 1.0, and prints an approximate ε and the test accuracy for each. The ε is an analytical Gaussian-mechanism proxy, not output from a real accountant, so read it as a rough trend. There is no canary attack in the file. Exercise 2 asks you to add one.
Ship It
This lesson produces outputs/skill-dp-audit.md. Hand it a DP claim about a language model deployment and it audits four things: the (ε, δ) values, the accountant used, the MIA evaluation protocol, and whether anyone has assessed confidence-score exposure.
I'd run main.py first and read the ε column with suspicion. It is a proxy that composes a Gaussian-mechanism bound over every step, and with 10 epochs on 500 points that means 5000 steps. On my run the proxy stays far above the 1-10 range the closing printout mentions, even at σ = 4.0. So the table shows the direction of the tradeoff and nothing about whether a setting is private enough.
Two other things about the toy are worth knowing. It updates on one example at a time and adds noise at every update, where real DP-SGD sums clipped gradients over a mini-batch and noises the sum once. And accuracy is not monotone in σ on a single seeded run: at the seed in the file, σ = 4.0 scores higher than σ = 2.0. With 200 test points and one seed I wouldn't read anything into that, and it is a good reason to average over seeds before drawing a utility curve.
My bet is that the part to carry out of this lesson is the extraction result, not the accountant. A low ε on a canary test doesn't tell you the most extractable training example is safe. When I audit a DP claim, I'd ask what was measured before I ask what the ε was.
Exercises
-
Run
code/main.py. Sweep σ in {0.5, 1.0, 2.0} and report the (ε, δ)-accuracy trade-off. Identify the point at which utility collapses. -
Implement a canary insertion and a log-loss test. Measure detection rate before and after DP-SGD at σ = 1.0.
-
Read Nasr et al. 2025 on training-data extraction. Why does extraction success not collapse under moderate ε? What does this imply about MIA-as-evaluation?
-
Design a deployment using PMixED (arXiv:2403.15638) that operates entirely at inference time. What is the threat model that PMixED addresses that DP-SGD does not?
-
Sketch the DP Reversal via LLM Feedback attack. Design a countermeasure that limits confidence-score leakage and estimate its deployment cost.
Key Terms
| Term | What people say | What it actually means |
|---|---|---|
| DP | "(ε, δ)-differential privacy" | Formal privacy: output distribution close under neighbouring-dataset change |
| DP-SGD | "noise-injected SGD" | Gradient clipping + Gaussian noise addition; standard DP training |
| LoRA + DP-SGD | "efficient private fine-tune" | DP-SGD on low-rank adapters; standard 2025 configuration |
| MIA | "membership inference" | Attack that determines whether an example was in training data |
| Canary | "inserted watermark example" | Unique training example used to measure DP leakage |
| PMixED | "private inference mixture" | Inference-time DP via mixture-of-experts on next-token distributions |
| DP Reversal | "confidence leakage attack" | Attack that uses a model's confidence as an oracle for re-identification |
Further Reading
- Abadi et al.: DP-SGD (arXiv:1607.00133): the standard DP training algorithm
- Carlini et al.: Extracting Training Data (arXiv:2012.07805): the canonical extraction paper
- Duan et al.: Canary MIA on LLMs (arXiv:2402.07841, 2024): limited-success MIA
- Kowalczyk et al.: Auditing DP for LLMs (arXiv:2503.06808, March 2025): resolution of the tension
- PMixED (arXiv:2403.15638): inference-time private prediction
Code
- main.py (python, 104 lines)