Learned or Memorized ? Quantifying Memorization Advantage in Code LLMs

Djiré Albérick Euraste, Kaboré Abdoul Kader, Jordan Samhi, Earl T. Barr, Jacques Klein, Tegawendé F. BissyandéarXiv 2026 · DOI

TL;DR

How do we know if a code LLM actually understands programming or has just memorized the test set? This paper introduces a perturbation-based framework to quantify the "memorization advantage" of 8 popular code LLMs across 19 benchmarks. Surprisingly, widely suspected datasets like Defects4J and CVEFixes show low memorization signatures, suggesting models are genuinely generalizing rather than just regurgitating code.

What Problem Does This Paper Address?

The training datasets for state-of-the-art code LLMs are notoriously opaque due to commercial and privacy reasons. This creates a massive challenge: benchmark contamination. If a model has already seen evaluation benchmarks during its pre-training phase, its high performance might be an illusion driven by data leakage rather than true generalization.

Existing methods to detect data leakage often require access to training data or internal model weights, which are rarely available. This paper addresses the need for a black-box method to distinguish between genuine generalization (interpolation) and rote memorization in code LLMs.

Methods

The authors leverage the Perturbation Sensitivity Hypothesis (PSH). The core intuition is that if a model has memorized a specific piece of code or text, even a minor, human-imperceptible change (a perturbation) will cause its performance to plummet drastically. Conversely, if the model has truly learned the underlying logic, its performance will degrade gracefully.

Figure 1: GPT_4o text completion performance falloff for a memorized Shakespeare poem submitted to perturbations vs gradual performance decline with a recent BBC text (could not part of the training set of GPT_4o).

The authors formalize this by applying two task-specific perturbation types across 5 intensity levels:

  1. Natural Language Perturbations (for NL2Code tasks): Using the BART model to generate progressively paraphrased versions of prompts, ordered by semantic distance.
  2. Code Perturbations (for Code2Code/Code2NL tasks): Progressively renaming variables using randomly generated identifier names ($\alpha$-renaming).

By measuring the maximum performance drop between consecutive perturbation levels, they calculate a sensitivity score. High sensitivity indicates a model is relying on memorization or suffers from a severe knowledge gap.

Datasets

The paper evaluates 8 open-source models (including DeepSeek-Coder-V2, Qwen2.5-Coder, StarCoder, and CodeLlama) across 19 benchmarks spanning five task families:

  • Code Generation: HumanEval, APPS, MBPP, LBPP, CodeContest, XLCost.
  • Program Repair: QuixBugs, Defects4J, ConDefects.
  • Test Generation: BigCodeBench, TestEval, QuixBugs.
  • Vulnerability Detection: CVEFixes, VulDetectBench, VulnPatchPairs, Devign, ReVeal, DiverseVul.
  • Code Summarization: CodeSearchNet, TLCode-Sum.

No new benchmarks are introduced; instead, the paper systematically audits these existing datasets for signs of model memorization.

Key Insights and Ideas

  • Generalization is Highly Task-Dependent: Code summarization tasks show remarkably low sensitivity (<0.3) across all models, indicating robust generalization. Meanwhile, test generation and context-dependent program repair (ConDefects) exhibit high sensitivity (0.4–0.7), marking them as significant generalization challenges for current architectures.
  • The Defects4J and CVEFixes Surprise: Both datasets are frequently suspected of data leakage within the research community. However, they showed unexpectedly low memorization advantage scores. CVEFixes scores were consistently below 0.1. The authors hypothesize that either the models have genuinely generalized these common vulnerability/repair patterns, or extreme duplication in training data has pushed the model's sensitivity threshold further out.
  • Architecture Trumps Size: Models with similar parameter counts showed completely different sensitivity profiles. For example, StarCoder showed high sensitivity (up to 0.8) on the APPS benchmark, suggesting potential contamination, while QwenCoder maintained consistently low values (<0.4) across most benchmarks.

Key Results

  • Code Generation: Most models demonstrated strong generalization with sensitivity scores below 0.4. However, StarCoder was a clear outlier on the APPS benchmark, spiking to ~0.8 ($p < 0.01$).
  • Test Generation: All models showed a statistically significant leap in sensitivity (0.4–0.7 median range) compared to basic code generation ($p < 0.001$), proving that writing tests requires a deeper semantic understanding that models struggle to generalize.
  • Vulnerability Detection: This domain showed the widest variance. While CVEFixes was incredibly robust (<0.1 sensitivity), other security benchmarks like Devign and ReVeal showed moderate-to-high sensitivity (0.4–0.8), indicating that generalizing security knowledge remains an ongoing struggle.

Limitations and Future Work

  • No Definitive Proof of Leakage: Because training datasets remain private, this perturbation method provides strong circumstantial evidence of memorization but cannot definitively prove data leakage.
  • Syntactic vs. Semantic Perturbations: The code perturbations were limited to syntactic changes ($\alpha$-renaming of variables). The authors note that future work should explore semantic perturbations, such as altering loop structures or changing control flows, to see if models maintain their robustness.
  • Model Version Specificity: The results represent a snapshot of specific model versions. As code LLMs rapidly evolve, their sensitivity profiles and generalization boundaries will shift.

Summary updated

BibTeX
@misc{euraste2026learned,
  author = {Djiré Albérick Euraste and Kaboré Abdoul Kader and Jordan Samhi and Earl T. Barr and Jacques Klein and Tegawendé F. Bissyandé},
  title = {{Learned or Memorized ? Quantifying Memorization Advantage in Code LLMs}},
  year = {2026},
  eprint = {2604.13997},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2604.13997},
}
Figure