Choose the Right Randomization Unit for an A/B Test
Machine LearningModel answerLast updated
Decide whether to randomize by user, session, or request for a new ML-powered feature, and explain the consequences of each choice.
Background
Your team has trained a new ML model that re-ranks search results based on a user's long-term interest profile. You are ready to run an A/B test to measure whether the new ranker increases clicks and purchases.
A colleague suggests three possible randomization units:
- Request-level — each individual search query is randomly assigned to control or treatment, independently.
- Session-level — each browsing session is randomly assigned; every query within that session sees the same variant.
- User-level — each user is assigned once and permanently; they always see the same variant.
What is expected
Answer the following:
- Which randomization unit would you recommend, and why?
- What goes wrong if you pick the wrong unit?
- What is the SUTVA assumption, and which unit best satisfies it here?
- Are there any practical trade-offs or edge cases with your recommended unit?
You do not need to do any math. A clear, structured explanation with reasoning is enough.
Hints
Hint 1
Think about whether the model's output for one query depends on what the user saw in a previous query — does exposure to one variant 'contaminate' future queries?
Hint 2
SUTVA stands for Stable Unit Treatment Value Assumption. Ask yourself: can one unit's treatment affect another unit's outcome?
Hint 3
Consider novelty effects and how long it takes for a personalization model to show its true impact on behavior.
Model answer
Easy Try it yourself first — then compare your approach, complexity and edge cases.
Recommended Unit: User-Level Randomization
For a personalization feature that uses a user's long-term interest profile, user-level randomization is the correct choice. Here is the reasoning, organized around each question.
1. Why User-Level?
The new ranker is personalized — its outputs for a given user depend on that user's accumulated history. This creates two problems if you randomize at a finer grain:
Request-level randomization assigns the same user to control on one query and treatment on the next. This means:
- The user's experience is inconsistent and jarring (they see different result orderings for the same intent).
- The model may behave poorly because it was trained assuming consistent exposure; partial exposure is out-of-distribution.
- Clicks on one query are not independent of the previous query's result — a user who found a good result may refine their query, inflating or deflating metrics in ways that are hard to interpret.
Session-level randomization is better than request-level, but still has issues:
- A user assigned to treatment in the morning and control in the afternoon will have their behavior in the control session influenced by what they saw in the treatment session (e.g., they already found what they wanted). This is cross-contamination across sessions.
- It also makes it harder to measure long-term effects like repeat purchase behavior.
User-level randomization avoids both problems:
- Each user has a consistent, coherent experience throughout the experiment.
- Long-term behavioral signals (repeat visits, purchases over days) can be cleanly attributed to the variant.
- The model's personalization logic operates as designed, since it always sees a user who has been fully in one condition.
2. What Goes Wrong With the Wrong Unit?
Interference / spillover: When a user is exposed to both variants (request- or session-level), their behavior in one variant is influenced by their experience in the other. This violates the independence assumption that underlies standard A/B test statistics, leading to biased estimates of the treatment effect.
Variance inflation: Metrics like clicks per user are computed by averaging over users, but if each user contributes data to both groups, the effective sample size is lower than it appears, making confidence intervals unreliable.
Novelty and learning effects: Personalization models often need several interactions before they meaningfully diverge from a baseline. Request-level randomization prevents this ramp-up from happening, so you may measure a weaker effect than the model would actually produce in production.
3. SUTVA and Which Unit Satisfies It
SUTVA (Stable Unit Treatment Value Assumption) requires two things:
- The potential outcome for one unit does not depend on the treatment assigned to another unit (no interference between units).
- There is only one version of each treatment (no hidden variation in how treatment is applied).
For request-level randomization, SUTVA is violated: the outcome of query #5 for a user depends on what variant was shown in queries #1–4. The units (requests) interfere with each other through the user's memory and the model's context.
For user-level randomization, SUTVA is approximately satisfied:
- One user's outcome does not directly depend on another user's treatment assignment (assuming users do not heavily influence each other, which is reasonable for search).
- Each user consistently receives one version of the product.
User-level is therefore the unit that best satisfies SUTVA here.
4. Practical Trade-offs and Edge Cases
Pro — cleaner causal inference: User-level assignment is the standard for personalization experiments and is well understood by analysis tooling.
Con — requires more users, not more queries: The effective sample size is the number of users, not the number of queries. If your user base is small (e.g., a niche B2B product), you may need a longer experiment to reach significance. Request-level randomization is tempting precisely because it inflates apparent sample size, but this is a trap.
Cookie/ID consistency: If users are identified by cookies that reset (e.g., incognito browsers, mobile app reinstalls), the same human may end up in both groups. Mitigate this by using a stable logged-in user ID wherever possible, and excluding or separately analyzing logged-out traffic.
New users vs. returning users: The personalization model may behave very differently for new users (cold start) versus users with rich history. Consider stratifying your randomization or analyzing these subgroups separately to avoid a diluted average effect that hides a strong effect on returning users.
Ramp-up period: Even with user-level randomization, give the experiment enough time (typically 1–2 weeks minimum for search products) so that users in the treatment group accumulate enough interactions for the model's personalization to fully kick in.
Summary Table
| Unit | SUTVA satisfied? | Consistent UX? | Measures long-term effects? | Recommended? |
|---|---|---|---|---|
| Request | No | No | No | No |
| Session | Partially | Partially | Partially | No |
| User | Yes | Yes | Yes | Yes |
Bottom line: Use user-level randomization. It is the only unit that gives a coherent, uncontaminated view of how the personalized ranker affects real user behavior over time.