Skip to content
Book Open access

When AI Coding Assistants Leak Training Data: A Study of LLM Memorization in Code Generation

Jul 2026 · AIware · 0 citations · 29 references
Computer Science

TL;DR

It is confirmed that memorization persists in modern LLMs and is influenced more by a complex interplay of training domain, dataset composition, architectural choices, and content characteristics, rather than parameter count alone.

Abstract

Large Language Models (LLMs) for code generation risk memorizing and reproducing sensitive training data, including licensed code and proprietary information. We investigate memorization behavior in recent open-weight LLMs in code generation using a two-stage memorization evaluation pipeline, which combines a similarity-based extractability filter with a targeted data extraction attack. We evaluate four models (StarCoder2-3B, StarCoder2-7B, Llama3-8B, and DeepSeek-R1-distilled-Llama-8B) on a custom dataset of 30,000+ Python files. Our results reveal memorization rates of 42-64%, with code-specialized models exhibiting higher rates than general-purpose models. Categorical analysis shows that repetitive content (license headers, documentation) is memorized at rates up to 70%, while complex code exhibits lower susceptibility. Notably, realistic code completion scenarios trigger unintentional memorization in 13-14% of cases, posing practical risks for AI coding assistants. We demonstrate that knowledge distillation reduces extraction rates by approximately 19%, offering a cost-effective mitigation approach. Our findings confirm that memorization persists in modern LLMs and is influenced more by a complex interplay of training domain, dataset composition, architectural choices, and content characteristics, rather than parameter count alone.

Read PDF

Similar papers

Preprint Aug 2026

Memorization Diagnostics for Code LLMs Should be Scale-Aware

It is revealed that scaled encoders successfully absorb substantial representation load while still converging on the correct family of solutions, and this ability to adapt to varying surface forms is what truly matters for usability and generalizability in LLM and agentic applications.

P. Rajput, Abdoul Aziz Bonkoungou, Albérick Euraste Djiré et al. · 0 citations
Preprint Jul 2026

CoGate: Confidence-Gated Co-Decoding for Secure Code Generation

CoGate is proposed, a confidence-gated co-decoding approach that controls the expert's influence on the co-decoding process based on its confidence, and outperforms existing co-decoding methods (CoSec+) across multiple benchmarks.

Minghao Hu, Lannan Luo, Allen G. Roush et al. · 0 citations
Conference Open access 2026

AutoSUIT Bench - Automated Security UnIt Test Benchmark for LLM Coding

Upon benchmarking against LLMs, it is found that functionality pass rate is consistently higher than vulnerability pass rate for all programming languages, highlighting the necessity of vulnerable code benchmarks with larger CWE coverage.

Samuel Osebe, Fan Yang, Junyi Li et al. · 0 citations
Preprint Jul 2026

Quantize with Confidence? An Empirical Study of Quantization for Code Generation

Six state-of-the-art quantization methods are evaluated on two representative large code model families using the multilingual McEval and CoderEval benchmarks for Python and Java to provide practical guidance for selecting quantization strategies for deploying large code models on resource-constrained hardware.

Saima Afrin, MD Zahidul Haque, A. Mastropaolo · 0 citations
Open access Jul 2026

AlquistCoder: A Synthetic Data Approach to Training Compact Secure Coding Assistants and Building Security Benchmarks

AlquistCoder, a compact 3.8B‐parameter coding assistant designed to address both risks through targeted synthetic‐data alignment, is introduced and publicly released to support reproducible research on security alignment for code‐generation models.

Ondřej Kobza, Adam Černý, Ivanka M. Dostal et al. · 0 citations
Open access Aug 2026

Detecting AI-Generated Text and Code: An Empirical Study of Cross-Generator and Cross-Domain Generalization

A paired-prompt benchmark for human-versus-machine detection across English text, Python code, and mixed text–code documents shows that reliable deployment requires cross-domain evaluation, mixed-content testing, and calibration beyond in-distribution accuracy.

Neethika Alluri, Pardha Saradhi Varma Gottumukkala, H. Indukuri · 0 citations