GO TO A SECTION

↑ ↓ to navigate · Enter to openExplore all sections →
FDEInterviews logo
★ Read firstUSENIX Security 2021

Extracting Training Data from Large Language Models

GPT-2 shows no train-test gap, yet a black-box audit recovered 604 verbatim training texts, some with names and phone numbers. Text repeated 33 times in one page was enough.

Breakdown by FDE Interviews · 14 min read · Updated

About the original · 2020
AUTHORS
Carlini, Tramèr, Wallace, Jagielski et al.
FROM
Google, Stanford, UC Berkeley, Northeastern, OpenAI, Harvard, Apple
PUBLISHED
Dec 2020 · USENIX Security 2021
CITED BY
3,595Semantic Scholar · Nov 2026
IN THIS BREAKDOWN · 10 SECTIONS

You can read 22% of this breakdown.

01

The paper in one minute

Language models trained on web text were widely assumed not to memorize individual documents. They train for about one epoch on deduplicated data, and their training loss and test loss are almost equal, which is the usual sign that a model has not overfit. This paper shows that the average hides the worst case: a small number of training examples are stored verbatim and can be recovered by anyone who can query the model.

The authors studied GPT-2, whose weights and training source were public, and checked their findings with OpenAI against the original training set. They generated 200,000 samples of 256 tokens with each of three sampling setups, then ranked the samples by six scores. The best scores compare GPT-2's confidence on a sample with a reference that should not have memorized it: a smaller GPT-2, the zlib compressor, or GPT-2 itself on the lowercased text. Text that the large model finds much more predictable than the reference does is a likely memory. For each of the 18 combinations they sent 100 candidates for manual checking.

Of the 1,800 candidates, 604 were verbatim training text. Most were common material such as news, license text and log files. Some were not: 46 contained named individuals, 32 contained contact details, 35 contained random high-entropy strings such as UUIDs, and one sample reproduced a person's name, address, email, phone and fax number. Several came from a single training document.

A controlled test on Reddit URLs that appeared in exactly one document measured how much repetition memorization needs. GPT-2 XL (1.5 billion parameters) emitted every URL repeated 33 times or more, the 345-million-parameter model fewer, and the 117-million-parameter model only one, with help. Larger models memorized more. The paper closes with mitigations: differentially private training, careful deduplication and data sourcing, filtering outputs, and auditing models with methods like these.

THE IDEA, VISUALLY
REPEATS IN ONE DOCUMENT VS MODEL SIZE (TABLE 4) repeats XL 1.5B M 345M S 117M 359 emitted emitted w/ hint 113 emitted emitted 76 emitted w/ hint 72 emitted 64 emitted emitted 56 emitted emitted 51 emitted w/ hint 51 emitted w/ hint 35 emitted w/ hint 33 emitted 17 17 8 33x Each URL sits in a single document, so document-level deduplication keeps every repeat. Bigger models need fewer repeats to memorize. arXiv 2012.07805, USENIX Security 2021 WHAT THE 604 MEMORIZED SAMPLES HELD (TABLE 1) US and international news 109 Log files and error reports 79 Licenses and terms of use 54 Lists of named items 54 Forum or wiki entries 53 Valid URLs 50 Named individuals 46 Promotional content 45 High entropy (UUIDs, base64) 35 Contact info 32 Code 31 Configuration files 30 personal information Samples can sit in several categories. 1,800 candidates were checked by hand; 604 were verbatim training text.
Left: Table 4 of the paper. Thirteen Reddit URLs, each in a single training document repeated 8 to 359 times; GPT-2 XL emits every one repeated 33 times or more, Medium 4 unaided plus 4 with a hint, Small one with a hint. Right: Table 1, what the 604 memorized samples contained; red bars are personal information.
Research notes: the problem, approach and results
604 of 1,800

inspected candidates confirmed as verbatim training data, across 18 search configurations (Section 6)

33

fewest repeats, all inside one document, after which GPT-2 XL emitted a URL unaided (Table 4)

57% vs 17%

share memorized when candidates are ranked by the zlib ratio vs by raw perplexity, 300 each (our sum of Table 2)

THE PROBLEM

Large language models are trained once on huge, deduplicated datasets and show almost no gap between training and test loss, so the common assumption was that they do not memorize individual training examples in a way anyone could recover.

THE IDEA

Query GPT-2 as a black box: generate 600,000 samples, rank them by how much more likely GPT-2 finds them than a reference (a smaller model, zlib compression, the lowercased text), and check the top candidates against the training data with the model's creators.

THE RESULT

604 of 1,800 inspected candidates were verbatim training text, including names, phone numbers, email addresses, code and 128-bit UUIDs, some from a single document. The largest model memorized URLs that appeared 33 times in one page; smaller models needed more repeats or none.

02

Why it matters to an FDE

Whatever you train on can come back out. Customers fine-tune models on support tickets, contracts, chat logs and code. This paper is the standard evidence that a model can reproduce a training record verbatim, to anyone who can query it, without any overfitting showing up in the loss curve. If the training set holds personal data or secrets, treat the model weights as holding them too.

Repetition is the variable you control. The striking examples were repeated many times inside one document: a forum dump that listed the same links dozens of times, a page with a UUID 10 to 311 times. Document-level deduplication keeps all of those repeats because they sit in one document. Before a fine-tune, count repeated spans inside documents, not only duplicate documents.

The audit is cheap and runs before release. Plant a few fake records (canaries) in the training data, train, and measure how highly the model ranks each one among all strings of the same format. Our toy run shows the pattern: a fake five-digit pin went from a random rank to the model's first guess after appearing four times. That is an audit you can show a security reviewer.

Clean the data first; it is the control that works. The paper is direct that sanitizing data is imperfect and that differential privacy is hard to apply to scraped text. For an FDE, the practical stack is: remove or tokenize personal fields before training, deduplicate within and across documents, keep secrets out of corpora entirely, and add an output filter for known sensitive patterns as a second line.

Larger models raise the risk. The 1.5-billion-parameter model needed 33 repeats where the smaller ones failed entirely. Moving a customer to a bigger base model for quality also moves them toward more memorization of the same data.

THE FULL BREAKDOWN

Understand the mechanism. Try it on a real problem.

Unlock this breakdown and 290 more papers.

Premium opens every paper in full, plus every answer, concept, course and guide on the site. One payment for six months of access.

6 months · One payment · No auto-renewal

Get Premium · ₹2,000 / $25
  • ◇1 architecture diagram
  • </>1 runnable code experiment
  • ▦2 results tables
  • ?5 interview questions with answers
  1. 03Key takeaways

    Definitions, the search-and-rank method, what was found, the repetition test and the mitigations

    Free account
  2. 04How it works

    The generate-rank-verify pipeline, the six scores, deduplication and the URL repetition test

    Premium
  3. 05The numbers that matter

    Table 2 per configuration and per score, Table 4's repetition grid, and the categories that leaked

    Premium
  4. 06Try it yourself

    Recompute Table 2 and Table 4, then run a canary audit and watch per-document repeat caps undo it

    Premium
  5. 07Where it breaks

    One public model, manual checks, a loose lower bound, and defenses that were not tested

    Premium
  6. 08Using it on a deployment

    Data hygiene before fine-tuning, a canary audit before release, output checks, access limits

    Premium
  7. 09Interview angles

    Five questions this paper prepares you for, with answer hints

    Premium
Back to the paper library →