MLCrack

    ML SYSTEM DESIGN & MLOPS · INTERVIEW QUESTION

    Outline the data pipeline for training an LLM from raw text to training batches.

    🔴 advanced · ML Pipelines

    Hint: Collection → cleaning → deduplication → tokenization → batching.

    Answer

    LLM data pipeline stages:

    1. Data Collection: crawl web (Common Crawl), scrape, license datasets (books, academic papers, code).

    2. Quality Filtering: remove low-quality text (boilerplate, spam, non-natural language), filter by language, apply classifier-based quality scoring (e.g., train a model to distinguish Wikipedia-quality text from random web text).

    3. Deduplication: exact dedup (hash matching), near-dedup (MinHash/LSH). Removes ~30-50% of web data. Critical for preventing memorization.

    4. PII Removal: detect and remove personal information (emails, phone numbers, addresses).

    5. Tokenization: apply trained tokenizer (BPE/SentencePiece).

    6. Packing & Batching: concatenate documents with separator tokens, pack into fixed-length sequences, create attention masks.

    7. Data Mixing: balance proportions from different sources (code, books, web, academic).

    8. Curriculum: optionally order data by complexity.

    9. Sharding: distribute across GPUs/nodes.

    Tools: datasets (HuggingFace), RedPajama, Dolma pipeline. Data quality is the single most impactful factor in LLM training.