Dataset Lineage and Provenance › Evaluation Provenance and Contamination

Michael BrenndoerferNovember 26, 20263 min read
Language AI HandbookAll chapters
Part 21 of 67Data Governance, Provenance, and Synthetic Ecosystems
Chapter 149Dataset Lineage and Provenance › Evaluation Provenance and Contamination
Reading section 12 of 17 · Evaluation Provenance and Contamination · 3 minSection 12 of 17 · 3 min

Section 12 of 17 · 3 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

Record the benchmark edition, split and any sampled subset with the prompt template, decoding configuration and scoring code. This identifies the examples and protocol behind a reported score. Exposure to benchmark content during training can inflate its score. The toy screen below measures literal five-gram overlap before packing.

We construct two positive controls from the retained transit document. The first copies it in full, and the second copies one sentence. The third example uses unrelated text as a negative control. The check compares their five-grams with those in the retained documents before packing.

overlap(e,T)=∣ngrams(e)∩⋃d∈Tngrams(d)∣∣ngrams(e)∣\mathrm{overlap}(e, T) = \frac{\left|\mathrm{ngrams}(e) \cap \bigcup_{d \in T}\mathrm{ngrams}(d)\right|} {\left|\mathrm{ngrams}(e)\right|}

where:

  • ee: an evaluation example
  • TT: the set of training documents
  • ngrams(e)\mathrm{ngrams}(e): the set of contiguous 5-grams in the evaluation example
  • ngrams(d)\mathrm{ngrams}(d): the set of contiguous 5-grams in training document dd
  • ⋃d∈Tngrams(d)\bigcup_{d \in T}\mathrm{ngrams}(d): the union of all 5-grams appearing in any training document
  • ∣⋅∣|\cdot|: the number of elements in a set

The numerator counts the evaluation 5-grams that also appear in training; the denominator is the total number of evaluation 5-grams. The result is a fraction between 0 and 1 for a nonempty evaluation five-gram set. When the set is empty, the fixture uses zero for its report, which indicates no available five-gram comparison. A paraphrase, translation, or code rewrite can evade exact matching when it preserves no five-grams. Common phrases can create matches without demonstrating that evaluation data entered training. Use the result to decide which examples need inspection.

PythonIn [27]
CollapseExpand
eval_examples = [
    {
        "eval_id": "eval-001",
        "task": "transit",
        "text": raw_docs[0]["text"],
    },
    {
        "eval_id": "eval-002",
        "task": "transit",
        "text": "The plan adds bus lanes and extends service hours across the region.",
    },
    {
        "eval_id": "eval-003",
        "task": "cooking",
        "text": "A recipe for lentil soup with carrots and thyme.",
    },
]

N_EVAL = 5
REVIEW_OVERLAP_THRESHOLD = 0.2
train_ngrams = set()
train_ngram_sources = defaultdict(set)

for doc in kept:
    toks = doc_tokens[doc["doc_id"]]
    for i in range(len(toks) - N_EVAL + 1):
        ngram = tuple(toks[i : i + N_EVAL])
        train_ngrams.add(ngram)
        train_ngram_sources[ngram].add(doc["doc_id"])

contam_rows = []
for example in eval_examples:
    toks = tokenize(example["text"])
    eval_ngrams = {
        tuple(toks[i : i + N_EVAL])
        for i in range(max(0, len(toks) - N_EVAL + 1))
    }
    hits = eval_ngrams & train_ngrams
    overlap = len(hits) / len(eval_ngrams) if eval_ngrams else 0.0
    source_docs = set()
    for ngram in hits:
        source_docs |= train_ngram_sources[ngram]
    contam_rows.append(
        {
            "eval_id": example["eval_id"],
            "task": example["task"],
            "eval_ngrams": len(eval_ngrams),
            "matched_ngrams": len(hits),
            "overlap_fraction": overlap,
            "source_docs": sorted(source_docs),
            "status": "flag_for_review"
            if overlap > REVIEW_OVERLAP_THRESHOLD
            else "below_threshold",
        }
    )

contam_df = pd.DataFrame(contam_rows)
Out[28]:
eval_id task eval_ngrams matched_ngrams overlap_fraction source_docs status
0 eval-001 transit 20 20 1.0 [doc-6bd4bf650451] flag_for_review
1 eval-002 transit 9 9 1.0 [doc-6bd4bf650451] flag_for_review
2 eval-003 cooking 6 0 0.0 [] below_threshold

All five-grams in both constructed positive controls appear in the retained transit document. The unrelated control has zero overlap. The controls exercise the screen without estimating leakage or performance for a benchmark edition or split. For a real benchmark, state which examples were screened and inspect matches across n-gram lengths and at sentence or document granularity where appropriate. Check task-specific artifacts such as answer formatting, prompt overlap, and label leakage separately.

The fixture flags overlap strictly above 0.2 for review and returns the matching document IDs. A low score leaves other forms of leakage open. In an audit, use these IDs to join to ingestion records and look for source, license, or consent evidence. The separate document trace below illustrates the lookup for the redacted web-006 item.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy