← Latest papers
💬 NLP

Detecting Data Contamination in LLMs via In-Context Learning

The paper introduces CoDeC, a practical and automated method that detects and quantifies training data contamination in large language models by analyzing how in-context learning impacts model confidence, distinguishing between memorized training data and unseen distributions.

Original authors: Michał Zawalski, Meriem Boubdir, Klaudia Bałazy, Besmira Nushi, Pablo Ribalta

Published 2026-05-13
📖 4 min read☕ Coffee break read

Original authors: Michał Zawalski, Meriem Boubdir, Klaudia Bałazy, Besmira Nushi, Pablo Ribalta

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

Imagine you are a teacher grading a student's exam. You want to know: Did this student actually learn the material, or did they just memorize the answers from a leaked answer key?

For a long time, checking if Large Language Models (LLMs) have "cheated" by memorizing their test questions during training has been like trying to find a needle in a haystack. Traditional methods were slow, required access to the model's secret training files, or gave confusing results.

This paper introduces a new, simple tool called CoDeC (Contamination Detection via Context). Think of CoDeC as a "Surprise Quiz with a Hint" test.

The Core Idea: The "Hint" Test

Here is how CoDeC works, using a simple analogy:

1. The "Unseen" Scenario (The Honest Student)
Imagine you ask a student a math problem they've never seen before.

  • Without a hint: They might struggle a bit.
  • With a hint: You show them a similar problem they also haven't seen before. Suddenly, they get a "lightbulb moment." The hint helps them understand the style of the question, and they answer with more confidence.
  • CoDeC's Observation: When a model sees a dataset it hasn't memorized, giving it examples from that same dataset acts like a helpful hint. The model gets smarter and more confident.

2. The "Memorized" Scenario (The Cheating Student)
Now, imagine you ask the student a problem they have already memorized from a leaked answer key.

  • Without a hint: They recite the answer perfectly because they know it by heart.
  • With a hint: You show them another problem from the same leaked key. Instead of helping, this new information confuses them. Why? Because their brain is stuck in "recitation mode." The new hint disrupts their rigid memory pattern, causing them to stumble and answer with less confidence.
  • CoDeC's Observation: When a model has memorized the data, adding more examples from that same data actually lowers its confidence because it breaks their memorization rhythm.

How CoDeC Measures This

The method is surprisingly simple and automated:

  1. Take a question from a dataset you suspect might be in the model's training data.
  2. Ask the model to answer it (Measure its confidence).
  3. Add a "hint": Put a few other random questions from that same dataset right before the target question.
  4. Ask the model again: Does its confidence go up or down?
    • Confidence goes UP? The model is likely clean (it's learning from the context).
    • Confidence goes DOWN? The model is likely contaminated (it's memorizing, and the extra context is messing it up).

By doing this for hundreds of questions, CoDeC gives you a percentage score.

  • 0–20%: The model is likely honest; it's reasoning, not memorizing.
  • 80–100%: The model has likely memorized this dataset. It's "cheating."

Why This is a Big Deal

  • No Secret Keys Needed: You don't need to see the model's training files (which are often secret). You just need to talk to the model.
  • It Works Everywhere: It works on math tests, coding challenges, and general knowledge questions.
  • It Catches "Soft" Cheating: It doesn't just catch exact copies. It catches models that have seen very similar data (like a rephrased version of a test question or a synthetic version of a benchmark). If the model has memorized the "vibe" of the test, CoDeC will catch it.

What the Authors Found

The researchers tested CoDeC on dozens of models, including some with public training data (so they knew the truth) and some with secret training data.

  • The Results: CoDeC was incredibly accurate (99.9% accuracy in distinguishing seen vs. unseen data).
  • The Baselines: Older methods (like checking how "easy" the model finds the question) failed to separate the cheaters from the honest students.
  • Real-World Findings: When they applied CoDeC to popular, recent models, they found several instances where models scored very high on specific benchmarks, suggesting those models had likely seen the test data (or very similar data) during their training.

The Takeaway

CoDeC is like a lie detector for AI benchmarks. It doesn't just ask, "Do you know the answer?" It asks, "Does seeing more of this topic help you, or does it confuse you?" If it confuses you, you probably already knew the answer by heart. This helps the AI community trust benchmark scores more and ensures that models are being judged on their ability to learn, not just their ability to memorize.

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 →