Pre-Training Data Curation at Trillion-Token Scale: Comparing Datatrove, NeMo Curator, and Data-Juicer 2.0

Preparing multi-trillion-token corpora for foundation model pre-training has become one of the most resource-intensive infrastructure challenges in modern artificial intelligence. While distributed training frameworks like Megatron-LM and TorchTitan have standardized model parallelism across GPU clusters, the upstream data engineering stack often remains fragmented across ad-hoc scripts, unoptimized Spark jobs, and brittle bash wrappers. Raw web dumps from Common Crawl contain massive quantitie

8 min
Pre-Training Data Curation at Trillion-Token Scale: Comparing Datatrove, NeMo Curator, and Data-Juicer 2.0

Preparing multi-trillion-token corpora for foundation model pre-training has become one of the most resource-intensive infrastructure challenges in modern artificial intelligence. While distributed training frameworks like Megatron-LM and TorchTitan have standardized model parallelism across GPU clusters, the upstream data engineering stack often remains fragmented across ad-hoc scripts, unoptimized Spark jobs, and brittle bash wrappers.

Raw web dumps from Common Crawl contain massive quantities of boilerplate, machine-translated spam, toxic content, personal identifiable information (PII), and duplicated text. Processing petabytes of raw WARC archives into clean token streams requires multi-stage filtration pipelines covering text extraction, heuristic filtering, language identification, exact and fuzzy deduplication, classifier scoring, and benchmark decontamination.

Three primary open-source frameworks have emerged to handle pre-training data curation at scale: Hugging Face Datatrove, NVIDIA NeMo Curator, and Alibaba Data-Juicer 2.0. Each represents a fundamentally distinct architectural approach to distributed computing, hardware acceleration, and data modeling.

Data Curation Pipeline Architectures

Architectural Philosophies

The design differences among Datatrove, NeMo Curator, and Data-Juicer reflect their underlying compute assumptions and target infrastructures.

1. Hugging Face Datatrove: CPU-First Streaming on Slurm

Datatrove was engineered by Hugging Face to process the 15-trillion-token FineWeb and FineWeb-2 datasets. Its core design philosophy centers on lightweight, platform-agnostic streaming with minimal operational overhead.

  • Execution Model: Pure Python pipeline blocks executed via standard multiprocessing on single nodes or orchestrators like Slurm on large high-performance computing (HPC) clusters.
  • Memory Strategy: Datatrove avoids holding massive datasets in shared memory. Instead, it streams records through generator pipelines, enforcing strict per-task memory limits (typically 2 GB to 4 GB per CPU core).
  • Native Extensions: Critical performance bottlenecks, such as 64-bit hashing for MinHash generation, are written in compiled Rust modules (such as fast_mh3) to bypass Python interpreter overhead.
  • Storage Abstraction: Built on fsspec, allowing unified, zero-copy streaming directly from S3, Hugging Face Hub buckets, or local POSIX filesystems without requiring intermediate database systems.

2. NVIDIA NeMo Curator: GPU-Accelerated Pipelines with RAPIDS and Dask

NeMo Curator is NVIDIA's dedicated framework for foundation model data preparation, powering the 8-trillion-token dataset behind the Nemotron model family.

  • Execution Model: Distributed execution powered by Dask and accelerated via RAPIDS cuDF and cuML. Tasks are scheduled across GPU clusters to parallelize heavy string manipulation, table joins, and matrix operations.
  • Hardware Offloading: Heavy algorithmic steps—including document-level MD5 hashing, MinHash Locality Sensitive Hashing (LSH), and semantic embedding clustering—are offloaded directly to GPU CUDA cores and Tensor Cores.
  • Multimodal and Post-Training: Beyond pre-training text, NeMo Curator integrates PyTorch-based inference models for aesthetic scoring, synthetic data generation, and semantic deduplication across image and video assets.

3. Alibaba Data-Juicer 2.0: Composable Multi-Modal Operators on Ray and Spark

Data-Juicer 2.0 was introduced by Alibaba as a cloud-scale data processing system spanning both pre-training and post-training data lifecycles.

  • Execution Model: Built on top of distributed compute engines like Ray and Apache Spark, Data-Juicer implements a library of over 100 modular Operators (OPs).
  • Lineage and Divergence Tracking: Data-Juicer features automated statistical analysis between pipeline stages. It tracks metric deviations (such as sudden shifts in text length or token entropy) across consecutive transformations to identify unintended data corruption or excessive filtering.
  • Modality Unification: Operates across text, image, audio, and video modalities within a single declarative configuration file.

Core Pipeline Stages: Implementation and Mechanics

