Sampling Methods

Sampling is how AI explores the space of possibilities.

Build 2 hr Python

Prerequisites: Phase 1, Lessons 06-07 (Probability, Bayes' Theorem)

#Learning Objectives

  • Implement inverse CDF, rejection, and importance sampling from scratch using only uniform random numbers
  • Build temperature, top-k, and top-p (nucleus) sampling for language model token generation
  • Explain the reparameterization trick and why it enables backpropagation through sampling in VAEs
  • Run Metropolis-Hastings MCMC to sample from an unnormalized target distribution
Full Access lesson

Keep going. The rest of this lesson is one step away.

Unlock all 503 lessons, video, code, quizzes and every future update. Pay in your own currency with Paystack.

The text and code of this lesson are based on AI Engineering from Scratch by Rohit Ghumare, MIT licensed.