How a language model learns.
Follow the 14 stages that transform raw data into a trained, aligned and deployable model. Expand each stage to inspect its subtopics and jump into lessons that already exist in your project.
14 stages · Raw data → deployed model
Each stage has one responsibility in the model creation process.
01Data CollectionGather and identify the source material that will form the training corpus.NEW LESSONS NEEDED›
Gather and identify the source material that will form the training corpus.
- Books and articles
- Websites and documents
- Code repositories
- Licensed datasets
- Human-generated content
- Multilingual datasets
- Data source identification
- Data quality assessment
02Data Cleaning and PreprocessingImprove dataset quality before the content is transformed into model-ready sequences.NEW LESSONS NEEDED›
Improve dataset quality before the content is transformed into model-ready sequences.
- Data filtering
- Duplicate removal
- Noise removal
- HTML and formatting removal
- Text normalization
- Language identification
- Spam filtering
- Toxic content filtering
- Personally identifiable information filtering
- Data quality validation
03Data TransformationConvert raw documents into token sequences using a tokenizer and vocabulary.EXISTING TOKEN / VECTOR LESSONS›
Convert raw documents into token sequences using a tokenizer and vocabulary.
- Text segmentation
- Document splitting
- Sentence splitting
- Tokenization
- Vocabulary construction
- Token ID assignment
- Special token handling
- Training sequence preparation
- Sequence packing
04Training Data PreparationTurn tokenized sequences into training examples, batches and data-loader inputs.EXISTING PRETRAINING LESSONS›
Turn tokenized sequences into training examples, batches and data-loader inputs.
- Training dataset creation
- Training and validation splits
- Data sampling
- Data shuffling
- Batch creation
- Sequence length configuration
- Training example preparation
- Data loading pipeline
05Model Architecture DesignChoose the neural network structure and dimensions before initializing its parameters.EXISTING ARCHITECTURE LESSONS›
Choose the neural network structure and dimensions before initializing its parameters.
- Neural network architecture
- Transformer architecture
- Decoder-only architecture (GPT)
- Number of Transformer layers
- Attention heads
- Hidden dimensions
- Embedding dimensions
- Feed-forward network dimensions
- Context length
- Model parameter configuration
06Model InitializationCreate the initial parameter state from which optimization begins.NEW LESSONS NEEDED›
Create the initial parameter state from which optimization begins.
- Weight initialization
- Embedding initialization
- Attention weight initialization
- Feed-forward weight initialization
- Bias initialization (where applicable)
- Parameter configuration
- Initial model state
07Pretraining (Foundation Model Training)Train the model on large-scale text with a self-supervised next-token prediction objective.EXISTING PRETRAINING LESSONS›
Train the model on large-scale text with a self-supervised next-token prediction objective.
- Self-supervised learning
- Next-token prediction objective
- Forward propagation
- Token prediction
- Loss calculation
- Cross-entropy loss
- Backpropagation
- Gradient calculation
- Gradient accumulation
- Weight updates
- Optimizers (Adam / AdamW)
- Learning-rate scheduling
- Training epochs and steps
08Model Evaluation (Pretraining Evaluation)Check whether the model is learning and generalizing beyond its training examples.PARTIAL COVERAGE · EVALUATION LESSONS TO ADD›
Check whether the model is learning and generalizing beyond its training examples.
- Training loss monitoring
- Validation loss
- Perplexity
- Benchmark evaluation
- Language understanding evaluation
- Reasoning evaluation
- Code generation evaluation
- Generalization assessment
- Overfitting detection
09Supervised Fine-Tuning (SFT)Adapt a pretrained model to follow instructions using curated demonstrations.EXISTING FINE-TUNING LESSONS›
Adapt a pretrained model to follow instructions using curated demonstrations.
- Instruction dataset preparation
- Question-answer datasets
- Human-written demonstrations
- Prompt-response pairs
- Instruction following
- Supervised learning
- Fine-tuning loss
- Parameter updates
- Model evaluation
10Human Preference Alignment (RLHF and Related Methods)Use human preferences or preference-derived objectives to improve response behavior.EXISTING RLHF / DPO LESSONS›
Use human preferences or preference-derived objectives to improve response behavior.
- Human feedback collection
- Response comparison
- Preference dataset creation
- Reward model training
- Reward scoring
- Reinforcement learning
- PPO (Proximal Policy Optimization)
- Preference optimization
- DPO (Direct Preference Optimization)
- Response quality improvement
11Safety and Alignment TrainingTeach and assess safety-related behavior, policy adherence and robustness.PARTIAL COVERAGE · TARGETED SAFETY TRAINING TO ADD›
Teach and assess safety-related behavior, policy adherence and robustness.
- Safety dataset preparation
- Harmful request identification
- Refusal behavior training
- Bias evaluation
- Toxicity reduction
- Privacy protection
- Instruction hierarchy
- Policy alignment
- Red-team evaluation
12Model Testing and ValidationValidate the post-trained model across intended capabilities and failure modes.NEW EVALUATION / TESTING LESSONS NEEDED›
Validate the post-trained model across intended capabilities and failure modes.
- Functional testing
- Accuracy evaluation
- Reasoning benchmarks
- Hallucination evaluation
- Safety testing
- Robustness testing
- Bias testing
- Adversarial testing
- Human evaluation
13Model OptimizationReduce serving cost and improve memory use, latency and throughput while managing quality trade-offs.EXISTING OPTIMIZATION LESSONS›
Reduce serving cost and improve memory use, latency and throughput while managing quality trade-offs.
- Quantization
- Pruning
- Knowledge distillation
- Memory optimization
- Inference optimization
- Parallel processing
- Latency optimization
- Throughput optimization
14Model DeploymentPackage the model and make it available to inference infrastructure and applications.PARTIAL COVERAGE · DEPLOYMENT LESSONS TO ADD›
Package the model and make it available to inference infrastructure and applications.
- Model serialization
- Model checkpointing
- Model hosting
- GPU / accelerator deployment
- Inference server setup
- API integration
- Load balancing
- Monitoring
- Version management
Don't confuse these boundaries
The tokenizer and vocabulary are prepared for the model's data pipeline. At inference, the deployed tokenizer is reused to encode user input.
Pretraining learns broad language patterns from large corpora. SFT further adapts the pretrained model to follow instructions and demonstrations.
Optimization changes model representation or serving efficiency. Deployment makes a chosen model version available to applications.
The trained model is ready. What happens when a user asks a question?
Continue into the existing interactive inference experience, which traces input to output.