Unveiling Memorization in Code Models
Not on the map. Why?
Abstract (arXiv)
The availability of large-scale datasets, advanced architectures, and powerful computational resources have led to effective code models that automate diverse software engineering activities. The datasets usually consist of billions of lines of code from both open-source and private repositories. A code model memorizes and produces source code verbatim, which potentially contains vulnerabilities, sensitive information, or code with strict licenses, leading to potential security and privacy issues. This paper investigates an important problem: to what extent do code models memorize their training data? We conduct an empirical study to explore memorization in large pre-trained code models. Our study highlights that simply extracting 20,000 outputs (each having 512 tokens) from a code model can produce over 40,125 code snippets that are memorized from the training data. To provide a better understanding, we build a taxonomy of memorized contents with 3 categories and 14 subcategories. The results show that the prompts sent to the code models affect the distribution of memorized contents. We identify several key factors of memorization. Specifically, given the same architecture, larger models suffer more from memorization problems. A code model produces more memorization when it is allowed to generate longer outputs. We also find a strong positive correlation between the number of an output's occurrences in the training data and that in the generated outputs, which indicates that a potential way to reduce memorization is to remove duplicates in the training data. We then identify effective metrics that infer whether an output contains memorization accurately. We also make suggestions to deal with memorization.
Key facts. Cited by 29 papers in the map (data through 7 Oct 2026). First posted on arXiv 19 Aug 2023.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2024: 6; 2025: 17; 2026: 6.
29 papers.
Sort:
By area:
- 2025LessLeak-Bench: A First Investigation of Data Leakage in LLMs Across 83 Software Engineering Benchmarkscited by 34
- 2024Recite, Reconstruct, Recollect: Memorization in LMs as a Multifaceted Phenomenoncited by 30
- 2025A Survey on Model Extraction Attacks and Defenses for Large Language Modelscited by 18
- 2025Beyond Final Code: A Process-Oriented Error Analysis of Software Development Agents in Real-World GitHub Scenarioscited by 14
- 2024LiCoEval: Evaluating LLMs on License Compliance in Code Generationcited by 13
- 2024The Fault in our Stars: Quality Assessment of Code Generation Benchmarkscited by 9
- 2024An Empirical Study on Capability of Large Language Models in Understanding Code Semanticscited by 7
- 2025Memorize or Generalize? Evaluating LLM Code Generation with Code Rewritingcited by 6
- 2026Human oversight of agentic systems in practice: Examining the oversight work, challenges, and heuristics of developers using software agentscited by 6
- 2025Memorization in Large Language Models in Medicine: Prevalence, Characteristics, and Implicationscited by 5
- 2024Promise and Peril of Collaborative Code Generation Models: Balancing Effectiveness and Memorizationcited by 4
- 2025"My productivity is boosted, but ..." Demystifying Users' Perception on AI Coding Assistantscited by 4
17 more
- 2025The Fools are Certain; the Wise are Doubtful: Exploring LLM Confidence in Code Completioncited by 3
- 2025Trust Me, I Know This Function: Hijacking LLM Static Analysis using Biascited by 3
- 2025Scrub It Out! Erasing Sensitive Memorization in Code Language Models via Machine Unlearningcited by 3
- 2024Developer Perspectives on Licensing and Copyright Issues Arising from Generative AI for Software Developmentcited by 2
- 2026AscendOptimizer: Episodic Agent for Ascend NPU Operator Optimizationcited by 2
- 2025Layer-Wise Perturbations via Sparse Autoencoders for Adversarial Text Generationcited by 1
- 2025Breaking Memorization Barriers in LLM Code Fine-Tuning via Information Bottleneck for Improved Generalizationcited by 1
- 2026Model See, Model Do? Exposure-Aware Evaluation of Bug-vs-Fix Preference in Code LLMscited by 1
- 2026RustMizan: A Compilable, Contamination-Aware Benchmarking Framework for Rust Vulnerabilitiescited by 1
- 2025Malicious and Unintentional Disclosure Risks in Large Language Models for Code Generationcited by 0
- 2025Contamination Means Overestimation? A Fine-Grained Empirical Study in Code Intelligencecited by 0
- 2025Benchmarking Web API Integration Code Generationcited by 0
- 2025CodeGenLink: A Tool to Find the Likely Origin and License of Automatically Generated Codecited by 0
- 2025Effective Code Membership Inference for Code Completion Models via Adversarial Promptscited by 0
- 2025How Do Semantically Equivalent Code Transformations Impact Membership Inference on LLMs for Code?cited by 0
- 2026Predicting Program Exit Code with LLMs and Programming Language Semanticscited by 0
- 2026PatchBench: Evaluating AI Agents for Vulnerability Patchingcited by 0
- 2026PatchBench: Evaluating AI Agents for Vulnerability Patching3 Sep 2026
- 2026Predicting Program Exit Code with LLMs and Programming Language Semantics1 Sep 2026
- 2026RustMizan: A Compilable, Contamination-Aware Benchmarking Framework for Rust Vulnerabilities6 Jul 2026
- 2026Human oversight of agentic systems in practice: Examining the oversight work, challenges, and heuristics of developers using software agents3 Jun 2026
- 2026AscendOptimizer: Episodic Agent for Ascend NPU Operator Optimization24 Mar 2026
- 2026Model See, Model Do? Exposure-Aware Evaluation of Bug-vs-Fix Preference in Code LLMs15 Jan 2026
- 2025How Do Semantically Equivalent Code Transformations Impact Membership Inference on LLMs for Code?17 Dec 2025
- 2025Effective Code Membership Inference for Code Completion Models via Adversarial Prompts19 Nov 2025
- 2025Breaking Memorization Barriers in LLM Code Fine-Tuning via Information Bottleneck for Improved Generalization15 Oct 2025
- 2025CodeGenLink: A Tool to Find the Likely Origin and License of Automatically Generated Code1 Oct 2025
- 2025Benchmarking Web API Integration Code Generation24 Sep 2025
- 2025Scrub It Out! Erasing Sensitive Memorization in Code Language Models via Machine Unlearning17 Sep 2025
17 more
- 2025Memorization in Large Language Models in Medicine: Prevalence, Characteristics, and Implications10 Sep 2025
- 2025Trust Me, I Know This Function: Hijacking LLM Static Analysis using Bias24 Aug 2025
- 2025The Fools are Certain; the Wise are Doubtful: Exploring LLM Confidence in Code Completion22 Aug 2025
- 2025"My productivity is boosted, but ..." Demystifying Users' Perception on AI Coding Assistants17 Aug 2025
- 2025Layer-Wise Perturbations via Sparse Autoencoders for Adversarial Text Generation14 Aug 2025
- 2025A Survey on Model Extraction Attacks and Defenses for Large Language Models26 Jun 2025
- 2025Contamination Means Overestimation? A Fine-Grained Empirical Study in Code Intelligence3 Jun 2025
- 2025Malicious and Unintentional Disclosure Risks in Large Language Models for Code Generation27 Mar 2025
- 2025Beyond Final Code: A Process-Oriented Error Analysis of Software Development Agents in Real-World GitHub Scenarios16 Mar 2025
- 2025Memorize or Generalize? Evaluating LLM Code Generation with Code Rewriting4 Mar 2025
- 2025LessLeak-Bench: A First Investigation of Data Leakage in LLMs Across 83 Software Engineering Benchmarks10 Feb 2025
- 2024Developer Perspectives on Licensing and Copyright Issues Arising from Generative AI for Software Development16 Nov 2024
- 2024Promise and Peril of Collaborative Code Generation Models: Balancing Effectiveness and Memorization18 Sep 2024
- 2024LiCoEval: Evaluating LLMs on License Compliance in Code Generation5 Aug 2024
- 2024An Empirical Study on Capability of Large Language Models in Understanding Code Semantics4 Jul 2024
- 2024Recite, Reconstruct, Recollect: Memorization in LMs as a Multifaceted Phenomenon25 Jun 2024
- 2024The Fault in our Stars: Quality Assessment of Code Generation Benchmarks15 Apr 2024
- 2025Scrub It Out! Erasing Sensitive Memorization in Code Language Models via Machine Unlearningcited by 3
- 2025Layer-Wise Perturbations via Sparse Autoencoders for Adversarial Text Generationcited by 1
- 2025Effective Code Membership Inference for Code Completion Models via Adversarial Promptscited by 0
- 2025How Do Semantically Equivalent Code Transformations Impact Membership Inference on LLMs for Code?cited by 0
- 2025How Do Semantically Equivalent Code Transformations Impact Membership Inference on LLMs for Code?17 Dec 2025
- 2025Effective Code Membership Inference for Code Completion Models via Adversarial Prompts19 Nov 2025
- 2025Scrub It Out! Erasing Sensitive Memorization in Code Language Models via Machine Unlearning17 Sep 2025
- 2025Layer-Wise Perturbations via Sparse Autoencoders for Adversarial Text Generation14 Aug 2025
- 2025Beyond Final Code: A Process-Oriented Error Analysis of Software Development Agents in Real-World GitHub Scenarioscited by 14
- 2026Human oversight of agentic systems in practice: Examining the oversight work, challenges, and heuristics of developers using software agentscited by 6
- 2026RustMizan: A Compilable, Contamination-Aware Benchmarking Framework for Rust Vulnerabilitiescited by 1
- 2026RustMizan: A Compilable, Contamination-Aware Benchmarking Framework for Rust Vulnerabilities6 Jul 2026
- 2026Human oversight of agentic systems in practice: Examining the oversight work, challenges, and heuristics of developers using software agents3 Jun 2026
- 2025Beyond Final Code: A Process-Oriented Error Analysis of Software Development Agents in Real-World GitHub Scenarios16 Mar 2025
- 2025LessLeak-Bench: A First Investigation of Data Leakage in LLMs Across 83 Software Engineering Benchmarkscited by 34
- 2024Recite, Reconstruct, Recollect: Memorization in LMs as a Multifaceted Phenomenoncited by 30
- 2025A Survey on Model Extraction Attacks and Defenses for Large Language Modelscited by 18
- 2024LiCoEval: Evaluating LLMs on License Compliance in Code Generationcited by 13
- 2024The Fault in our Stars: Quality Assessment of Code Generation Benchmarkscited by 9
- 2024An Empirical Study on Capability of Large Language Models in Understanding Code Semanticscited by 7
- 2025Memorize or Generalize? Evaluating LLM Code Generation with Code Rewritingcited by 6
- 2025Memorization in Large Language Models in Medicine: Prevalence, Characteristics, and Implicationscited by 5
- 2024Promise and Peril of Collaborative Code Generation Models: Balancing Effectiveness and Memorizationcited by 4
- 2025"My productivity is boosted, but ..." Demystifying Users' Perception on AI Coding Assistantscited by 4
- 2025The Fools are Certain; the Wise are Doubtful: Exploring LLM Confidence in Code Completioncited by 3
- 2025Trust Me, I Know This Function: Hijacking LLM Static Analysis using Biascited by 3
12 most cited of 22 All 22 (JSON)
- 2026PatchBench: Evaluating AI Agents for Vulnerability Patching3 Sep 2026
- 2026Predicting Program Exit Code with LLMs and Programming Language Semantics1 Sep 2026
- 2026AscendOptimizer: Episodic Agent for Ascend NPU Operator Optimization24 Mar 2026
- 2026Model See, Model Do? Exposure-Aware Evaluation of Bug-vs-Fix Preference in Code LLMs15 Jan 2026
- 2025Breaking Memorization Barriers in LLM Code Fine-Tuning via Information Bottleneck for Improved Generalization15 Oct 2025
- 2025CodeGenLink: A Tool to Find the Likely Origin and License of Automatically Generated Code1 Oct 2025
- 2025Benchmarking Web API Integration Code Generation24 Sep 2025
- 2025Memorization in Large Language Models in Medicine: Prevalence, Characteristics, and Implications10 Sep 2025
- 2025Trust Me, I Know This Function: Hijacking LLM Static Analysis using Bias24 Aug 2025
- 2025The Fools are Certain; the Wise are Doubtful: Exploring LLM Confidence in Code Completion22 Aug 2025
- 2025"My productivity is boosted, but ..." Demystifying Users' Perception on AI Coding Assistants17 Aug 2025
- 2025A Survey on Model Extraction Attacks and Defenses for Large Language Models26 Jun 2025
12 newest of 22 All 22 (JSON)