69 hands-on ML coding exercises
Practice ML/AI coding interviews.
Build fluency with focused Python and NumPy exercises across metrics, training, retrieval, debugging, and models from scratch. Run tests instantly in your browser.
Free to start · No signup required · Remote PyTorch execution supported
import math
import torch
def scaled_dot_product_attention(query, key, value, mask):
# 1. Compute scaled query-key scores
d_k = query.shape[-1]
scores = query @ key.transpose(-2, -1) / math.sqrt(d_k)
# 2. Mask and apply stable softmax
scores = scores.masked_fill(~mask, float("-inf"))
weights = torch.softmax(scores, dim=-1)
# 3. Weighted sum of values
return weights @ valueSeven practical tracks
Focused implementations. Real ML judgment.
Metrics
Ranking quality, probability quality, and grouped evaluation.
9 problems02Loss & Training
Stable objectives, weighting, sampling, and optimization inputs.
9 problems03Data & Features
Reliable feature transforms, batching, windows, and leakage control.
7 problems04Retrieval & Ranking
Candidate generation, similarity search, indexing, and reranking.
7 problems05Debugging
Drift, data comparison, calibration, and segmented model behavior.
8 problems06Neural Networks & LLM Components
Tokenization, attention, normalization, inference, and expert routing.
22 problems07ML Models From Scratch
Mini trainers built end to end, from parameter initialization to prediction.
7 problemsGuided roadmaps
Know what to practice next.
Follow focused problem sets that connect foundations to practical outcomes, starting with systematic ML debugging.
Explore roadmaps