+-----------------------------------------------------------------------------------+
|                           PRE-TRAINING DATA CURATION PIPELINE                     |
+-----------------------------------------------------------------------------------+
|  [Raw WARC / JSONL]                                                               |
|          |                                                                        |
|          v                                                                        |
|  [Stage 1: Text Extraction & Normalization]                                       |
|  - Trafilatura / Resiliparse / Unicode normalization / Regex cleanup              |
|          |                                                                        |
|          v                                                                        |
|  [Stage 2: Heuristic & Quality Filtering]                                         |
|  - Gopher repetition filters / C4 heuristics / Language ID (FastText)            |
|          |                                                                        |
|          v                                                                        |
|  [Stage 3: Deduplication at Scale]                                                |
|  - Exact (SHA-256 / MD5) -> MinHash LSH (128 hashes) -> Connected Components      |
|          |                                                                        |
|          v                                                                        |
|  [Stage 4: Semantic Scoring & Model-Based Filtering]                             |
|  - FineWeb-Edu classifier / Embedding clustering / Perplexity thresholds          |
|          |                                                                        |
|          v                                                                        |
|  [Stage 5: Decontamination & PII Redaction]                                       |
|  - 13-gram evaluation Bloom filters / Regex & NER redaction                       |
|          |                                                                        |
|          v                                                                        |
|  [Tokenized Shards -> Megatron-LM / TorchTitan]                                   |
+-----------------------------------------------------------------------------------+

1. Document Extraction and Normalization

The first phase converts raw HTML WARC files from web crawls into formatted, readable text.

  • In Datatrove, the Trafilatura or WarcReader blocks parse web pages directly into memory-efficient document dictionaries. It strips boilerplate JavaScript, CSS, and navigation trees while preserving paragraph boundaries.
  • In NeMo Curator, document extraction leverages distributed Dask workers running parallel Python extractors, converting raw web dumps into Parquet shards stored on distributed object storage.
  • In Data-Juicer 2.0, format-specific formatter OPs handle encoding normalization, character set unification (FTFY), and structure preservation across HTML, PDF, and Markdown sources.

2. Heuristic and Rule-Based Quality Filtering

Heuristic filtering removes low-quality machine-generated text, SEO link spam, and corrupted strings using deterministic rules:

  • Character-Level and Word-Level Rules: Datatrove includes prebuilt implementations of Gopher quality filters (e.g., words per document between 50 and 100,000, mean word length between 3 and 10 characters, symbol-to-word ratios under 0.1) and C4 filters (removing lines ending without terminal punctuation).
  • Repetition Detection: Checks identify duplicate n-grams, repetitive line patterns, and looped sentences (e.g., top 4-gram character ratio < 0.3).
  • Language Filtering: FastText language identification models discard documents failing a confidence threshold (typically probability > 0.65 for the target language).
# Datatrove Pipeline Definition Example
from datatrove.executor.slurm import SlurmPipelineExecutor
from datatrove.pipeline.readers import JsonlReader
from datatrove.pipeline.filters import (
    GopherQualityFilter,
    GopherRepetitionFilter,
    LanguageFilter,
    C4QualityFilter,
)
from datatrove.pipeline.writers.jsonl import JsonlWriter

pipeline = [
    JsonlReader("s3://pretraining-data/raw_dumps/"),
    LanguageFilter(languages=["en"], language_threshold=0.65),
    GopherQualityFilter(min_doc_words=50, max_doc_words=100000),
    GopherRepetitionFilter(
        dup_line_frac=0.3,
        dup_para_frac=0.3,
        dup_line_char_frac=0.2,
    ),
    C4QualityFilter(),
    JsonlWriter("s3://pretraining-data/filtered_dumps/"),
]

executor = SlurmPipelineExecutor(
    pipeline=pipeline,
    tasks=1000,
    cpus_per_task=2,
    mem_per_cpu_gb=4,
    time="08:00:00",
    logging_dir="s3://pretraining-data/logs/",
)
executor.run()

3. Exact and Fuzzy Deduplication

Deduplication is the most computationally expensive stage of pre-training curation. Redundant documents consume precious training FLOPs and encourage memorization.

