Design a Near-Duplicate Removal Pipeline for Petabyte-Scale Pretraining Text

Last updated: November 29, 2026

Quick Overview

Design a batch pipeline that finds exact and near-duplicate documents across a multi-petabyte web text corpus and outputs a deduplicated dataset that is reproducible across reruns.

OpenAI
System Design
Machine Learning Engineer
OpenAI
November 29, 2026
Machine Learning Engineer
Onsite
System Design
Hard

0

0

0 solved


Design a batch pipeline that finds exact and near-duplicate documents across a multi-petabyte web text corpus and outputs a deduplicated dataset that is reproducible across reruns.

Pretraining data quality is central to OpenAI's research output, and duplicated text wastes compute and increases memorization. The interviewer wants to see a distributed data pipeline built on sound algorithms (MinHash and LSH), realistic cost estimates, and careful handling of skew.

What the Interviewer Expects
  • Separate exact dedup (hashing) from fuzzy dedup (MinHash plus LSH)
  • Explain how banding parameters set the similarity threshold
  • Turn candidate pairs into clusters with connected components at scale
  • Estimate compute, shuffle size and runtime for billions of documents
  • Make outputs deterministic and incremental as new crawls arrive
  • Handle skew from boilerplate pages that collide with millions of others
Key Topics to Cover
MinHash
locality-sensitive hashing
connected components
Spark
data skew
reproducibility
How to Approach This
  1. Start by clarifying functional and non-functional requirements with the interviewer.
  2. Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
  3. Draw a high-level architecture first, then deep dive into 1-2 critical components.
  4. Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
  5. Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
  • How would you dedupe at the paragraph level instead of the document level?
  • How do you choose which copy in a cluster to keep?
  • How do you avoid removing evaluation benchmark contamination incorrectly, or failing to remove it?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements
  • Input: say 20 billion documents, around 2 PB of text, sharded in object storage (Parquet).
  • Output: same schema with duplicates removed plus a cluster ID mapping for auditing.
  • Near-duplicate defi...
High-Level Design

Stages on a Spark or Ray cluster:

  1. Normalize (lowercase, strip whitespace, Unicode NFC) and compute a SHA-256 for exact dedup; group by hash and keep one.
  2. Shingle and MinHash: 128 permuta...

Submit Your Answer
Markdown supported