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
- Trace a Python expression
- Accumulate values in a loop
- Keep a test set independent
- Compute a weighted sum
- Estimate a probability
- Take one gradient step
- Trace a breadth-first search
- Evaluate a classifier
- Trace one artificial neuron
- Read a token sequence
- Compute an attention output
- Distinguish training and inference
- Trace a retrieval request
- Validate structured output
- Compute a discounted return
- Read a human preference pair
- Use a learned reward
- Compare preference training methods
- Audit a timetable assistant
Python for experiments
- Trace a list comprehension over short labels
- Count repeated tokens with a dictionary
- Compare shallow copies of a nested list
- Use enumerate to preserve positions
- Read the half-open endpoints of a slice
- Separate an empty list from a missing value
- Group records by an explicit key
- Trace a generator through one pass
- Explain the result of a stable sort
- Use a set to detect duplicate identifiers
- Check the shape of a batch before processing
- Test a helper with one edge case
Vectors and matrices
- Represent a document with three counts
- Compute a two-coordinate dot product
- Interpret a negative dot product
- Normalize a short vector to unit length
- Use cosine similarity to compare directions
- Calculate a squared Euclidean distance
- Multiply a matrix by a feature vector
- Read the shape of a batch multiplication
- Explain why a transpose changes the product
- Add a bias to a linear score
- Compare sums with means when pooling
- Locate an axis error in a feature table
Probability and sampling
- Calculate a conditional frequency
- Use a complementary event to simplify a count
- Distinguish sampling with replacement
- Read a two-by-two contingency table
- Compute an expectation for a discrete reward
- Update a belief using two likelihoods
- Trace a probability tree with dependent draws
- Compare independent and joint probabilities
- Find an impossible probability distribution
- Normalize three unscaled weights
- Explain what a random seed controls
- Describe variation across repeated small samples
Measuring predictions
- Build a confusion matrix from eight labels
- Compute precision with rare positives
- Compute recall for a missed alert
- Read a false positive rate
- Compare accuracy with a majority baseline
- Calculate F1 from counts
- Choose a threshold under asymmetric cost
- Group forecasts into a calibration bin
- Compute mean absolute error
- Compare mean squared error after one large miss
- Average performance across unequal groups
- Separate a zero score from an undefined metric
Data preparation and evaluation
- Split by customer to avoid repeated records
- Use a time split for a future event
- Fit a scaler using training data only
- Encode an unseen category explicitly
- Keep a feature unavailable at prediction time out of training
- Diagnose a target proxy in a table
- Choose a missing-value indicator
- Compare stratified and unstratified sampling
- Hold out an untouched final set
- Inspect conflicting labels for the same example
- Trace the impact of a duplicate in evaluation
- Design a small data provenance record
Optimization and learning
- Fit an intercept-only predictor for squared error
- Compute a residual and its sign
- Take one gradient descent step on a parabola
- Show how an oversized step overshoots
- Calculate a mini-batch mean gradient
- Separate a parameter from a hyperparameter
- Compare L1 and L2 penalty terms
- Read a training and validation loss curve
- Check a derivative with a finite difference
- Explain a learning-rate schedule by example
- Compare two models at equal validation loss
- Use feature scaling to interpret a step
Networks and representations
- Trace one rectified linear unit
- Propagate two activations through a second layer
- Count weights in a small dense layer
- Apply the chain rule through a scalar network
- Find a region with zero ReLU gradient
- Read the effect of a sigmoid on a logit
- Explain why stacked linear layers collapse
- Pool three token vectors by averaging
- Measure a nearest neighbor in embedding space
- Show how scale affects unnormalized retrieval
- Compare one-hot and learned representations
- Mask a padded item before averaging
Search and decision problems
- Define a state for a library cart route
- Trace one breadth-first frontier
- Compare depth-first and breadth-first discovery
- Use uniform-cost search on unequal edges
- Read an admissible heuristic on a toy map
- Compute the A-star priority for two nodes
- Detect a repeated state on a cycle
- Use a constraint to prune a seating plan
- Break ties between equal-cost routes
- Distinguish a path cost from a heuristic
- Trace a two-ply minimax game tree
- Compute an expected value at a chance node
Language modeling and decoding
- Predict with a tiny bigram table
- Separate token counts from word counts
- Trace one byte-pair merge
- Explain the role of an unknown token
- Shift inputs and targets for next-token prediction
- Compute a sequence probability from conditionals
- Choose a greedy continuation with given scores
- Compare greedy selection with overall sequence likelihood
- Construct a top-k candidate set
- Build a nucleus from sorted probabilities
- Apply a stopping token in a short decode
- Separate padding masks from causal masks
Attention and transformer blocks
- Read query, key and value roles
- Compute a tiny attention score matrix entry
- Combine values with supplied attention weights
- Check a row of normalized attention weights
- Mask a future token in causal attention
- Trace two heads with different supplied weights
- Add a residual vector coordinate by coordinate
- Interpret per-token layer normalization
- Show why token order needs a position signal
- Count token pairs in full self-attention
- Identify reusable keys and values during decoding
- Relate input context length to attention work
Retrieval and grounded generation
- Calculate document frequency for two terms
- Compare term frequency across short passages
- Retrieve by an exact rare identifier
- Rank two dense neighbors by cosine
- Keep overlap when chunking a definition
- Choose evidence among near-duplicate revisions
- Apply a metadata filter before retrieval
- Compute recall at three for a query
- Distinguish retrieval failure from answer failure
- Rerank a shortlist with a supplied score
- Check whether a citation entails a claim
- Audit an unanswerable retrieval question
Reinforcement learning
- Specify state, action, reward and transition
- Compute a discounted three-step return
- Compare immediate reward with total return
- Calculate the value of a stochastic action
- Take one tabular Q-learning update
- Trace an on-policy SARSA target
- Compare an exploratory action with a greedy one
- Identify an absorbing terminal state
- Evaluate a policy from two sampled returns
- Compute a one-step temporal difference error
- Explain partial observability with matching observations
- Show how a proxy reward can change a policy
Instruction tuning and human feedback
- Separate pretraining text from a demonstration
- Mark which tokens contribute to a supervised reply loss
- Design a comparison with one clear preference
- Separate a tie from a missing rating
- Compute an empirical preference fraction
- Compare human agreement across two tasks
- Contrast a reward score with a calibrated probability
- Read a pairwise reward difference
- Interpret the sign of a policy log ratio
- Explain a KL penalty using a two-action policy
- Compare rejection sampling with policy updating
- Detect a length shortcut in preference data
Alignment and evaluation experiments
- Track preferred and rejected replies in a DPO example
- Compare policy and reference preference odds
- Distinguish a DPO update from a reward-model fit
- Control answer order in a pairwise evaluation
- Compare a rubric score with a pairwise win
- Look for disagreement hidden by an average
- Evaluate an exact-format instruction separately from content
- Check an annotator guideline against a borderline case
- Measure a model's abstention coverage
- Audit a held-out preference pair for contamination
- Separate a grader's style preference from correctness
- Compare two checkpoints on the same blind pairs
Running reliable AI systems
- Measure latency with two sequential stages
- Distinguish throughput from response time
- Estimate prompt token cost from a supplied rate
- Account for variable-length padding in a batch
- Choose a cache key for a versioned prompt
- Avoid a duplicate event after a retry
- Compare a cached output with a fresh evaluation
- Identify a schema change in a model response
- Choose a representative regression case
- Detect a change in the input mix
- Compare two releases on matched examples
- Build a reproducible experiment record
Capstone
Background reading · UC Berkeley · Introduction to Artificial Intelligence