Deduplication occurs in three distinct tiers:

  1. Exact Document Deduplication: Hashing the full document text using 64-bit or 128-bit hashes (MD5, SHA-256, or xxHash).
  2. Fuzzy Near-Duplicate Detection (MinHash LSH):
  • Documents are tokenized into character or word n-grams (typically 5-grams or 13-grams).
  • A set of KK independent hash functions (usually K=128K = 128) computes the minimum hash value across all n-grams in the document, forming a MinHash signature.
  • The signatures are divided into bb bands of rr rows (K=b×rK = b \times r). Documents colliding within any single band are flagged as candidate duplicate pairs.
  • Candidate pairs are verified against a Jaccard similarity threshold (typically 0.70 to 0.85), followed by connected-component clustering to keep only one canonical document per cluster.
  1. Semantic Deduplication (SemDeDup):
  • Documents are encoded into dense vectors using small embedding models.
  • High-dimensional k-means clustering groups semantically related documents, and pairwise cosine similarity pruning removes documents with cosine similarity exceeding 0.90.
# NeMo Curator GPU-Accelerated MinHash LSH Example
from nemo_curator import ExactDuplicates, MinHashDeduplicator
from nemo_curator.datasets import DocumentDataset
from dask.distributed import Client

client = Client("tcp://dask-scheduler:8786")

dataset = DocumentDataset.read_parquet(
    "s3://pretraining-data/filtered_parquet/",
    backend="cudf",
)

# Step 1: Exact deduplication via GPU cuDF
exact_dedup = ExactDuplicates(id_field="doc_id", text_field="text")
exact_clean = exact_dedup(dataset)

# Step 2: GPU-accelerated MinHash LSH (128 permutation hashes)
minhash_dedup = MinHashDeduplicator(
    id_field="doc_id",
    text_field="text",
    num_hashes=128,
    num_bands=16,
    jaccard_threshold=0.80,
    ngram_size=5,
)
fuzzy_clean = minhash_dedup(exact_clean)
fuzzy_clean.to_parquet("s3://pretraining-data/deduped_parquet/")

4. Classifier Annotation and Synthetic Quality Scoring

In modern pipelines like FineWeb-Edu and Nemotron-4, simple heuristic filters are augmented with machine learning quality classifiers:

  • Small Model Scoring: FineWeb-Edu trains a classifier on top of Snowflake-Arctic-Embed or Llama-3-8B annotations to score web pages from 0 to 5 on educational value.
  • Token Thresholding: Documents scoring below an educational threshold (e.g., score < 3) are filtered out, drastically improving downstream reasoning and mathematical performance in trained LLMs.
  • Batch Execution: Datatrove uses batched PyTorch inference blocks on CPU or small GPU worker pools, whereas NeMo Curator executes TensorRT-accelerated inference across dedicated GPU nodes.

5. Benchmark Decontamination and PII Redaction

To prevent test-set leakage, curation frameworks screen corpora against downstream benchmark evaluation suites (e.g., MMLU, GSM8K, HumanEval, ARC):

  • 13-Gram Bloom Filters: A Bloom filter is constructed from all 13-grams present in benchmark evaluation datasets. Any training document exhibiting 10 or more overlapping 13-grams is flagged and removed.
  • PII Scrubbing: Regex patterns and named entity recognition (NER) models redact social security numbers, phone numbers, IP addresses, and private email addresses.

Technical Comparison Matrix

| Dimension | Hugging Face Datatrove | NVIDIA NeMo Curator | Alibaba Data-Juicer 2.0 | | :--- | :--- | :--- | :--- | | Primary Backend | CPU (Multiprocessing / Slurm) + Rust | GPU (RAPIDS cuDF, cuML) + Dask | Ray / Apache Spark / PyTorch | | Primary Language | Python + Rust (fast_mh3) | Python + CUDA C++ | Python + C++ | | Hardware Target | CPU Clusters (HPC / Cloud spot nodes) | GPU Clusters (A100 / H100 / Grace Hopper) | Heterogeneous (CPU, GPU, Cloud Ray) | | Scale Provenance | 15T+ tokens (FineWeb, FineWeb-2) | 8T+ tokens (Nemotron-4 340B) | Multi-modal & LLM Pre/Post-training | | Deduplication Stack | Fast MinHash LSH (Rust/C), Exact sub-string | cuDF GPU Exact, cuML MinHash LSH, SemDeDup | MinHash LSH, BitHash, SemDeDup OPs | | Memory Footprint | Extremely low (streaming generators, 2-4GB/core) | Medium-High (GPU VRAM + Dask distributed RAM) | Medium (Ray/Spark partition overhead) | | Supported Modalities | Text (primary), Code | Text, Multimodal (Image/Video classifiers) | Text, Code, Image, Video, Audio | | Lineage & Diagnostics | Task logging and stage counters | Dask Dashboard + WandB | Automated OP Metric Divergence Analyzer | | Storage Connectors | fsspec (S3, HF Hub, GCS, Local POSIX) | Parquet, JSONL, S3, POSIX | Parquet, JSONL, HDFS, S3, OSS |


Performance, Infrastructure Economics, and Trade-Offs

