Coders In Hoods
  • Courses
  • Roles
  • Blog
  • Setup

Coders In Hoods AI Academy

Every course is free. Sign in to start, and your progress, quiz scores and bookmarks follow you.

AI Academy

  • Courses
  • Paths
  • Setup guides
  • How we teach

Role roadmaps

  • AI Engineer
  • Forward Deployed Engineer
  • Machine Learning Engineer
  • All roles

Coders In Hoods

  • The agency
  • Coaching for teams
  • Blog
  • LinkedIn
  • X (Twitter)

Contact

codersinhoods@gmail.com

© Coders In Hoods · since 2019

Course overview

LLMs for Engineers

Free · sign in to start and track progress

1 · Inside the transformer

  • 1Tokens and embeddings
  • 2Attention, step by step
  • 3The transformer block

2 · How models are trained

  • 4Pretraining and scaling laws

    Exercise answers

    • Answer: Fit your own scaling law on a laptop
    • Answer: Base model versus assistant on conveyancing prompts
  • 5Post-training an assistant

3 · Running models in production

  • 6Sampling and hallucination
  • 7Context windows, KV cache and caching
  • 8Reasoning models and extended thinking
  • 9Choosing and comparing models
CapstoneChoose a model for document extractionReference implementation

Module 2 · How models are trained · Lesson 4

Pretraining and scaling laws

How one objective, predicting the next token over trillions of tokens of text, produces a base model, and how scaling laws decide model size, data and compute.

70 min 2 videos 3 exercises 6-question quiz Answers
Setup for the exercises:Install Claude CodePython with uvRun Hugging Face models on CPU

By the end of this lesson you can

  • Compute the cross-entropy loss for a next-token prediction and explain why one sequence yields many training examples
  • Describe the main stages of a pretraining data pipeline and how they shape what a model knows
  • Estimate training compute with C ≈ 6ND and convert it into GPU-hours
  • Explain the Kaplan and Chinchilla scaling results and why modern small models are deliberately "over-trained"
  • Predict how a base model responds to a prompt, and why it is not yet an assistant

On this page

  • The objective: next-token prediction
  • The data
  • Compute: the 6ND rule
  • Worked example
  • Scaling laws
  • Compute-optimal is not deployment-optimal
  • How a run actually goes
  • The base model: a document simulator
  • Summary
  • Sources & further reading
  • Quiz

In this lesson

  1. 01The objective: next-token prediction
  2. 02The data
  3. 03Compute: the 6ND rule
  4. 04Scaling laws
  5. 05How a run actually goes
  6. 06The base model: a document simulator
  7. 07Summary

Sources & further reading

  • Training Compute-Optimal Large Language Models (Chinchilla)Paper · Hoffmann et al. · DeepMind · 2022The compute-optimal result that model size and training tokens should scale together. Read the abstract, Figure 1 and Section 3.
  • Scaling Laws for Neural Language ModelsPaper · Kaplan et al. · OpenAI · 2020The first systematic power-law fits of loss against parameters, data and compute. Figure 1 is the famous one; Section 2.1 derives C ≈ 6ND.
  • The Llama 3 Herd of ModelsPaper · Llama Team, Meta · Meta · 2024The most detailed public account of a frontier-scale pretraining run. Section 3 covers data curation, scaling-law experiments and the training recipe.
  • The FineWeb Datasets: Decanting the Web for the Finest Text Data at ScalePaper · Penedo et al. · Hugging Face · 2024An open, step-by-step web-data pipeline (extraction, filtering, deduplication) with ablations showing what each step is worth.
  • Language Models are Few-Shot Learners (GPT-3)Paper · Brown et al. · OpenAI · 2020Shows a pure base model doing tasks from examples in its prompt (in-context learning). Section 2 and Figure 2.1 explain zero-, one- and few-shot prompting.
  • Introducing Meta Llama 3Lab research · Meta · 2024The short post with the "over 15T tokens" figure and the observation that the 8B model kept improving far past its Chinchilla-optimal data budget.
Free · sign in to start

Sign in to keep reading.

Free, no card. We use your account to save progress, quiz scores, bookmarks and occasionally send updates from our team.

  • 7 more sections
  • 3 hands-on exercises
  • A 6-question quiz
  • Progress, quiz scores and bookmarks