Sub topic 15
Beyond Fixed Splits: Bandits and Interleaving
Assume you understand sticky A/B assignment, guardrail metrics, delayed labels, and basic statistical testing. This chapter explains two strategies that go beyond a fixed traffic split: bandits and interleaving.
Why fixed splits are not always enough
A fixed split gives each variant a predetermined share of traffic, such as 50% for the control and 50% for the candidate. This makes comparison simple because the assignment rule does not change during the experiment.
However, a fixed split can waste traffic on a clearly worse model. It can also delay a useful model from receiving more traffic. Bandit algorithms address this by changing allocation as evidence accumulates.
A bandit is an algorithm that balances:
- Exploration: sending traffic to learn about each model.
- Exploitation: sending more traffic to the model currently expected to perform best.
| Strategy | Main goal | Allocation |
|---|---|---|
| A/B test | Estimate a causal difference | Fixed or preplanned |
| Bandit | Improve outcomes during learning | Adaptive |
| Interleaving | Compare ranking behavior efficiently | Mixed result list |
Bandit allocation
Suppose two recommendation models produce a click or no-click outcome. An epsilon-greedy bandit chooses the currently best model most of the time, but explores other models with probability epsilon.
import random
def choose_model(rewards, epsilon=0.10):
if random.random() < epsilon:
return random.choice(list(rewards))
return max(
rewards,
key=lambda name: rewards[name]["successes"] /
rewards[name]["trials"]
)
rewards = {
"stable": {"successes": 480, "trials": 10_000},
"candidate": {"successes": 540, "trials": 10_000},
}
for _ in range(5):
print(choose_model(rewards))This example uses observed click rates as estimates. Production systems usually use confidence-aware methods such as Thompson sampling or an upper-confidence-bound algorithm. These methods explore models that might be good but still have limited evidence.
Adaptive allocation changes the meaning of the data. A standard A/B test assumes that assignment was independent of previous outcomes. A bandit violates that assumption because later assignments depend on earlier results. Use an analysis method designed for adaptive experiments, and record the assignment probability for every request.
Interleaving ranking models
Interleaving compares ranking models by combining their results into one list. For example, model A supplies some items and model B supplies others. A user's click then provides a direct preference signal between the models.
A common method is team-draft interleaving:
- Randomly choose one model to select first.
- Add that model's highest-ranked unused item.
- Let the other model select its highest-ranked unused item.
- Continue until the list is full.
- Attribute clicks to the model that supplied each clicked item.
Interleaving often needs fewer users than a page-level A/B test because both models compete within the same session. It works best for ranking changes where item-level clicks are meaningful. It is less suitable when models change prices, page layout, response wording, or other whole-experience features.
Choosing a strategy
Use a fixed A/B test when you need a defensible estimate of a business effect. Use a bandit when reducing regret during rollout is important and you can analyze adaptive data. Use interleaving for ranking models with fast, item-level feedback.
For high-risk changes, combine strategies. Start with shadow traffic, then use a guarded canary. After basic safety is established, run a fixed A/B test or an adaptive strategy according to the decision you need to make.
Exercise
A candidate ranking model has a small early lead, but the team needs an unbiased estimate of its effect on purchases. Should it immediately use a bandit?
Show answer
No. Start with a fixed A/B test, preserve the assignment probabilities, and use guardrails. A bandit can be considered later if improving traffic allocation during learning is more important than a simple causal comparison.