Choosing the right data curation framework involves evaluating available hardware, cluster orchestrators, and budget constraints.

1. Throughput and Acceleration

NVIDIA's benchmarks demonstrate that running MinHash LSH across 100 billion tokens takes multiple days on a standard 96-core CPU server. By offloading token shingling, hash computation, and band sorting to cuDF on an 8x H100 node, NeMo Curator completes the same processing in several hours.

However, GPU memory constraints (VRAM capacity) introduce strict batch-sizing requirements. If document lengths exceed anticipated limits or large document clusters cause memory spikes during connected-component joins, Dask workers can trigger out-of-memory (OOM) errors.

2. Cost Economics: Spot CPU vs. Reserved GPU

While GPU processing delivers higher wall-clock speed, CPU-based processing using Datatrove is often more cost-effective on standard cloud infrastructure:

  • Datatrove runs comfortably on low-cost spot CPU instances or existing HPC Slurm clusters that do not have GPU allocations. Because its memory footprint per worker is predictable (2 GB to 4 GB per core), jobs can be scaled across thousands of spot cores with minimal risk of eviction cascades.
  • NeMo Curator is most cost-effective when high-end GPU clusters (A100/H100) are already provisioned and sitting idle between training runs, allowing teams to saturate GPU memory bandwidth for rapid data prep.

3. Operational Complexity

  • Datatrove has virtually no heavy distributed infrastructure dependencies. It requires no Spark master nodes, no Ray daemon management, and no Dask cluster coordination—simply a Python virtual environment with Slurm or local multiprocessing.
  • NeMo Curator requires a functional Dask-CUDA cluster, correct RAPIDS/cuDF driver matching, and high-bandwidth interconnects (InfiniBand or RoCE) to prevent Dask shuffle operations from stalling.
  • Data-Juicer requires configuring Ray or Spark runtime environments, but provides an extensive suite of pre-built operators and lineage inspection tools.

Engineering Decision Framework

When selecting a framework for pre-training data curation:

  1. Choose Hugging Face Datatrove if:
  • Your compute infrastructure consists primarily of CPU instances, HPC Slurm clusters, or spot virtual machines.
  • You want to reproduce or extend the FineWeb / FineWeb-Edu pipeline with minimal configuration.
  • You prioritize memory predictability, low dependency overhead, and direct streaming from S3 or Hugging Face Hub.
  1. Choose NVIDIA NeMo Curator if:
  • You have dedicated GPU infrastructure (e.g., A100 or H100 clusters) available for data processing.
  • You need the highest possible wall-clock throughput for trillion-token MinHash LSH and exact deduplication.
  • You plan to apply dense embedding-based semantic deduplication (SemDeDup) and GPU-accelerated synthetic classifiers.
  1. Choose Alibaba Data-Juicer 2.0 if:
  • Your pipeline processes multimodal data (text alongside images, video, or audio).
  • Your team relies on Ray or Apache Spark as the standard enterprise data platform.
  • You need detailed lineage tracking and automated statistical divergence analysis across complex DAG transformations.

Sources

Written by

More to read

  • Maximal Update Parametrization (muP): How Tensor Programs Enable Zero-Shot Hyperparameter Transfer in LLM Pre-Training

    Pre-training a frontier large language model requires hundreds of thousands of GPU hours and millions of dollars in compute. At that scale, traditional hyperparameter tuning is financially and operationally impossible: teams cannot sweep learning rates, weight initializations, or optimizer betas across multiple 70B parameter runs to find the loss minimum. Historically, practitioners relied on ad-hoc heuristic extrapolation or manual guesses from small runs, often leading to sub-optimal loss curv

    1 min
  • Apple Music Mandates AI Transparency Tags Across Tracks, Compositions, and Artwork

    Apple Music has notified record labels and distribution partners that it is introducing mandatory AI transparency tags across its ingestion pipeline, establishing visible indicators for synthetic audio and visual assets later this year. Under the updated ingestion specifications, content providers must declare when artificial intelligence tools have been used to generate a material portion of a release. Four-Tier Metadata Taxonomy The framework establishes distinct metadata flags across four

    1 min
  • OpenAI Gains on Anthropic in Corporate AI Spending, Ramp Data Shows

    Corporate card and spend-management platform Ramp released updated enterprise purchasing data indicating that OpenAI is growing faster than Anthropic among US businesses in the third quarter of 2026, closing the gap after losing the top spot earlier in the year. The metrics, compiled from transaction data across more than 70,000 businesses using Ramp corporate cards and invoice processing, highlight ongoing volatility in enterprise model selection. Market Share Trajectory and Model Drivers A

    1 min