LearnerBox logo LearnerBox Infosystems LLP
  • The Science of AI

    How Large Language Models Work — Part 4: Training, Scaling Laws, and RLHF

    This is Part 4 of a five-part series on the internal mechanics of large language models. Part 3 covered the complete transformer block and architectural variants. Part 4 addresses how models are trained: the pre-training objective, loss functions, the Chinchilla scaling laws, and the alignment pipeline of instruction tuning and RLHF that transforms a raw language model into a useful assistant. The Pre-Training Objective The entire capability of a modern LLM emerges from one deceptively simple training objective: predict the next token. Given a sequence of tokens [t1,t2,…,tn][t_1, t_2, \ldots, t_n], the model is trained to maximise the log-probability of each token given all preceding tokens:LPT=−1n∑i=1nlog⁡P(ti∣t1,…,ti−1; θ)\mathcal{L}_{\text{PT}} = -\frac{1}{n} \sum_{i=1}^{n} \log…