Applied AI Foundations

Trace a calculation, evaluate a model, and examine how human feedback shapes its answers. Practice touch typing in 200 self-contained lessons.

Opening lessons

  1. Trace a Python expression
  2. Accumulate values in a loop
  3. Keep a test set independent
  4. Compute a weighted sum
  5. Estimate a probability
  6. Take one gradient step
  7. Trace a breadth-first search
  8. Evaluate a classifier
  9. Trace one artificial neuron
  10. Read a token sequence
  11. Compute an attention output
  12. Distinguish training and inference
  13. Trace a retrieval request
  14. Validate structured output
  15. Compute a discounted return
  16. Read a human preference pair
  17. Use a learned reward
  18. Compare preference training methods
  19. Audit a timetable assistant

Python for experiments

  1. Trace a list comprehension over short labels
  2. Count repeated tokens with a dictionary
  3. Compare shallow copies of a nested list
  4. Use enumerate to preserve positions
  5. Read the half-open endpoints of a slice
  6. Separate an empty list from a missing value
  7. Group records by an explicit key
  8. Trace a generator through one pass
  9. Explain the result of a stable sort
  10. Use a set to detect duplicate identifiers
  11. Check the shape of a batch before processing
  12. Test a helper with one edge case

Vectors and matrices

  1. Represent a document with three counts
  2. Compute a two-coordinate dot product
  3. Interpret a negative dot product
  4. Normalize a short vector to unit length
  5. Use cosine similarity to compare directions
  6. Calculate a squared Euclidean distance
  7. Multiply a matrix by a feature vector
  8. Read the shape of a batch multiplication
  9. Explain why a transpose changes the product
  10. Add a bias to a linear score
  11. Compare sums with means when pooling
  12. Locate an axis error in a feature table

Probability and sampling

  1. Calculate a conditional frequency
  2. Use a complementary event to simplify a count
  3. Distinguish sampling with replacement
  4. Read a two-by-two contingency table
  5. Compute an expectation for a discrete reward
  6. Update a belief using two likelihoods
  7. Trace a probability tree with dependent draws
  8. Compare independent and joint probabilities
  9. Find an impossible probability distribution
  10. Normalize three unscaled weights
  11. Explain what a random seed controls
  12. Describe variation across repeated small samples

Measuring predictions

  1. Build a confusion matrix from eight labels
  2. Compute precision with rare positives
  3. Compute recall for a missed alert
  4. Read a false positive rate
  5. Compare accuracy with a majority baseline
  6. Calculate F1 from counts
  7. Choose a threshold under asymmetric cost
  8. Group forecasts into a calibration bin
  9. Compute mean absolute error
  10. Compare mean squared error after one large miss
  11. Average performance across unequal groups
  12. Separate a zero score from an undefined metric

Data preparation and evaluation

  1. Split by customer to avoid repeated records
  2. Use a time split for a future event
  3. Fit a scaler using training data only
  4. Encode an unseen category explicitly
  5. Keep a feature unavailable at prediction time out of training
  6. Diagnose a target proxy in a table
  7. Choose a missing-value indicator
  8. Compare stratified and unstratified sampling
  9. Hold out an untouched final set
  10. Inspect conflicting labels for the same example
  11. Trace the impact of a duplicate in evaluation
  12. Design a small data provenance record

Optimization and learning

  1. Fit an intercept-only predictor for squared error
  2. Compute a residual and its sign
  3. Take one gradient descent step on a parabola
  4. Show how an oversized step overshoots
  5. Calculate a mini-batch mean gradient
  6. Separate a parameter from a hyperparameter
  7. Compare L1 and L2 penalty terms
  8. Read a training and validation loss curve
  9. Check a derivative with a finite difference
  10. Explain a learning-rate schedule by example
  11. Compare two models at equal validation loss
  12. Use feature scaling to interpret a step

Networks and representations

  1. Trace one rectified linear unit
  2. Propagate two activations through a second layer
  3. Count weights in a small dense layer
  4. Apply the chain rule through a scalar network
  5. Find a region with zero ReLU gradient
  6. Read the effect of a sigmoid on a logit
  7. Explain why stacked linear layers collapse
  8. Pool three token vectors by averaging
  9. Measure a nearest neighbor in embedding space
  10. Show how scale affects unnormalized retrieval
  11. Compare one-hot and learned representations
  12. Mask a padded item before averaging

