The student who recites instead of understanding
Two students prepare for a history exam. The first has understood the causes of the French Revolution: she can explain them in her own words and answer a question she has never seen. The second has learned three pages of the textbook by heart: ask him, and he recites them, commas included. Both have "learned", but not the same thing.
A language model does a bit of both. Most of what it retains takes the form of general patterns: grammar, common facts, ways of reasoning. But a small share of its training data is stored almost as is in its parameters (the billions of numbers adjusted during training), and can come back out word for word if you give it the right cue. This is called memorization. When someone deliberately gets those passages to come out, it is called extraction.
The phenomenon matters for privacy (a phone number read once on a web page can resurface), for copyright (song lyrics, pages of novels) and for how much we can trust performance scores (a model that saw a test's answers during training "cheats" without meaning to).
The problem: learning and memorizing cannot be cleanly separated
You might think a good model generalizes and a model that memorizes is simply badly trained. Reality is messier.
As early as 2019, the researcher Vitaly Feldman showed that to learn well from real data, a model sometimes needs to memorize. Real-world data has a "long tail": many rare cases seen only once or twice (an obscure proper name, a dialect phrase, an exotic line of code). For those, there is no general rule to extract; remembering the example itself is the only way to get it right next time.
Does Learning Require Memorization? A Short Tale about a Long TailSo the question is not "does the model memorize?" (the answer is yes, always a little) but: how much, what, and can it be brought back out?
Three definitions to get things straight
Researchers had to pin down what they were measuring. Three notions keep coming up.
Verbatim memorization: the model outputs a sequence of words that appears exactly, character for character, in its training data. It is the easiest definition to check: you search for the output in the corpus.
Extractability, or "k-extractable": the operational definition proposed by Nicholas Carlini and colleagues at Google in 2022. Take a passage from the training corpus. Give the model the tokens (word pieces) that precede it in the original document, say . Let it continue by always picking the most likely next word. If it reproduces the passage exactly (for example the next 50 tokens), the passage is extractable with a context of length . The smaller , the stronger the memorization: a short cue is enough for the rest to follow.
Approximate memorization: the model reproduces a near-identical passage, with one word changed, different punctuation or different capitalization. This matters because a filter that only blocks exact copies is easy to get around. Daphne Ippolito, Carlini and coauthors demonstrated it in 2022: a "perfect" filter against verbatim copying is defeated by barely modified instructions, for instance asking the model to write in capital letters.
Preventing Verbatim Memorization in Language Models Gives a False Sense of PrivacyA passage can be encoded in the parameters without any ordinary question ever bringing it out. Researchers therefore separate memorization (what is stored) from extractability (what a given method can pull out). An extraction result is always a lower bound: a better method might pull out more.
Why it happens: three measured factors
The paper "Quantifying Memorization" (Carlini et al., 2022) measured memorization in model families trained on The Pile, a public corpus whose exact contents are known. It found three regular relationships.
Quantifying Memorization Across Neural Language Models- Duplication. The more often a text appears in the corpus, the more it is memorized, and much faster than proportionally. Another 2022 study (Kandpal et al.) put a number on it: a sequence present 10 times in the data is on average regenerated about 1,000 times more often than a sequence present once.
- Model size. With the same data, a bigger model memorizes more. In the paper, the largest model tested (6 billion parameters) reproduces at least 1% of its training corpus when prompted with the start of each passage.
- Prompt length. The more context the model is given (the larger ), the more likely it is to "recognize" the passage and unroll the rest.
This points straight at the most exposed texts: those the web repeats thousands of times. Software licenses, terms of service, statutes, religious verses, popular song lyrics, the opening pages of bestsellers, and anything copied across countless sites. A very famous novel is quoted, summarized and pasted everywhere; an obscure one is not.
Deduplicating Training Data Mitigates Privacy Risks in Language ModelsThe key studies, from GPT-2 to ChatGPT
2021: extracting data from GPT-2
The first landmark paper came from Carlini and researchers at Google, OpenAI, Apple and several US universities. The idea has two steps. First, have the model generate hundreds of thousands of texts freely. Then flag the ones the model is suspiciously confident about, for instance by comparing its confidence with that of a smaller model: a text the big model finds very likely but the small one finds odd has a good chance of having been learned by heart.
Extracting Training Data from Large Language ModelsOut of about 1,800 candidates, roughly 600 turned out to be exact copies of GPT-2's training data. Among them: names together with email addresses and phone numbers, chat logs, code, random 128-bit identifiers. Some appeared in just one document of the corpus. The authors already noted that larger models were more vulnerable than smaller ones.
2023: repeat a word until ChatGPT derails
Chat assistants were thought to be better protected: their final training stage (alignment, which teaches them to answer politely and helpfully) moves them away from simply continuing text. In November 2023, Milad Nasr, Carlini and coauthors showed otherwise with a disarmingly simple attack: ask ChatGPT to repeat the word "poem" forever.
After a while the model "diverges": it stops repeating and starts producing a different kind of text, part of which is copied word for word from its training data. With about $200 worth of queries, the team extracted over 10,000 distinct memorized passages, including personal contact details. In this mode the model emitted training data 150 times more often than when behaving normally. The paper concludes that the alignment techniques of the time did not remove memorization, they hid it. OpenAI then took steps to block this kind of request.
Scalable Extraction of Training Data from (Production) Language Models2023: image generators too
This is not specific to text. Diffusion models (Stable Diffusion, Imagen), which build images from a description, can also reproduce training images. In January 2023, Carlini and coauthors generated large numbers of images from the most frequently repeated captions in the corpus, then kept those that came back nearly identical across samples. Result: over a thousand training images extracted in total, from photos of real people to company logos. Again, it is mostly images heavily duplicated in the data that resurface.
Extracting Training Data from Diffusion Models2025-2026: whole books
Recent work has changed scale: no longer isolated sentences, but books. In May 2025, a team led by A. Feder Cooper and Mark Lemley (Stanford) measured how much of 200 books was memorized by 14 open-weight models (models whose parameters can be downloaded). Their conclusion is nuanced: most models do not memorize most books, but there are spectacular exceptions. Meta's Llama 3.1 70B has memorized almost all of Harry Potter and the Sorcerer's Stone: given just its first few words, you can extract the whole book nearly verbatim.
Extracting memorized pieces of (copyrighted) books from open-weight language modelsIn January 2026, part of the same group (Ahmed, Cooper, Koyejo, Liang, Stanford) tested commercial assistants protected by safeguards. On the same book, Gemini 2.5 Pro and Grok 3 reproduced roughly 70 to 77% without any workaround; Claude 3.7 Sonnet required bypassing its protections (a "jailbreak" by repeated attempts), after which it reproduced some books almost in full; GPT-4.1 held out much longer and eventually refused to continue. Safeguards matter, then, but none eliminated the risk.
Extracting books from production language modelsGuessing whether a text was in the training data
A related question is membership inference: given a text, can you tell whether it was part of the training data? The appeal is obvious for an author who wants to know if their novel was used, or for a researcher checking that a benchmark has not leaked into the corpus.
The basic idea: a model is usually a little more "at ease" (less surprised) with a text it has already seen. Methods such as Min-K% Prob (2023) look at the words of the text the model finds least likely: if even those do not surprise it much, the text was probably seen.
Detecting Pretraining Data from Large Language ModelsThese methods have severe limits, demonstrated in 2024 by Michael Duan and colleagues (University of Washington, among others). On models from 160 million to 12 billion parameters whose corpus is known exactly, membership attacks do barely better than chance in most settings. Two reasons:
- The corpus is huge and each text is seen only once or twice: the trace a single document leaves is tiny.
- The line between "seen" and "unseen" is blurry: an unseen text can closely resemble seen ones (a wire story reposted on a hundred sites, a documentation page similar to another).
The authors also show that earlier headline successes often came from a bias: "seen" texts were older than the "unseen" ones they were compared with, so the attack was really detecting when a text was written, not whether it was in the corpus. Another team showed the same year that "blind" methods, which do not even query the model, beat the published attacks on those test sets.
Do Membership Inference Attacks Work on Large Language Models? Blind Baselines Beat Membership Inference Attacks for Foundation ModelsGuessing for a single document is very hard. Reasoning over a whole collection (all of a newspaper's articles, all of an author's books) works better, because weak signals add up: that is the idea behind "dataset inference" (Maini et al., 2024). And when a passage can be extracted word for word, the question is settled differently: you are no longer guessing, you are observing.
Why it became central in lawsuits
Memorization moved from labs to courtrooms because it bears on a concrete question: does a model "contain" the works it has read? Two examples, without the legal detail (covered in What the courts have said about training):
- GEMA v. OpenAI (Munich, 11 November 2025). Germany's music rights society complained that ChatGPT reproduced the lyrics of nine well-known German songs. The Munich Regional Court sided with GEMA at first instance: it found that the lyrics were memorized in the model itself and that reproducing them in answers was also a copy. OpenAI said it disagreed, and as far as we know the ruling was not final as of November 2026.
- The New York Times v. OpenAI and Microsoft (New York, since December 2023). The newspaper's complaint relied in part on examples where the models reproduced long passages of articles. In autumn 2026, the case was still at the summary judgment stage, with no ruling on the merits.
In these cases, the research described above is cited by both sides: by one to show that works really are stored, by the other to point out that the vast majority of texts are not.
Countermeasures
None is perfect; they are combined.
1. Deduplicate the data
Since duplication is the first factor, the first defense is removing duplicates before training (see Data deduplication). In 2021, a Google team removed from the C4 corpus, among other things, a single 61-word English sentence repeated more than 60,000 times. Models trained on the deduplicated data emitted memorized text ten times less often, while learning as well or better.
Deduplicating Training Data Makes Language Models BetterThe limit: you cannot deduplicate what does not look like a duplicate. A novel present once in the corpus, but quoted in excerpts across thousands of pages, remains highly exposed.
2. Filter the outputs
A second safety net checks what the model is about to answer. GitHub Copilot, for example, offers a setting that blocks suggestions matching existing public code. Chat assistants often decline to recite song lyrics or long excerpts of books. The limits: these filters only see exact or near-exact copies (and we saw they can be fooled), and they protect nothing once an open model's parameters are downloaded and run without a filter.
3. Differential privacy
Differential privacy is a mathematical guarantee: training is modified (by capping each example's influence and adding calibrated random noise) so that the final model is almost the same whether or not any given document was in the data. If the model barely depends on that document, it cannot spit it back out.
In 2025 Google released VaultGemma, a 1-billion-parameter model trained entirely with this guarantee. The price remains steep: according to Google, its performance is comparable to non-private models from about five years earlier. Today the technique is mostly used on sensitive data and modest models.
VaultGemma: A Differentially Private Gemma Model4. Change the training objective: the "goldfish loss"
A language model learns by trying to predict each next word; the error it makes (the loss) is used to correct its parameters. The goldfish loss (2024, University of Maryland and the ELLIS Institute) makes a tiny change: for a fraction of the words, say one in four, the error is not counted. The model reads those words but is never corrected to predict them.
As a result, it can no longer reproduce a long chain intact, because some links are ones it never learned to predict. The trick is to choose the skipped words based on the few words before them (rather than at random on every pass): a passage seen a hundred times always loses the same links, so duplication is no longer enough to engrave it. The authors report a large drop in extractable memorization, with little to no effect on benchmark scores.
Be like a Goldfish, Don't Memorize! Mitigating Memorization in Generative LLMsAnd after the fact?
If a model has already memorized a text, one can try to make it "forget" without retraining from scratch: that is the topic of machine unlearning, a young field whose guarantees are still debated.
Summary table
| Countermeasure | When it acts | What it reduces well | Main limit |
|---|---|---|---|
| Deduplication | Before training | Memorization of repeated texts | Misses partial or scattered duplicates |
| Output filter | At answer time | Exact reproduction of long passages | Can be bypassed; absent from downloaded open models |
| Differential privacy | During training | Any dependence on a single document, with a mathematical guarantee | High cost in quality and compute |
| Goldfish loss | During training | Word-for-word reproduction of long chains | Recent, little experience at large scale |
| Unlearning | After training | A specific, identified piece of content | Guarantees still uncertain |
Why it matters
Memorization is where training data stops being abstract. As long as a model generalizes, it is hard to say what it "owes" to any given text. When it recites a chapter, an address or a song's lyrics, the link is plain for everyone to see. That weighs on privacy (personal data can resurface), on the ongoing copyright lawsuits, and on the reliability of evaluations (a model that memorized a test's answers looks stronger than it is, see The limits of benchmarks).
It is also a very concrete engineering question: deduplicating, filtering and choosing the training objective are decisions every team that trains models makes. They connect to the collection choices described in Opt-outs and access protocols and to provenance in Dataset provenance and licenses.
Key takeaways
- A model mostly learns patterns, but it also stores a small part of its data almost as is; extraction is when someone gets it back out.
- A passage is "k-extractable" if, cued with the tokens that precede it, the model completes it exactly; approximate memorization (near-copies) counts too.
- Three factors increase memorization: how often a text is duplicated in the data, model size, and prompt length.
- Attacks have grown from a few hundred sentences (GPT-2, 2021) to thousands of passages (ChatGPT, 2023) and then whole books (Llama 3.1 in 2025, commercial assistants in 2026).
- Telling whether a single text was used in training is much harder than once believed (Duan et al., 2024); reasoning over a collection of documents works better.
- Countermeasures are combined: deduplication, output filters, differential privacy, goldfish loss; none is enough on its own.
1. Under the definition of Carlini et al. (2022), what does it mean for a passage to be extractable with a context of length k?
2. Which factor does the page present as the main driver of memorization, and therefore the first thing to fix?
3. What did Duan et al. (2024) show about membership inference on large language models?
4. How does the goldfish loss reduce word-for-word reproduction?