← Latest papers
💻 computer science

Learned or Memorized ? Quantifying Memorization Advantage in Code LLMs

This paper introduces a perturbation-based method to quantify memorization advantages in code LLMs, revealing that memorization risks are highly dependent on specific models and tasks while demonstrating that widely suspected benchmarks like CVEFixes and Defects4J actually exhibit low memorization, suggesting models rely more on learned generalization.

Original authors: Djiré Albérick Euraste, Kaboré Abdoul Kader, Jordan Samhi, Earl T. Barr, Jacques Klein, Tegawendé F. Bissyandé

Published 2026-04-16
📖 5 min read🧠 Deep dive

Original authors: Djiré Albérick Euraste, Kaboré Abdoul Kader, Jordan Samhi, Earl T. Barr, Jacques Klein, Tegawendé F. Bissyandé

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

The Big Question: Did the Student Cheat?

Imagine you are a teacher giving a final exam to a class of brilliant students (these students are AI Code Models). You want to know if they truly understand the math and logic behind the problems, or if they just memorized the answers from a specific textbook they were allowed to study.

In the world of AI, this is a huge problem. Because we don't know exactly what data these AI models were trained on, we often suspect they are "cheating" by having seen the test questions before. If they get a perfect score, is it because they are geniuses, or because they memorized the answer key?

This paper introduces a clever way to test if the students are memorizing or learning.


The Method: The "Slight Nudge" Test

Instead of just giving the students the same test again, the researchers decided to play a game of "spot the difference." They used a technique called Perturbation.

Think of it like this:

  • The Original Question: "Write a function to calculate the sum of numbers from 1 to 10."
  • The Nudge (Perturbation): "Write a function to calculate the total of integers starting at 1 and ending at 10."

To a human, these are the exact same question. The meaning hasn't changed at all. But to a robot that just memorized the answer to the first version, the second version might look like a completely different puzzle.

The Analogy of the Parrot vs. The Musician:

  • The Parrot (Memorization): If you ask a parrot to say "Hello," it says "Hello." If you ask it to say "Hullo" (a slight change), it might freeze or say something nonsense. It only knows the exact sound it heard.
  • The Musician (Generalization): If you ask a musician to play a song, and you ask them to play it slightly faster or in a different key, they can still play it. They understand the music, not just the notes.

The researchers "nudged" the code prompts in many ways (changing variable names, rephrasing instructions, shuffling code structure) and watched how the AI's performance dropped.

  • Big Drop in Performance? The AI was likely memorizing (The Parrot).
  • Small Drop in Performance? The AI was generalizing (The Musician).

What They Found: The Results

The researchers tested 8 different AI models on 19 different types of coding tasks. Here is what they discovered, using our classroom analogy:

1. The "Star Student" who might be cheating

One model, called StarCoder, did great on most tests but suddenly struggled when the questions were "nudged" on a specific dataset called APPS.

  • The Analogy: It's like a student who gets 100% on a math test but fails immediately if you change the font of the question. This suggests StarCoder might have memorized the specific answers for the APPS dataset rather than truly understanding the logic.

2. The "Surprising" Clean Benchmarks

There was a lot of worry in the community that popular datasets like Defects4J (a list of bugs) and CVEFixes (security patches) were "contaminated" (i.e., the AI had seen them before).

  • The Finding: The researchers found the opposite! When they nudged these questions, the AI's performance didn't crash.
  • The Analogy: People thought the students were cheating on the "Security Exam," but the test showed they actually understood the security concepts deeply. They weren't just reciting answers; they were solving the problems.

3. The Easiest vs. Hardest Subjects

  • Code Summarization (The Easy Subject): When asked to explain what code does in plain English, the AI models were very robust. Even when the code was slightly changed, they still understood it. It's like a student who can summarize a story no matter how you rephrase the title.
  • Test Generation (The Hard Subject): When asked to write tests for code (checking if the code works), the models struggled more with the "nudges." This suggests that writing tests requires a deeper, more fragile understanding that is harder to generalize.

4. The Security Domain is a Wild Card

In the field of security (finding bugs and vulnerabilities), the results were all over the place. Some models were super robust, while others fell apart with the slightest nudge.

  • The Analogy: It's like a classroom where some students are experts in history but terrible at geography. There is no "one size fits all" for security; it depends heavily on how the specific AI was built.

Why Does This Matter?

This paper is a wake-up call for the AI community.

  1. Don't just look at the score: A high score on a test doesn't always mean the AI is smart. It might just mean the AI memorized the test.
  2. We need better tests: We shouldn't just use static, unchanging tests. We need tests that change slightly every time (dynamic benchmarks) to force the AI to prove it actually understands the logic.
  3. Design matters: Two AI models might have the same size (number of "brain cells"), but if one was trained differently, it might be a "Musician" while the other is just a "Parrot."

The Bottom Line

The authors built a tool to measure how "brittle" an AI's knowledge is. If the AI breaks when you slightly change the question, it's memorizing. If it stays strong, it's learning.

They found that while some AI models are indeed memorizing specific datasets, others are genuinely learning to code. The key takeaway? We need to stop trusting the raw scores and start testing how well these models handle the unexpected.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →