Model Extraction, Membership Inference and Privacy
You'll be able to:
You can explain how a model leaks its training data (memorisation, membership inference) and its behaviour (extraction via the prediction API), reason about which signals make an API more extractable, and state what differential privacy guarantees — and what it costs in accuracy.
Models leak in two directions
A deployed model leaks inward facts — what it was trained on — and outward behaviour — what it does, which a competitor can copy. Both leaks happen through the ordinary prediction API, with no exploit and no breach. The engineer's job is to understand the mechanism well enough to price each leak and decide which to pay for.
Memorisation and training-data extraction
Neural networks memorise. The larger the model, the more it memorises, and unusual or repeated sequences are memorised most readily. Carlini and colleagues showed in 2020 that a public language model could be prompted into emitting verbatim training sequences — names, contact details, licence keys, code — and that the risk rises with model size. The attacker needs only to generate a lot of text and then rank the outputs for "this looks memorised" using a signal such as the model's own confidence compared with a smaller reference model.
The defensive implications are concrete. Deduplicate training data: a sequence seen many times is memorised far more than one seen once. Scrub secrets and personal data before training, not after. And assume anything in the training set may surface in an output; if that is unacceptable for some category of data, that data does not belong in the training set at all.
Membership inference
A subtler leak: not what the data was, but whether a specific record was in the training set. Shokri and colleagues (2017) showed this can be inferred from a model's output alone. The mechanism is overfitting in miniature — models are typically more confident on examples they trained on than on similar examples they did not. An attacker trains "shadow models" that mimic the target, learns what confidence patterns look like for members versus non-members, and applies that to the target's outputs.
Why it matters: membership can itself be sensitive. If a model was trained on patients at a specific clinic, inferring that a person's record was in the set discloses that they were a patient. Membership inference is also the standard test used to measure a model's privacy in practice.
What makes an API more vulnerable: returning full probability vectors rather than top labels, high-precision scores, and overfitting. What helps: regularisation, returning less (labels only, or rounded confidences), and differential privacy during training.
Model extraction
The outward leak. Tramèr and colleagues (2016) showed that for many model families a querier can reconstruct a functionally equivalent model from API responses — sometimes exactly, for simple models, sometimes a close approximation trained on query-answer pairs. For large models, the modern form is distillation: query the target with many inputs, train a cheaper model on the outputs. The clone may not match the original, but it captures much of the behaviour for a fraction of the cost.
Controls here are economic rather than absolute: rate limits and per-account quotas, returning labels instead of scores, watermarking outputs so a distilled clone can be shown to derive from yours, and monitoring query distributions for the tell-tale pattern of systematic coverage rather than organic use. Accept that a determined adversary with a large budget can approximate any model exposed through an API; the goal is to make it expensive and detectable.
Differential privacy in one paragraph
Differential privacy (DP) is a mathematical promise about a process, not a property of data: the output distribution of the training algorithm changes by at most a bounded factor (controlled by a parameter called epsilon) when any single record is added or removed. A membership-inference attacker therefore cannot do much better than guessing, because the trained model is nearly the same with or without the record. Dwork and Roth's textbook is the canonical reference for the definition and its composition rules.
For deep learning, the standard recipe is DP-SGD: clip each example's gradient so no one record can dominate an update, then add calibrated Gaussian noise before applying it. The cost is real: accuracy drops, training is slower, and small epsilon values (strong guarantees) can be expensive on hard tasks. The choice of epsilon is a policy decision dressed as a parameter; values quoted in practice range from below 1 to above 10, and there is no consensus on what is "enough".
Worked example: scoring an API
A credit-risk model returns a probability to four decimal places, unauthenticated, with no rate limit.
- Extraction: unlimited queries plus precise scores make distillation straightforward. Mitigation: authenticate, cap daily queries per client, return a risk band (low/medium/high) instead of a score.
- Membership inference: the model is overfitted to a small training set, and precise scores expose the confidence gap. Mitigation: regularise, round, and measure with a membership-inference test before release.
- Training data: applicant records include free-text notes. Mitigation: exclude the notes from training; the model's purpose does not need them.
Each mitigation has a cost — a band is less informative to a downstream user than a score — and the risk note should say so.
What is still unsettled
How much memorisation is inherent to capable language models, whether DP can be made cheap enough for frontier-scale training, and what a legally defensible epsilon is — all open. Machine unlearning (removing a record's influence after training) is an active research area with no dependable, verifiable method yet.
What to remember
- Models memorise; deduplicate and scrub before training, and keep out any data that must never appear in an output.
- Membership inference exploits the confidence gap between seen and unseen examples; return less and overfit less.
- Extraction cannot be prevented, only made expensive and visible: authentication, quotas, coarse outputs, monitoring.
- Differential privacy bounds a process, costs accuracy, and its epsilon is a policy choice.
Check Yourself
Module Mission
30–40 minDecision 4 of the case file. Write a one-page risk note on the delay score API. Cover how a customer in the training data could be detected from the score, how a competitor could copy the model through the API, and three changes to the API design (rounding, rate limits, label-only responses) with the business cost of each. Finish with one paragraph on whether differential privacy during training would help, and what Halden would lose.
Open Case file: Halden Assist →Good looks like
- Membership inference is explained with what the attacker sends and what they compare.
- Model extraction is explained with roughly how many queries it takes and why four decimal places help the attacker.
- Each of the three API changes names what it protects against and what a paying customer loses.
- The differential privacy paragraph says what the guarantee covers and that accuracy falls, most for rare cases.
- The note recommends something specific for the customers who compete with each other.
Loading your work…
Curated Materials
2.3hThe deep work happens here — the lesson is your briefing.
Live on aiqbench
This lesson's subject on the rest of the site, today.
In the news, last 30 days
- Hackers Hide Password-Stealing Malware in GitHub Code, Putting Software Downloads at RiskCybersecurity News ·
- Silver Fox Hackers Use Fake Software Downloads to Spread Gh0stRAT Malware That Can Spy on PCsCybersecurity News ·
- MINE: A Training-Free Defense against Indirect Prompt Injection via Mutual Information and Embedding VariancearXiv ·