Skip to content

Differential Privacy for LLM

Definition

Differential Privacy (DP) — a formal guarantee where the result of an algorithm is statistically almost independent of the presence of a single example in the training dataset. In the context of LLM, it is applied during Fine-Tuning and Pre-training to reduce the risk of extracting personal data.

Formalization

An algorithm M provides (ε, δ)-differential privacy if for any neighboring datasets D and D′ and any set S:

P[M(D) ∈ S] ≤ e^ε · P[M(D′) ∈ S] + δ

A smaller ε corresponds to a stronger guarantee.

DP-SGD

The primary method is a modification of stochastic gradient descent:

  1. Calculate the gradient for each example in the microbatch.
  2. Clip the gradient by norm C.
  3. Add Gaussian noise with σ, which depends on C and ε.
Parameter Role
ε privacy budget
δ probability of failure
C gradient clipping threshold
σ noise scale

Trade-offs

Enhancing privacy reduces model quality — an effect similar to the Alignment Tax. It is used in conjunction with PII filtering and Data Cleaning.

See Also