Model Inversion & Data Extraction
What is Model Inversion?
Section titled “What is Model Inversion?”Model Inversion is a privacy attack where an adversary uses an AI model’s outputs (or API responses) to infer sensitive information about the data used to train it. If an LLM or image generator memorizes parts of its training corpus, an attacker can extract that exact data.
In the case of large language models, this is frequently called Training Data Extraction.
The Memorization Problem
Section titled “The Memorization Problem”Deep learning models, especially Large Language Models (LLMs) with billions of parameters, have a tendency to memorize exact strings of text from their training sets if those strings appear frequently or occupy a unique context.
If a company fine-tunes a base model on their internal Confluence wikis or Slack logs without properly sanitizing the data, the model may inadvertently memorize proprietary source code, API keys, or personally identifiable information (PII) like employee social security numbers or customer addresses.
Extraction Techniques
Section titled “Extraction Techniques”Attackers do not need root access to the model weights to perform an extraction attack; they only need the ability to query the model.
1. Prefix Prefixing
Section titled “1. Prefix Prefixing”The simplest form of extraction is providing a prefix that naturally precedes the hidden data and asking the model to autocomplete it.
- Prompt: “John Doe’s emergency contact number is…”
- Model Response: “…555-019-2831.” (Extracted from leaked HR documents during fine-tuning).
2. Divergence Attacks
Section titled “2. Divergence Attacks”Researchers have discovered that forcing an LLM to generate text that deviates from its expected path (e.g., by asking it to repeat a single word indefinitely) can cause the model’s normal generation logic to collapse. When it self-corrects, it often defaults to spitting out verbatim snippets of its memorized training data instead of coherent prose.
Mitigation Strategies
Section titled “Mitigation Strategies”- Data Sanitization: The most effective defense is never putting sensitive data into the training set in the first place. Use robust scrubbing tools to remove PII, secrets, and proprietary code before training or fine-tuning.
- Differential Privacy: Training the model using differential privacy (DP-SGD) ensures that the presence or absence of any single data point in the training set does not significantly change the final model weights, drastically limiting memorization.
- Output Filtering: Implementing a secondary filter that compares the LLM’s output against a database of known sensitive patterns (like credit card formats or API key entropy) before showing it to the user.