AI Ethics and Governance Intermediate 14 minutes

Privacy-Enhancing Technologies

Differential privacy, federated learning, synthetic data, and the limits of each.

Your progress in the track0%

Differential privacy

An algorithm \(M\) satisfies \((\varepsilon, \delta)\)-differential privacy if, for every pair of neighbouring datasets \(D\) and \(D’\) and every set of outputs \(S\):

$$P[M(D) \in S] \le e^{\varepsilon}\, P[M(D’) \in S] + \delta$$

The Laplace mechanism for a simple count

import numpy as np
def dp_count(values, predicate, epsilon, rng=np.random.default_rng()):
    true = sum(1 for v in values if predicate(v))
    return true + rng.laplace(scale=1.0 / epsilon)    # the sensitivity of a count = 1

DP-SGD with Opacus

# pip install opacus
from opacus import PrivacyEngine
engine = PrivacyEngine()
model, optimizer, train_loader = engine.make_private(
    module=model, optimizer=optimizer, data_loader=train_loader,
    noise_multiplier=1.1, max_grad_norm=1.0)
# ... the usual training loop ...
print(engine.get_epsilon(delta=1e-5))

Comparison

TechniqueProtects againstDoes not protect against
Differential privacyInferring an individual's presence in the dataGroup patterns, and its cost to accuracy
Federated learningTransferring raw dataInformation leaking through the updates
Secure aggregationSeeing each participant's update individuallyWhat the final model reveals
Synthetic dataSharing the original records directlyMemorization and reproduction without guarantees
Homomorphic encryption and secure computationExposing data during computationHigh computational cost

The value of ε alone is not enough to judge; also state δ, the privacy unit (record or person), and the accounting method.

Lesson terms

Differentially private training
A version of stochastic gradient descent that clips each example's gradient and adds Gaussian noise to achieve differential privacy.
Differential privacy
A mathematical guarantee that the distribution of an algorithm's outputs changes only by a limited amount (controlled by the parameter ε) when one person's record is added or removed.
Privacy budget
The value of ε that sets the maximum information leakage, which accumulates with every query or training epoch.

Abstract

Differential privacy gives a mathematical guarantee that an algorithm's outputs do not change much when one person is added or removed, and it is controlled by the budget ε. It can be applied to training with DP-SGD, which clips the gradients and adds noise, at a cost in accuracy. Federated learning keeps the data where it is and exchanges model updates, but it does not guarantee privacy on its own. Synthetic data is useful for development, but it may memorize real records if it is not generated with guarantees.

Review questions

  1. What does a smaller ε mean in differential privacy?

    Stronger protection and more noise, and usually lower accuracy.

  2. Why is federated learning alone not enough to guarantee privacy?

    Because model updates may leak information about the local data, so it is combined with differential privacy and secure aggregation.

Sources and references

  1. Dwork & Roth — The Algorithmic Foundations of Differential Privacy
  2. Abadi et al. (2016) — Deep Learning with Differential Privacy
  3. McMahan et al. (2017) — Communication-Efficient Learning of Deep Networks from Decentralized Data
  4. Opacus

Complete the lesson