mlsanityData to 14 Oct 2026

Traces of Memorisation in Large Language Models for Code

arXiv 2312.11658 ↗First posted 18 Dec 2023cs.CR cs.AI cs.SEcited by 29

On the map: LLM safety and security → Membership inference attacks

Abstract (arXiv)

Large language models have gained significant popularity because of their ability to generate human-like text and potential applications in various fields, such as Software Engineering. Large language models for code are commonly trained on large unsanitised corpora of source code scraped from the internet. The content of these datasets is memorised and can be extracted by attackers with data extraction attacks. In this work, we explore memorisation in large language models for code and compare the rate of memorisation with large language models trained on natural language. We adopt an existing benchmark for natural language and construct a benchmark for code by identifying samples that are vulnerable to attack. We run both benchmarks against a variety of models, and perform a data extraction attack. We find that large language models for code are vulnerable to data extraction attacks, like their natural language counterparts. From the training data that was identified to be potentially extractable we were able to extract 47% from a CodeGen-Mono-16B code completion model. We also observe that models memorise more, as their parameter count grows, and that their pre-training data are also vulnerable to attack. We also find that data carriers are memorised at a higher rate than regular code or documentation and that different model architectures memorise different samples. Data leakage has severe outcomes, so we urge the research community to further investigate the extent of this phenomenon using a wider range of models and extraction techniques in order to build safeguards to mitigate this issue.

Key facts. Cited by 29 papers in the map (data through 14 Oct 2026). Placed in Membership inference attacks, one of 12 directions in LLM safety and security. Builds on 37 of its 54 references that are in the map. First posted on arXiv 18 Dec 2023.

Builds on

37 of 54 references.

Closest ancestors · 7

Same direction, newest first

  1. 2023Overconfidence is a Dangerous Thing: Mitigating Membership Inference Attacks by Enforcing Less Confident Prediction4 Jul
  2. 2023Towards More Realistic Membership Inference Attacks on Large Diffusion Models22 Jun
  3. 2023Targeted Attack on GPT-Neo for the SATML Language Model Data Extraction Challenge13 Feb
  4. 2023Analyzing Leakage of Personally Identifiable Information in Language Models1 Feb
  5. 2022Quantifying Privacy Risks of Masked Language Models Using Membership Inference Attacks8 Mar
  6. 2021Membership Inference Attacks From First Principles7 Dec
  7. 2021Membership Inference Attacks on Machine Learning: A Survey14 Mar

Other references · 30

  1. 2022Training language models to follow instructions with human feedbackcited by 15,971
  2. 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,459
  3. 2021Pre-train, Prompt, and Predict: A Systematic Survey of Prompting Methods in Natural Language Processingcited by 2,234
  4. 2020Extracting Training Data from Large Language Modelscited by 2,189
  5. 2023Pythia: A Suite for Analyzing Large Language Models Across Training and Scalingcited by 1,786
  6. 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,310
  7. 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 906
  8. 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 885
  9. 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 744
  10. 2023Extracting Training Data from Diffusion Modelscited by 732
  11. 2021Deduplicating Training Data Makes Language Models Bettercited by 714
  12. 2022InCoder: A Generative Model for Code Infilling and Synthesiscited by 498
18 more
  1. 2019Does Learning Require Memorization? A Short Tale about a Long Tailcited by 460
  2. 2020Label-Only Membership Inference Attackscited by 388
  3. 2022A Systematic Evaluation of Large Language Models of Codecited by 363
  4. 2022Deduplicating Training Data Mitigates Privacy Risks in Language Modelscited by 314
  5. 2022Memorization Without Overfitting: Analyzing the Training Dynamics of Large Language Modelscited by 220
  6. 2022Are Large Pre-Trained Language Models Leaking Your Personal Information?cited by 200
  7. 2022What Does it Mean for a Language Model to Preserve Privacy?cited by 195
  8. 2023Emergent and Predictable Memorization in Large Language Modelscited by 148
  9. 2022The Privacy Onion Effect: Memorization is Relativecited by 136
  10. 2019Reconstruction and Membership Inference Attacks against Generative Modelscited by 122
  11. 2022CERT: Continual Pre-Training on Sketches for Library-Oriented Code Generationcited by 87
  12. 2019Membership Inference Attacks on Sequence-to-Sequence Models: Is My Data In Your Machine Translation System?cited by 71
  13. 2022CodeFill: Multi-token Code Completion by Jointly Learning from Structure and Naming Sequencescited by 50
  14. 2023Training Data Extraction From Pre-trained Language Models: A Surveycited by 45
  15. 2022Codex Hacks HackerRank: Memorization Issues and a Framework for Code Synthesis Evaluationcited by 14
  16. 2023The (ab)use of Open Source Code to Train Large Language Modelscited by 10
  17. 2023SecretBench: A Dataset of Software Secretscited by 5
  18. 2023Whose Text Is It Anyway? Exploring BigCode, Intellectual Property, and Ethicscited by 3

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2024: 6; 2025: 14; 2026: 9.

