Safety, Security & Responsible AI·Question 19 of 70Intermediate

What is training data memorisation and extraction, and why does it matter for a deployed product?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

LLMs don't just learn patterns; they memorise some training examples verbatim, especially data that's duplicated, high-entropy (like a phone number or key), or seen many times. Extraction attacks pull that memorised data back out. Nasr et al. (2023) showed a "divergence" prompt (asking a production chat model to repeat a word forever) caused it to spit out chunks of verbatim training data including PII; academic work has recovered training strings from open models routinely.

Full worked answer

LLMs don't just learn patterns; they memorise some training examples verbatim, especially data that's duplicated, high-entropy (like a phone number or key), or seen many times. Extraction attacks pull that memorised data back out. Nasr et al. (2023) showed a "divergence" prompt (asking a production chat model to repeat a word forever) caused it to spit out chunks of verbatim training data including PII; academic work has recovered training strings from open models routinely.

Why it matters in production:

  • Privacy/PII - if you fine-tune on customer data, the model can leak one customer's data to another user who prompts the right way. This is a real breach, not a theoretical one.
  • Copyright/IP - verbatim regurgitation of copyrighted text is both a legal and a reputational exposure.
  • Secrets - code models trained on scraped repos have emitted live API keys.
  • Membership inference - an attacker can sometimes determine whether a specific record was in the training set, itself a privacy violation for sensitive datasets (e.g., a medical corpus).

Mitigations, roughly in order of leverage: deduplicate training data (duplication is the single biggest driver of memorisation); scrub PII and secrets before training/fine-tuning; don't fine-tune on raw sensitive data - prefer RAG, where you can delete a document and it's actually gone, or redact before training; use differential privacy (DP-SGD) if you must train on sensitive data, accepting a utility/compute cost; and add output filters for known-sensitive patterns. The strategic takeaway for an engineer choosing an architecture: memorisation is a decisive reason to keep sensitive knowledge in a retrieval layer rather than in the weights.

What a good answer covers

  • LLMs don't just learn patterns; they memorise some training examples verbatim, especially data that's…
  • Extraction attacks pull that memorised data back out
  • (2023) showed a "divergence" prompt (asking a production chat model to repeat a word forever) caused it…
  • Privacy/PII - if you fine-tune on customer data, the model can leak one customer's data to another user…
  • Copyright/IP - verbatim regurgitation of copyrighted text is both a legal and a reputational exposure

Key terms: memorise · Extraction attacks · Privacy/PII · Copyright/IP · Secrets · Membership inference · deduplicate · scrub PII and secrets · differential privacy · output filters

Interviewer follow-ups to expect

  1. Why does deduplication reduce memorisation so much?

  2. How does this influence a RAG-vs-fine-tuning decision for private data?

  3. What is membership inference and when is it itself the harm?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep