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:
-
Data Collection: crawl web (Common Crawl), scrape, license datasets (books, academic papers, code).
-
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).
-
Deduplication: exact dedup (hash matching), near-dedup (MinHash/LSH). Removes ~30-50% of web data. Critical for preventing memorization.
-
PII Removal: detect and remove personal information (emails, phone numbers, addresses).
-
Tokenization: apply trained tokenizer (BPE/SentencePiece).
-
Packing & Batching: concatenate documents with separator tokens, pack into fixed-length sequences, create attention masks.
-
Data Mixing: balance proportions from different sources (code, books, web, academic).
-
Curriculum: optionally order data by complexity.
-
Sharding: distribute across GPUs/nodes.
Tools: datasets (HuggingFace), RedPajama, Dolma pipeline. Data quality is the single most impactful factor in LLM training.
Related questions
- What is LLMOps and how does it differ from traditional MLOps?
- What is a feature store? Why is it important for ML systems?
- Explain model parallelism vs data parallelism for training large models.
- How do you handle versioning of LLMs in production?
- Design a real-time ML serving system for a recommendation engine handling 10k QPS.