29 papers.

Sort:

By area:

  1. 2024A Survey on Large Language Models for Code Generationcited by 658
  2. 2024LiCoEval: Evaluating LLMs on License Compliance in Code Generationcited by 14
  3. 2024API-guided Dataset Synthesis to Finetune Large Code Modelscited by 11
  4. 2024An Exploratory Investigation into Code License Infringements in Large Language Model Training Datasetscited by 9
  5. 2025Memorize or Generalize? Evaluating LLM Code Generation with Code Rewritingcited by 7
  6. 2025Scrub It Out! Erasing Sensitive Memorization in Code Language Models via Machine Unlearningcited by 7
  7. 2025Differentiation-Based Extraction of Proprietary Data from Fine-Tuned LLMscited by 6
  8. 2026Human oversight of agentic systems in practice: Examining the oversight work, challenges, and heuristics of developers using software agentscited by 6
  9. 2025Benchmarking AI Models in Software Engineering: A Review, Search Tool, and Unified Approach for Elevating Benchmark Qualitycited by 4
  10. 2024CodeCipher: Learning to Obfuscate Source Code Against LLMscited by 3
  11. 2025How Much Do Code Language Models Remember? An Investigation on Data Extraction Attacks before and after Fine-tuningcited by 3
  12. 2024Can Large Language Models put 2 and 2 together? Probing for Entailed Arithmetical Relationshipscited by 1
17 more
  1. 2025Low-Perplexity LLM-Generated Sequences and Where To Find Themcited by 1
  2. 2025Breaking Memorization Barriers in LLM Code Fine-Tuning via Information Bottleneck for Improved Generalizationcited by 1
  3. 2025Effective Code Membership Inference for Code Completion Models via Adversarial Promptscited by 1
  4. 2026Model See, Model Do? Exposure-Aware Evaluation of Bug-vs-Fix Preference in Code LLMscited by 1
  5. 2026The Next Challenge for Agentic Cybersecurity: A Realistic, Contamination-Free Reverse Engineering Benchmarkcited by 1
  6. 2025Malicious and Unintentional Disclosure Risks in Large Language Models for Code Generationcited by 0
  7. 2025Contamination Means Overestimation? A Fine-Grained Empirical Study in Code Intelligencecited by 0
  8. 2025Are AI Coders Snitches? An Empirical Study of Pretraining Data Detection on Code Large Language Modelscited by 0
  9. 2025DevLicOps: A Framework for Mitigating Licensing Risks in AI-Generated Codecited by 0
  10. 2025Towards Privacy-Preserving Code Generation: Differentially Private Code Language Modelscited by 0
  11. 2025SoK: Understanding (New) Security Issues Across AI4Code Use Casescited by 0
  12. 2026Exploring Approaches for Detecting Memorization of Recommender System Data in Large Language Modelscited by 0
  13. 2026SERSEM: Selective Entropy-Weighted Scoring for Membership Inference in Code Language Modelscited by 0
  14. 2026A Metamorphic Testing Approach to Diagnosing Memorization in LLM-Based Program Repaircited by 0
  15. 2026Feedback-Normalized Developer Memory for Reinforcement-Learning Coding Agents: A Safety-Gated MCP Architecturecited by 0
  16. 2026Characterizing the Quality Profile of AI-Generated C++ in Productioncited by 0
  17. 2026Keep Evaluation Fair: Detecting Data Leakage in Code Generation Benchmarks via Membership Inference Attackscited by 0

Similar, not cited

Close in wording, no citation either way

  1. 2024Undesirable Memorization in Large Language Models: A Survey
  2. 2026Detecting Functional Memorization in Code Language Models
  3. 2025A Survey on Model Extraction Attacks and Defenses for Large Language Models
  4. 2023On Extracting Specialized Code Abilities from Large Language Models: A Feasibility Study
  5. 2024Measuring Impacts of Poisoning on Model Parameters and Embeddings for Large Language Models of Code
  6. 2026A Lifecycle and Application-Stack Survey of Large Language Model Vulnerabilities: Attacks, Risks, Defenses, and Open Problems
  7. 2023Latent Jailbreak: A Benchmark for Evaluating Text Safety and Output Robustness of Large Language Models
  8. 2024Breaking Down the Defenses: A Comparative Survey of Attacks on Large Language Models