advanced25 min studyLesson 624 in Engineering

Deduplicate before trusting a split

Keep related conversations, templates, and source records together so evaluation tests generalization rather than repeated content.

On this page

What you’ll understand

  • Separate exact duplicates from semantic or source-related groups.
  • Design group-aware split rules before inspecting test outcomes.
  • Quantify row-split leakage under an explicit independent-assignment model.

Randomly splitting rows does not make examples independent when many rows are paraphrases of the same instruction, turns of one conversation, or variants from one source document. An evaluation can then reward recall of content already seen during training. Deduplication and group-aware splitting address different parts of that problem. Define relatedness and provenance before choosing a split, then freeze the evaluation rather than repeatedly tuning against its answers.

Different duplicate rules answer different questions

Exact hashing can detect identical canonical records, but canonicalization itself needs a contract: whitespace or formatting changes can be meaningful for code and structured-output tasks. Near-duplicate checks find similar strings or token sequences, while semantic grouping may connect paraphrases with little literal overlap. No single similarity threshold perfectly separates useful variation from leakage. Preserve source IDs and transformation lineage so generated variants can remain linked even when their text differs substantially.

Deduplication can reduce repeated exposure and memorization risk, but it is not a complete privacy guarantee or proof that a benchmark is uncontaminated. A model may have seen related content during pretraining, and a fine-tuning dataset can contain sensitive information once without any duplicates. Review provenance, permitted use, and task quality separately. Record which duplicates were removed and why, including effects on task and language distributions rather than silently letting a large source dominate the remaining mix.

G(xi)=G(xj)⟹split⁡(xi)=split⁡(xj)G(x_i)=G(x_j)\Longrightarrow\operatorname{split}(x_i)=\operatorname{split}(x_j)
G is a declared related-record group identifier. This invariant prevents a group from crossing train/validation/test under the chosen grouping rule;it does not prove unrelated groups share no latent or pretraining overlap.↔ Scroll wide equations horizontally.

Split on the unit that can leak

A conversation-level split keeps turns from the same conversation together. A source-document split keeps derived questions and answers together. A template-family or task split can measure a broader generalization goal. The right unit depends on the claim: new rows from known tasks are different from unseen task families. Keep validation for model and hyperparameter selection and preserve a final test for the stated use, with an audit trail of any later contamination discoveries.

Avoid using test labels to decide cleaning thresholds and then reporting the same test as untouched evidence. Contamination checking may legitimately identify overlap, but its policy and disposition should be documented. Related groups can have unequal sizes, so a target proportion of groups does not necessarily produce the same proportion of rows or tokens. Report all three counts and the resulting task balance. Downstream loss normalization can amplify any remaining long or frequently repeated group.

Pcross=1−pk−(1−p)kP_{\rm cross}=1-p^k-(1-p)^k
For one k-row group whose rows are independently assigned to train with probability p and test otherwise, this is the probability it spans both splits. It does not apply unchanged to a fixed-size global allocation or a group-aware split.↔ Scroll wide equations horizontally.

Inspect leakage at token and source levels

Run exact and chosen near-duplicate checks across split boundaries after formatting, while also checking original source and conversation IDs. A template that injects an answer into the prompt can leak within an individual example even when group IDs are disjoint. Evaluate deduplication samples manually for false merges and missed variants. Retain reproducible hashes and rules without publishing sensitive contents. A clean split is evidence for a stated boundary, not permission to claim universal unseen-task performance.

The probability lab can show the row-assignment assumption. Reset and set both p=0.8, n=10, then predict mean eight rows in train. Counts zero and ten mean the group stayed in one split;interior bars mean it crossed. The exact binomial model assumes independent row assignment, not a fixed 80/20 quota, and Play highlights outcomes rather than splitting data. It does not perform text deduplication or semantic grouping;use it to explain why related records should be assigned together when that matches the evaluation goal.

A ten-variant group leaks under independent row assignment

A source produces ten related variants. Each row is independently assigned to train with probability 0.8 and test with probability 0.2. Calculate the chance that this group appears in both.

  1. All ten land in train with probability 0.8¹⁰=0.1073741824. All ten land in test with probability 0.2¹⁰=0.0000001024.

  2. Subtract those two single-split cases from one:1−0.1073741824−0.0000001024=0.8926257152, or about 89.26% crossing probability.

  3. Assigning the group as one unit prevents this within-group crossing by construction. It still requires a valid grouping rule and does not remove unknown overlap from another source or the base model's pretraining.

The result

Independent row randomness can make related-content leakage likely. The split unit must match the generalization claim.

Explore the model

Interactive lab

Interactive lab · probability

Interior counts reveal a split group

Reset, set p=0.8, n=10;predict mean 8. Exact counts 1 through 9 represent a related group crossing an independent row split;0 or 10 do not. This is not a deduplication tool or an exact fixed-quota split model.

Interior counts reveal a split groupThese are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Current readings: Mean · np: 5; Variance · np(1−p): 2.5; Total probability: 1. All parameters are adjustable with the labeled controls below.03581000.070.150.220.3Successes kP(X = k)k = 0 · P = 9.77e-4
Exact probabilityHighlighted outcomeMean np
Mean · np
5
Variance · np(1−p)
2.5
Total probability
1
t = 0 s

These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forGroup-aware assignment addresses a different issue from shuffling individual records.

Check your understanding

Ten paraphrases come from one source instruction. Which split policy directly prevents those paraphrases from appearing on both sides?

Try it yourself

One hundred source groups each contain ten rows. A group-aware split assigns eighty groups to train and twenty to test. Count rows in each split and explain what changes if group sizes differ.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

The equal-size premise makes group and row percentages coincide only in this example.

Compare with the solution

Training has 80×10=800 rows and test 20×10=200, with no group crossing under the rule. If groups differ in size, the same 80/20 group counts can yield different row and token fractions. Report those effective weights and task composition rather than calling the split balanced solely from its group percentage.

Take it with you

  • Exact deduplication, semantic relatedness, and provenance grouping are distinct.
  • Split at the unit that matches the generalization claim.
  • A clean declared boundary does not prove absence of every pretraining or hidden overlap.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.