Design Test Cases for a Deduplication Function That Catch Both Missed Duplicates and False Merges
Design a test set for a function that decides whether two records or text snippets are duplicates, so that both missed duplicates and wrong merges are caught.
The function:
<code>
{{PASTE THE MATCHING / DEDUP / NORMALIZATION FUNCTION}}
</code>
What the records are: {{e.g. customer records, retrieved document chunks, product listings, support tickets}}
What happens on a match: {{e.g. records are merged permanently, one chunk is dropped from an LLM prompt, a warning is shown}}
Which mistake is worse here: {{a missed duplicate, or a false merge, and why}}
Produce test cases in four groups, as a table with columns: id, input A, input B, expected (match / no match), and why this case matters.
1. True duplicates that should match: differences only in case, whitespace, punctuation, Unicode forms (composed vs decomposed accents, non-breaking spaces, zero-width characters), encoding artifacts and field order.
2. Near-misses that must NOT match: pairs that differ in one meaningful token, such as a number, date, negation ("not"), version, unit or name. These are the cases normalization most often destroys.
3. Boundary cases: empty strings, very short inputs, very long inputs, inputs that are identical except for trailing content, and inputs that only match after the normalization step.
4. Property checks: symmetry (match(A, B) equals match(B, A)), idempotent normalization (normalize(normalize(x)) equals normalize(x)), and, if the function produces groups, whether matching is transitive or whether A~B and B~C can merge A and C unintentionally.
Then point out any step in the given function that would cause a group 2 case to falsely match, and name the case. Keep the set small enough to maintain: about 20-30 cases, weighted toward the mistake I said is worse.
---
When to use it: before shipping or changing deduplication, record linkage or text normalization, including RAG pipelines that drop repeated chunks. Normalization that strips punctuation or digits can quietly merge "refunds within 30 days" and "refunds within 3 days"; this prompt pushes the test set toward exactly those pairs.
How to adapt it: state what a match causes. A false merge in customer records may be irreversible and deserves heavy weighting; dropping a redundant chunk from a prompt is cheaper. For similarity-threshold matchers, ask for pairs just above and below the threshold as well.
Example input: a Python function that lowercases text, removes all non-alphanumeric characters and compares SHA-256 hashes, used to drop duplicate chunks before an LLM call.
What good output looks like: a table with cases such as "Plan: Pro" vs "plan pro" (match), "v2.1" vs "v21" (should not match, but this function will merge them because it strips the dot), "isn't eligible" vs "isnt eligible" (match), and an empty-string pair. It flags the dot-stripping step as the cause of the false merge and proposes keeping digits and dots, or comparing on a gentler normalization.
Sign in to upvote this prompt.