ML Systems Lab Open interactive version →
Advanced 55 min read explorationexploitationucbthompson samplingcuriosity

Exploration vs Exploitation

ε-greedy, UCB, curiosity (ICM), count-based, Thompson sampling, high-dimensional exploration

Consider a news recommendation system. For each user request you can recommend the user's known-favorite category (exploitation) or try a different category to learn their preferences (exploration). With 100% exploitation the user sees only what they have liked before — you never learn whether they would enjoy something new, and you are stuck with increasingly stale preferences. With 100% exploration recommendations are random and user satisfaction drops. The dilemma: exploration costs short-term performance but enables long-term improvement.

ε-greedy handles this with a simple switch: with probability ε take a random action, otherwise take the best known one. Simple, but fundamentally broken in large action spaces. With 10M news articles and ε = 0.1, ε-greedy explores uniformly across all 10M items — allocating just as much exploration to articles you are certain are terrible as to those with genuine uncertainty. It wastes exploration budget on obviously inferior options.

UCB (Upper Confidence Bound) directs exploration at uncertainty instead. Score each action as μ_a + c√(log t / N_a) where μ_a is the estimated reward, N_a is visit count, and t is total time steps. The second term is an exploration bonus that shrinks as N_a grows. Actions you have barely tried have large bonuses — the algorithm prefers them until it has reduced its uncertainty. This implements "optimism in the face of uncertainty": act as if uncertain actions are as good as their highest plausible value.

Thompson Sampling is the Bayesian version. Model each action's reward as a distribution — Beta(α, β) for click/no-click outcomes. Sample one reward estimate from each action's current posterior. Take the best. Actions with high uncertainty have wide distributions and are more likely to sample a high value — which means they are more likely to be selected and explored. As evidence accumulates, posteriors tighten and exploration naturally decreases. No explicit exploration rate to tune.

NOT this: exploration is just about trying random actions. Structured exploration — UCB, Thompson Sampling — outperforms random exploration by directing effort toward uncertain actions, not arbitrary ones. In a recommendation system with 10M items, ε-greedy wastes exploration uniformly. UCB concentrates exploration where information value is highest. The difference in regret is asymptotically O(ε T) versus O(log T).

Key points

Takeaway

Exploration should be directed at uncertainty, not randomness — UCB and Thompson Sampling concentrate effort where information gain is highest, while ε-greedy wastes exploration uniformly across actions including the obviously inferior ones.

Recap

Check your understanding

Q1. Why does ε-greedy exploration fail on Montezuma's Revenge (an Atari game with hard exploration), and what specific property of the environment causes the failure?

Q2. Which two statements correctly explain the noisy-TV problem in curiosity-driven exploration and how ICM/RND address it?

Q3. You are applying RL to a drug discovery task — the agent proposes molecular structures and receives a reward based on the drug's predicted binding affinity. The action space is discrete (atom type × position) but the molecule space has ~10^{60} valid molecules. How do you handle exploration?

Try it interactively

ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.

Open ML Systems Lab →