Design a Duplicate Event Detector
Understanding the Problem
👯 What is a duplicate event detector? On a social network, the same real-world event often gets created several times: the venue posts the concert, the promoter posts it, the band posts it, a ticket reseller imports it, and a fan creates one for their friends. Each copy has a different title, description, photo and RSVP list. A duplicate event detector finds the copies that describe the same happening, groups them, and lets the product treat them as one: show it once in recommendations, combine attendance, or offer hosts a merge.
This is a classic entity resolution problem (also called record linkage or deduplication). The same structure applies to duplicate products in a catalog, duplicate business listings on a map, or duplicate people in a CRM: generate candidate pairs cheaply (blocking), decide whether each pair matches (matching), and turn pair decisions into groups (clustering). We'll design it for Facebook-style events and point out where the event domain is tricky, especially recurring events and different events at the same venue, which look like duplicates and aren't.
Functional Requirements
Core Requirements
- When an event is created or edited, the system should find existing events that are likely the same real-world event.
- The system should group duplicates into a cluster with one canonical event, so recommendations and search show the event once.
- Hosts should be offered a merge or link when we're confident, and creators should see "this event may already exist" while creating one.
- Users should be able to report duplicates, and reviewers should be able to confirm or split clusters, with every action reversible.
Below the line (out of scope)
- Detecting fake or scam events (closer to content moderation and spam detection).
- Predicting attendance (see event attendance prediction), although merging changes its inputs.
- Deduplicating private events. Private events are only visible to invitees, and two private events with the same title are almost always different gatherings, so we only resolve public events.
Non-Functional Requirements
Assumptions to confirm: 20 million upcoming public events at any time and about 1 million new or edited events a day (about 12 per second on average, 100 per second at peak, for example when ticketing partners bulk-import a festival season). Suppose roughly 5-10% of public events have at least one duplicate, much higher for big concerts and festivals.
Core Requirements
- The "may already exist" suggestion during creation should return within 300 ms.
- New events should be resolved (added to a cluster or confirmed unique) within a few minutes of creation, before they're widely recommended.
- Precision over recall for merges. Wrongly merging two different events (two shows on the same night at the same venue) moves RSVPs to the wrong event and angers hosts. Missing a duplicate just shows it twice. We target over 99% precision for automatic linking and higher for anything that changes a host's event.
- Every grouping decision should be reversible and explainable ("same ticket link, same poster, starts at the same time").
Below the line (out of scope)
- Cross-platform dedup against other sites' listings, beyond using ticket URLs as a feature.
The arithmetic that defines the problem: comparing all pairs of 20 million events is about 2 × 10^14 comparisons, which is impossible even with a very cheap model. If blocking narrows each new event to about 50 candidates, a million new events a day is 50 million pair scores, about 600 per second, which a GBDT handles on a few CPU cores. A heavier cross-encoder on the top 5 candidates per event is 5 million inferences a day, about 60 per second, which is a single GPU. So the design is mostly about blocking recall: a duplicate that never becomes a candidate can't be found, no matter how good the matcher is.
Name the three stages up front: blocking, matching, clustering. Interviewers often follow that structure, and it shows you recognize entity resolution as a known problem with known tools instead of "just compute similarity."
Framing It as an ML Problem
ML Objective
The business wants fewer duplicate events shown to users (measured by rater-sampled duplicate rate in Events recommendations and search) and fewer split audiences (RSVPs scattered over copies), with wrong merges near zero (measured by host and user reports, and reviewer audits).
The model learns P(same real-world event | event A, event B), a calibrated pairwise match probability. Clustering then turns these into groups. Actions use thresholds on the pair probability and on cluster-level confidence.
Inputs and Outputs
- Input: a pair of events, each with title, description, start and end time, time zone, place (venue ID or address and coordinates), host and co-hosts, category, cover image, ticket URL, language, and creation source (created in app, imported by a ticketing partner, created by a page).
- Output: a match probability per pair and an explanation (top contributing features). After clustering: a cluster ID per event, a canonical event per cluster, and a cluster confidence.
Choosing the ML Approach
Binary classification on pairs, preceded by candidate retrieval (blocking) and followed by graph clustering. Pairwise classification fits because "duplicate" is a relationship, not a property of one event. We could also frame it as metric learning (learn an embedding where duplicates are close) and use only nearest-neighbor distance, but distance alone can't easily express hard rules like "same title, different dates is a series, not a duplicate." So the embedding is used for retrieval and as one feature, while a pairwise model makes the call.
Data and Labels
The data is the events table (with full edit history), places, pages and hosts, ticketing partner imports, cover images in blob storage, and user and host actions on events.
Labels come from several places:
- Human-labeled pairs. Raters see two events side by side and answer "same event / different / unsure," with guidelines for the edge cases (series, festivals with many sub-events, a watch party for a sports game vs the game itself). The main source, especially for hard cases.
- Host actions. A host who accepts a "merge with this event?" suggestion gives a positive; one who rejects it gives a strong negative. A host who deletes their event right after seeing "this event may already exist" is a weak positive.
- User reports of duplicates. Noisy, but useful for finding missed pairs.
- Strong rule-based positives. Two events with the same ticket URL and same start time, or the same partner event ID imported twice, are near-certain duplicates. Useful as extra positives, but they're the easy cases, so they shouldn't dominate training.
- Hard negatives by construction. Consecutive instances of a recurring series (same title, same venue, different week), different events at the same venue on the same night, and sub-events of a festival. These are generated from the data and confirmed by raters, and they're the most important negatives we have.
Sampling. Label candidate pairs from the blocking stage, not random pairs. Random pairs are almost all obviously different and teach the model nothing. Among blocked candidates, perhaps 2-5% are duplicates. We oversample pairs the current model is unsure about (active learning) and keep a random sample of blocked candidates for unbiased evaluation.
Leakage. If events are later merged, the merged record's fields may have been copied between them. Build features from each event's state at the time of the decision, using the edit history, not from the merged result. And split train and test by cluster, so the three copies of one concert don't appear in both.
Feature Engineering
Most features are pairwise similarities, computed on the fly for each candidate pair from per-event attributes.
Text similarity
- Title: normalized edit distance, token Jaccard, character n-gram TF-IDF cosine. Normalize first (lowercase, strip emojis, remove boilerplate like "LIVE!", "Official", "18+").
- Description: MinHash Jaccard on shingles (promoters often paste the same text), embedding cosine for paraphrases.
- Performer and entity overlap: named entities (artists, teams, speakers) extracted from both, and their overlap. Two events that both mention the same headliner at the same venue on the same night are almost surely the same.
- Multilingual: a title in Spanish and one in English for the same festival match on embeddings and entities, not on string distance.
Time
- Absolute difference between start times (in UTC, after time-zone normalization), overlap of the time ranges, whether one is contained in the other (a festival contains its sub-events).
- Same calendar date or not; day-of-week match.
Place
- Same place ID; distance between coordinates; address string similarity when there's no place ID; whether one event's location is just a city ("Austin, TX") and the other's a venue in that city.
Host and source
- Same host, co-host overlap, whether one host is the venue's page and the other the performer's page (a common duplicate pattern), whether either came from a ticketing partner, same partner event ID.
Image
- Perceptual hash distance between cover images (PDQ, pHash), since promoters reuse the same poster, and embedding cosine for crops and resized versions.
Links
- Same ticket URL (after normalizing tracking parameters), same domain, same external event ID. Among the strongest signals when present.
Series and context features (for hard negatives)
- Whether either event belongs to a recurring series, the number of events at this venue on this date, the number of events by this host with a similar title in the last 60 days. These let the model learn "same title, same venue, different week" is a series.
Embeddings. Each event gets a multimodal embedding (title, description, place and time bucket encoded with a text encoder, plus a CLIP-style image embedding of the cover, fused into one vector). It's computed once when the event is created or edited, stored in the event's feature record, and indexed for retrieval. Cosine similarity of the two embeddings is also a pair feature.
Real-time vs batch. Per-event attributes, embeddings and hashes are computed at creation and edit time (seconds). Context features like "events at this venue tonight" update continuously from the event stream. Pair features are computed on demand during matching, so there's no huge precomputed pair table; per-event inputs live in an online store keyed by event ID.
Modeling
Bad Solution: Exact Key Matching
Approach
Treat events with the same normalized title, same start time and same venue as duplicates.
Challenges
Real duplicates rarely match exactly: "The Midnight Owls | World Tour" vs "Midnight Owls World Tour - Night 2," a start time of 7:00 vs 8:00 (doors vs show), the venue picked from the place list vs typed as an address. Recall is terrible. And it can still be wrong: two events with the generic title "Open Mic Night" at the same bar at the same time could be legitimately duplicated by two hosts, or a data entry error.
Good Solution: Blocking Plus a GBDT on Similarity Features
Approach
- Blocking: for each new event, retrieve candidates sharing a geo cell (geohash at roughly 5 km, plus neighboring cells) and overlapping a ±2-day time window, plus anything with the same ticket URL or partner ID.
- Matching: a GBDT (LightGBM or XGBoost) on the pairwise features above, outputting a calibrated match probability.
- Thresholds: link above a high threshold, send a middle band to review or to host suggestions.
Challenges
Geo-and-time blocking misses duplicates where the location is vague ("Online," a city name only, a wrong pin) or the time was entered wrong (time zone mistakes are common). Hand-built text similarity struggles with paraphrases and other languages. And independent pair decisions can contradict each other: A matches B, B matches C, but A doesn't match C.
Great Solution: Multi-Key Blocking, a Two-Stage Matcher and Graph Clustering
Approach
- Multi-key blocking, unioned: geo cell × time window; MinHash LSH on normalized title and description shingles; embedding ANN (an HNSW index over event embeddings, filtered to a wide time window); exact keys (ticket URL, partner ID, image hash). Each catches duplicates the others miss. The union is capped at about 50 candidates, ranked by a cheap score.
- Stage 1 matcher: the GBDT over all similarity features scores every candidate (microseconds each).
- Stage 2 matcher: a cross-encoder (a small multilingual transformer that reads both events' title, description, time and place as one sequence) scores the top 5 pairs by GBDT score. It understands "Night 2," "doors 7pm, show 8pm," and translations far better than string features. Its score is fed back into a final GBDT layer with the other features, so structured signals like "different dates" and "same ticket URL" stay decisive.
- Clustering: high-confidence pairs become edges in a graph; clusters are formed with a method that resists chaining (see the deep dive), and each cluster picks a canonical event.
Challenges
More components to maintain, and blocking recall has to be measured continuously, since a change in how users enter locations can silently break a blocking key. The cross-encoder is the expensive part, but because it only sees a few pairs per event it costs one GPU, not a fleet.
Training
Loss. Binary cross-entropy for the GBDT and the cross-encoder. Calibrate the final model with isotonic regression on the held-out random blocked sample, since thresholds drive automatic actions.
Negatives. Easy negatives (different city, different month) are filtered out by blocking and barely matter. The training set should be rich in hard negatives: series instances, same-venue same-night events, festival sub-events, events by the same host with similar titles. We weight them up if the model's false positives concentrate there.
Cross-encoder training. Start from a pretrained multilingual encoder and fine-tune on labeled pairs, using symmetric inputs (train on both (A, B) and (B, A), or average both orders at inference) so the score doesn't depend on order. Synthetic positives help a little: take a real event and perturb it (rewrite the title with an LLM, shift the start by an hour, crop the poster). They must be clearly marked and limited, or the model learns the generator's quirks.
Cadence. Retrain monthly, or when label volume or error analysis justifies it. Duplicate patterns change slowly compared to spam. Embeddings for retrieval are re-indexed when the embedding model changes, which requires re-embedding all upcoming events (20 million, a few hours on GPUs).
Evaluation
Offline Metrics
- Blocking recall (pair completeness): the fraction of known duplicate pairs that blocking returns as candidates, and the reduction ratio (how many comparisons it saves). Blocking recall caps everything downstream, so it's the first number to check.
- Pairwise precision and recall at the link threshold, and PR-AUC, on the random blocked sample. Report precision separately on hard-negative slices (series, same venue same night), where errors concentrate.
- Cluster-level metrics: B-cubed precision and recall, or pairwise F1 over clusters, which penalize a single wrong edge that chains two large clusters together.
- Calibration of the pair probability.
Online Metrics and A/B Testing
- Duplicate rate in Events recommendations and search results, measured by raters on a daily sample.
- Host suggestion acceptance rate and rejection rate: rejections are wrong suggestions, so this is an online precision proxy.
- Wrong-merge reports and reverted links per thousand actions.
- Downstream engagement: RSVPs per impression on recommended events (fewer duplicates should mean more distinct, relevant events in the same slots).
A/B testing works by city or region rather than by user, because a cluster is shared by everyone. Treatment regions use the new model's clusters for deduplicating recommendations; compare duplicate rate and engagement. Changes that affect hosts' events (auto-linking) roll out to a small set of regions first, with reviewers auditing a sample of every action.
Serving
Two online paths and one batch path.
Creation-time suggestion (300 ms budget). While a host fills in the event form, the client sends the draft (title, time, place). The Dedup Service runs a lightweight version: embedding the draft with the text encoder (10-20 ms on CPU), ANN lookup plus geo-time blocking (20-30 ms), Stage 1 GBDT on the candidates (a few ms), and returns the top matches above a threshold as "This event may already exist." No cross-encoder here; we're only suggesting.
Async resolution on create or edit (minutes). When an event is saved, an event lands on Kafka. A resolution worker:
- Computes the event's embedding, hashes and normalized fields, and writes them to the event feature store and the ANN index.
- Runs full blocking (all keys) for about 50 candidates.
- Scores them with the GBDT, then the cross-encoder (on a GPU inference service such as Triton) for the top 5.
- Updates the match graph: adds edges above the edge threshold, and re-clusters the affected component.
- Writes cluster ID and canonical event to a cluster store that recommendations and search read to collapse duplicates, and queues host suggestions or reviews for mid-confidence matches.
Edits matter: a host changing the date or venue can create or break a duplicate relationship, so edits to time, place, title or ticket URL trigger re-resolution, and edges that no longer hold are removed.
Nightly batch re-resolution. A Spark job re-blocks and re-scores all upcoming events, which catches pairs missed by incremental updates (for example, when a third copy bridges two earlier ones) and keeps the clusters consistent. 20 million events × 50 candidates is a billion GBDT scores; at around 10 microseconds each that's about 3 core-hours, small for a Spark cluster.
Index sizing. 20 million event embeddings at 256 dimensions in float16 is about 10 GB, which fits in memory on a small HNSW cluster (or a managed vector database), with time-window filtering at query time.
Potential Deep Dives
1) How do we generate candidates without comparing every pair?
Bad Solution: Geo and Time Blocking Only
Approach
Index events by geohash and date; candidates are events in the same or neighboring cells within ±2 days.
Challenges
Duplicates with a wrong pin, a city-level location, "online," or a time-zone error never meet. Busy cells (Manhattan on a Saturday night, a festival weekend) produce thousands of candidates, so we have to truncate, which drops true matches at random.
Good Solution: Multiple Blocking Keys, Unioned
Approach
Add MinHash LSH on title and description (tolerates rewording and small typos) and exact keys (ticket URL, partner ID, image hash). Each key is a separate retrieval; the union is the candidate set. In busy cells, rank candidates by a cheap similarity before truncating.
Challenges
LSH on text still misses paraphrases and translations, and tuning bands and rows for MinHash is a recall-vs-cost trade-off that needs measuring.
Great Solution: Add Embedding ANN, and Measure Blocking Recall
Approach
Add an ANN lookup on the multimodal event embedding with a wide time filter (±7 days, to catch time-zone and date mistakes). Then measure blocking recall per key on labeled duplicate pairs: what fraction each key finds alone, and what the union finds. Keep keys that add unique recall and drop those that don't. Set the per-event candidate cap by plotting recall vs cap.
Challenges
The embedding index has to be updated within seconds of event creation, or two copies created minutes apart (very common for a newly announced concert) won't find each other. Use an index that supports real-time inserts (HNSW does), and also check the last few minutes of new events with a brute-force scan as a safety net.
2) How do we tell duplicates from recurring events and same-venue events?
This is where most false positives come from:
- Recurring series. "Tuesday Trivia @ The Pub" every week. Same title, venue, host and poster, different dates. The model needs date difference as a feature, and series features (is either event part of a series; how many similar-titled events this host has). Training needs plenty of series pairs labeled as negatives.
- Multi-night runs. A band playing the same venue on Friday and Saturday: two events, often with "Night 1" / "Night 2" or just different dates. Same handling as series; the cross-encoder picks up "Night 2."
- Same venue, same night. A club with two rooms, a stadium hosting a game and a pre-game party, a festival with stage-specific events. Features: number of events at the venue that night, title and performer overlap (low for different events), time-range overlap and containment.
- Parent and child events. A festival and its sub-events are related, not duplicates. Represent "contains" as a separate relationship rather than forcing it into duplicate or not.
When asked about precision, go straight to the hard negatives. "Recurring events and same-venue events" is the answer interviewers are listening for, and naming the features that separate them shows you've thought about the data.
3) How do we turn pair decisions into consistent clusters?
Bad Solution: Connected Components on Every Match
Approach
Add an edge for every pair above the threshold; each connected component is a cluster.
Challenges
Chaining. One wrong edge joins two clusters, and with series events it cascades: week 1 matches week 2 (a false positive), week 2 matches week 3, and soon a whole year of trivia nights is one "event." Connected components are only as good as the single worst edge.
Good Solution: High-Threshold Edges and Constraints
Approach
Only add edges above a high threshold, and enforce cannot-link constraints: two events by the same host on different dates can't be in one cluster; two events whose time ranges don't overlap can't be in one cluster. A merge that would violate a constraint is rejected.
Challenges
Constraints are hand-written and incomplete. High thresholds cut recall: a true third copy that matches each of the other two at 0.8 never joins.
Great Solution: Cluster-Level Scoring
Approach
Use an algorithm that looks at all edges between groups, not just the best one: average-linkage agglomerative clustering on match probabilities, or correlation clustering (which minimizes disagreements: pairs with low probability inside a cluster count against it). In practice: start with high-confidence edges, then merge two clusters only if the average match probability across all cross pairs is high and no cannot-link constraint is violated. Cap cluster size and send unusually large clusters to review. Re-cluster only the affected components on each update, so it's cheap.
Challenges
More computation per update (all cross pairs between two clusters), though clusters are small, usually 2-5 events. Re-clustering can move an event between clusters, which downstream systems must handle (cluster IDs change, so consumers read the cluster store rather than caching IDs forever).
4) What do we do with a cluster once we have one?
Grouping is the model's job; what happens next is a product decision, and the safest action depends on confidence:
- Link (default, reversible). Events stay separate; the cluster store records they're the same. Recommendations and search show only the canonical event; its page can say "also posted by The Venue." No host data changes, so it's safe to do automatically at high precision.
- Suggest merge to hosts. For a cluster with events from different hosts, offer each host "merge into one event with co-hosts?" Their accept or reject is both the action and a label.
- Auto-merge only for the clearest cases with consent built in, like a host who accidentally created the same event twice (same host, same everything, created minutes apart). Even then, keep the original records and a mapping, so a merge can be undone.
Choosing the canonical event: prefer the one created by the venue or the performer's verified page, then the one with a ticket link from a trusted partner, then the one with the most RSVPs, then the earliest. Combining attendance (counting RSVPs from all copies in the canonical event's "going" count) only happens on a real merge, not a link.
5) How do we keep clusters correct as events change?
Events get edited (date moved, venue changed, cancelled), and that can break a duplicate relationship or create one. Any edit to a matching-relevant field (title, time, place, ticket URL, cover image) triggers re-resolution: re-embed, re-block, re-score, and remove edges that no longer hold before re-clustering. Cancelled events leave their clusters. The nightly batch job is the backstop, recomputing all clusters for upcoming events from scratch and diffing against the live cluster store; large unexplained diffs page the team, since they usually mean a broken feature or blocking key rather than a real change in the world.
What is Expected at Each Level?
Mid-level
You should recognize that comparing all pairs is infeasible and propose blocking by location and time, then a pairwise classifier on similarity features (title, time, venue, host). You should know labels come from human raters and that precision matters more than recall because wrong merges are costly. A simple flow that checks new events against candidates and links matches is a good outcome.
Senior
You should structure the solution as blocking, matching and clustering; use several blocking keys including LSH or embedding ANN and measure blocking recall; and identify recurring series and same-venue events as the main hard negatives, with features to separate them. Expect to discuss the transitivity problem, calibrated thresholds for link vs suggest vs review, a creation-time suggestion within a latency budget, and re-resolution on edits.
Staff+
You should drive the system-level choices: blocking recall as the ceiling on everything, a two-stage matcher that spends the expensive model only where it matters, clustering that resists chaining with cannot-link constraints, and reversible product actions chosen by confidence. Expect to cover evaluation at the cluster level, region-based A/B tests, and how the same design generalizes to products, places or people. Strong candidates also note what not to dedupe (private events) and where host consent belongs in the loop.