Search and decision problems

  1. Define a state for a library cart route
  2. Trace one breadth-first frontier
  3. Compare depth-first and breadth-first discovery
  4. Use uniform-cost search on unequal edges
  5. Read an admissible heuristic on a toy map
  6. Compute the A-star priority for two nodes
  7. Detect a repeated state on a cycle
  8. Use a constraint to prune a seating plan
  9. Break ties between equal-cost routes
  10. Distinguish a path cost from a heuristic
  11. Trace a two-ply minimax game tree
  12. Compute an expected value at a chance node

Language modeling and decoding

  1. Predict with a tiny bigram table
  2. Separate token counts from word counts
  3. Trace one byte-pair merge
  4. Explain the role of an unknown token
  5. Shift inputs and targets for next-token prediction
  6. Compute a sequence probability from conditionals
  7. Choose a greedy continuation with given scores
  8. Compare greedy selection with overall sequence likelihood
  9. Construct a top-k candidate set
  10. Build a nucleus from sorted probabilities
  11. Apply a stopping token in a short decode
  12. Separate padding masks from causal masks

Attention and transformer blocks

  1. Read query, key and value roles
  2. Compute a tiny attention score matrix entry
  3. Combine values with supplied attention weights
  4. Check a row of normalized attention weights
  5. Mask a future token in causal attention
  6. Trace two heads with different supplied weights
  7. Add a residual vector coordinate by coordinate
  8. Interpret per-token layer normalization
  9. Show why token order needs a position signal
  10. Count token pairs in full self-attention
  11. Identify reusable keys and values during decoding
  12. Relate input context length to attention work

Retrieval and grounded generation

  1. Calculate document frequency for two terms
  2. Compare term frequency across short passages
  3. Retrieve by an exact rare identifier
  4. Rank two dense neighbors by cosine
  5. Keep overlap when chunking a definition
  6. Choose evidence among near-duplicate revisions
  7. Apply a metadata filter before retrieval
  8. Compute recall at three for a query
  9. Distinguish retrieval failure from answer failure
  10. Rerank a shortlist with a supplied score
  11. Check whether a citation entails a claim
  12. Audit an unanswerable retrieval question

Reinforcement learning

  1. Specify state, action, reward and transition
  2. Compute a discounted three-step return
  3. Compare immediate reward with total return
  4. Calculate the value of a stochastic action
  5. Take one tabular Q-learning update
  6. Trace an on-policy SARSA target
  7. Compare an exploratory action with a greedy one
  8. Identify an absorbing terminal state
  9. Evaluate a policy from two sampled returns
  10. Compute a one-step temporal difference error
  11. Explain partial observability with matching observations
  12. Show how a proxy reward can change a policy

Instruction tuning and human feedback

  1. Separate pretraining text from a demonstration
  2. Mark which tokens contribute to a supervised reply loss
  3. Design a comparison with one clear preference
  4. Separate a tie from a missing rating
  5. Compute an empirical preference fraction
  6. Compare human agreement across two tasks
  7. Contrast a reward score with a calibrated probability
  8. Read a pairwise reward difference
  9. Interpret the sign of a policy log ratio
  10. Explain a KL penalty using a two-action policy
  11. Compare rejection sampling with policy updating
  12. Detect a length shortcut in preference data

Alignment and evaluation experiments

  1. Track preferred and rejected replies in a DPO example
  2. Compare policy and reference preference odds
  3. Distinguish a DPO update from a reward-model fit
  4. Control answer order in a pairwise evaluation
  5. Compare a rubric score with a pairwise win
  6. Look for disagreement hidden by an average
  7. Evaluate an exact-format instruction separately from content
  8. Check an annotator guideline against a borderline case
  9. Measure a model's abstention coverage
  10. Audit a held-out preference pair for contamination
  11. Separate a grader's style preference from correctness
  12. Compare two checkpoints on the same blind pairs

Running reliable AI systems

  1. Measure latency with two sequential stages
  2. Distinguish throughput from response time
  3. Estimate prompt token cost from a supplied rate
  4. Account for variable-length padding in a batch
  5. Choose a cache key for a versioned prompt
  6. Avoid a duplicate event after a retry
  7. Compare a cached output with a fresh evaluation
  8. Identify a schema change in a model response
  9. Choose a representative regression case
  10. Detect a change in the input mix
  11. Compare two releases on matched examples
  12. Build a reproducible experiment record

Capstone

  1. Trace an evidence-grounded assistant from input to evaluation

Background reading · UC Berkeley · Introduction to Artificial Intelligence