Lune

ICSE2024Top-tier venue

Traces of Memorisation in Large Language Models for Code

Ali Al-Kaswan, Maliheh Izadi, Arie van Deursen

Abstract

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.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

8 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Differentiation-Based Extraction of Proprietary Data from Fine-Tuned LLMs cites Membership Inference Attacks Against Machine Learning Models
  • Differentiation-Based Extraction of Proprietary Data from Fine-Tuned LLMs cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • Differentiation-Based Extraction of Proprietary Data from Fine-Tuned LLMs cites API-Guided Dataset Synthesis to Finetune Large Code Models
  • Differentiation-Based Extraction of Proprietary Data from Fine-Tuned LLMs cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
  • Differentiation-Based Extraction of Proprietary Data from Fine-Tuned LLMs cites Extracting Training Data from Large Language Models
  • API-Guided Dataset Synthesis to Finetune Large Code Models cites Training language models to follow instructions with human feedback
  • Promise and Peril of Collaborative Code Generation Models: Balancing Effectiveness and Memorization cites Extracting Training Data from Large Language Models
  • Effective Code Membership Inference for Code Completion Models via Adversarial Prompts cites Membership Inference Attacks Against Machine Learning Models
  • Effective Code Membership Inference for Code Completion Models via Adversarial Prompts cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • Effective Code Membership Inference for Code Completion Models via Adversarial Prompts cites Promise and Peril of Collaborative Code Generation Models: Balancing Effectiveness and Memorization
  • Effective Code Membership Inference for Code Completion Models via Adversarial Prompts cites Extracting Training Data from Large Language Models
  • Chain-of-Thought Prompting Elicits Reasoning in Large Language Models cites Training language models to follow instructions with human feedback
  • Training language models to follow instructions with human feedback cites Extracting Training Data from Large Language Models
  • Extracting Training Data from Large Language Models cites Membership Inference Attacks Against Machine Learning Models
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers8

  1. Licoeval: Evaluating LLMs on License Compliance in Code GenerationWeiwei Xu, Kai Gao, Hao He, Minghui ZhouICSE 2025 · 6 citations
  2. API-Guided Dataset Synthesis to Finetune Large Code ModelsZongjie Li, Daoyuan Wu, Shuai Wang, Zhendong SuOOPSLA 2025 · 6 citations
  3. Promise and Peril of Collaborative Code Generation Models: Balancing Effectiveness and MemorizationZhi Chen, Lingxiao JiangASE 2024 · 4 citations
  4. Differentiation-Based Extraction of Proprietary Data from Fine-Tuned LLMsZongjie Li, Daoyuan Wu, Shuai Wang, Zhendong SuCCS 2025 · 1 citation
  5. Effective Code Membership Inference for Code Completion Models via Adversarial PromptsYuan Jiang, Zehao Li, Shan Huang, Christoph Treude et al.ASE 2025 · 1 citation

Builds on24

  1. Training language models to follow instructions with human feedbackLong Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida et al.NeurIPS 2022 · 24,707 citations
  2. Chain-of-Thought Prompting Elicits Reasoning in Large Language ModelsJason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma et al.NeurIPS 2022 · 22,562 citations
  3. Membership Inference Attacks Against Machine Learning ModelsReza Shokri, Marco Stronati, Congzheng Song, Vitaly ShmatikovS&P 2017 · 5,137 citations
  4. Extracting Training Data from Large Language ModelsNicholas Carlini, Florian Tramèr, Eric Wallace, Matthew Jagielski et al.USENIX Security 2021 · 2,866 citations
  5. CodeBERT: A Pre-Trained Model for Programming and Natural LanguagesZhangyin Feng, Daya Guo, Duyu Tang, Nan Duan et al.EMNLP Findings 2020 · 2,828 citations

Related papers

  1. Quantifying Contamination in Evaluating Code Generation Capabilities of Language ModelsMartin Riddell, Ansong Ni, Arman CohanACL 2024
  2. Scalable Extraction of Training Data from Aligned, Production Language ModelsMilad Nasr, Javier Rando, Nicholas Carlini, Jonathan Hayase et al.ICLR 2025
  3. Unveiling Memorization in Code ModelsZhou Yang, Zhipeng Zhao, Chenyu Wang, Jieke Shi et al.ICSE 2024 · 33 citations
  4. Quantifying and Analyzing Entity-Level Memorization in Large Language ModelsZhenhong Zhou, Jiuyang Xiang, Chaomeng Chen, Sen SuAAAI 2024 · 23 citations
  5. Security Attacks on LLM-based Code Completion ToolsWen Cheng, Ke Sun, Xinyu Zhang, Wei WangAAAI 2025 · 21 citations
Dusk over the sea between two cliffs drawn in fine vertical lines