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
- Use Thompson Sampling as your default for bandit problems — it adapts exploration to uncertainty automatically and outperforms ε-greedy empirically in most non-stationary settings. Thompson Sampling requires no explicit exploration rate tuning. As evidence accumulates, posterior distributions tighten and exploration naturally decreases. For contextual bandits where per-user context matters, use contextual Thompson Sampling or LinUCB.
- Never use a fixed ε in ε-greedy in production — constant exploration overhead wastes resources even after the policy has converged. Use a decaying schedule (ε_t = 1/√t) or switch to UCB/Thompson which naturally reduce exploration as uncertainty decreases. A fixed ε = 0.1 means 10% of all recommendations forever are random, even after millions of interactions.
- If exploration rate per time step drops to near zero, the system has converged and will not adapt to preference changes — maintain a minimum exploration floor. In non-stationary environments (user preferences shift, product catalog changes, seasonality), a fully converged policy becomes stale. Set a minimum exploration floor of 1–5% and monitor whether the floor is actively being used, which signals that preferences may have shifted.
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
- The dilemma: exploitation costs nothing short-term but goes stale; exploration costs performance but enables improvement.
- ε-greedy is broken at scale: with 10M items it explores obviously-terrible options uniformly.
- UCB directs exploration at uncertainty: $\mu_a + c\sqrt{\log t / N_a}$ — optimism in the face of uncertainty.
- Thompson Sampling (Bayesian): sample from each action's posterior, take the best; exploration decays as posteriors tighten, no rate to tune.
- Regret: ε-greedy $O(\epsilon T)$ vs UCB/TS $O(\log T)$.
- Never use fixed ε in production; decay it or switch to UCB/TS. Keep a 1–5% exploration floor for non-stationary settings.
- Hard-exploration (Montezuma): random discovery is ~$10^{-218}$ — need ICM/RND novelty rewards; beware the noisy-TV problem.
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?
- A) ε-greedy fails because Montezuma's Revenge has a very large discrete action space of 18 possible actions, which makes purely random exploration far too slow to be practical; using a substantially smaller ε value would solve this by concentrating exploration onto fewer candidate actions
- B) The failure is caused entirely by the game's high-resolution graphics, which make the raw pixel state space too large for Q-learning to generalise across effectively; the correct fix is a CNN with better convolutional feature extraction rather than any change to the exploration strategy itself
- C) The first reward requires a specific sequence of ~100+ actions; probability of discovering this by random exploration is (ε/|A|)^100 ≈ 10^{-218}, effectively impossible; fixes include ICM/RND novelty rewards, hierarchical RL subgoals, and human demonstration seeding
- D) ε-greedy is insufficient because Montezuma's Revenge has a fundamentally non-Markovian reward structure where the identical action produces different rewards depending on the full episode history; the fix is a recurrent policy that conditions on the entire trajectory rather than the current frame
Q2. Which two statements correctly explain the noisy-TV problem in curiosity-driven exploration and how ICM/RND address it?
- A) A pure prediction-error curiosity module rewards the agent for standing in front of random static (maximum prediction error forever, no real exploration); ICM fixes this via inverse-dynamics training so the feature encoder ignores uncontrollable features the agent's actions can't cause
- B) RND avoids the problem because its fixed random target network gives each TV frame a deterministic representation, so intrinsic reward for a static-but-unlearnable state decays to near zero after a few visits
- C) The noisy-TV problem occurs when the environment has a high frame rate that overwhelms the replay buffer; ICM solves this by subsampling frames, and RND avoids it via a projection invariant to frame rate
- D) The noisy-TV problem only applies to environments containing literal television screens; in Atari games without visible static, ICM and RND behave identically and the distinction is irrelevant
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?
- A) Use Bayesian optimisation with a surrogate model for Thompson sampling over molecular embeddings, or generative RL (REINVENT/GCPN) with diversity bonuses; the binding-affinity predictor is itself a proxy reward, so guard against Goodhart violations with diversity regularisation and periodic wet-lab validation
- B) Standard ε-greedy with ε=0.5 is entirely sufficient here because the dense local structure of chemical space means that random perturbations applied to an already-good molecule will frequently produce yet another good molecule; the raw figure of 10^{60} is misleading since most molecules turn out to be structurally near-identical
- C) Use count-based exploration with a SimHash-based locality-sensitive hash to approximate visit counts directly in the molecular fingerprint space; this provides UCB-style exploration bonuses for novel molecules without ever requiring exact discrete state counts to be maintained
- D) The only mathematically valid approach for a 10^{60}-molecule space is classical evolutionary search using genetic algorithms rather than any form of RL; RL is fundamentally incapable of scaling to state spaces larger than roughly 10^{20} states regardless of which exploration strategy is chosen
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 →