Lion Cipher Lab

Defend a model against membership inference with DP-SGD

Why it matters

Part 1 left you able to prove a model leaks its training set, and pointed at differential privacy as the defence with an actual guarantee. Pointing is not doing. In this lab you build that defence and pay for it in your own numbers. You train a target that overfits, run the real Shokri-et-al shadow-model attack against it — not a single hand-tuned threshold this time, but many shadow models feeding a trained attack classifier scored by AUC — and watch it succeed. Then you retrain the identical model with DP-SGD using Opacus at a chosen epsilon, rerun the exact same attack, and watch its AUC…

What you'll learn

Steps in this lab

  1. Where Part 1 left you, and what you build here
  2. The four ideas you need: DP, epsilon, delta, and DP-SGD
  3. Set up: install PyTorch and Opacus
  4. Build the shared code and an overfitting target
  5. The real attack: many shadow models plus a trained attack classifier
  6. The defence: retrain with DP-SGD in Opacus at a chosen epsilon
  7. The judgement: when DP-SGD is worth it, and its honest limits
  8. What you just did, and where to push it

Open the full interactive lab →