Product Sense · hard · Reported at Spotify

Design an experiment to test a new recommendation algorithm.

Asked in ML Engineer interviews.

Short answer

Randomize at user level, define engagement metric, guardrails, run long enough for novelty decay.

How to answer it

Define success first

Before any design, agree what the algorithm is for. Recommendations optimized for clicks and recommendations optimized for satisfaction produce different systems, and the metric decides which one you build.

Primary       one metric. Perhaps conversion, or long-session rate
Secondary     engagement depth, items discovered, return within 7 days
Guardrails    latency, error rate, revenue, unsubscribes, support tickets

Guardrails matter here specifically because a recommender can win on engagement while quietly harming the experience: clickbait raises clicks and lowers return visits.

The design

Unit           the user, not the session or the request. A user seeing both
               algorithms across sessions contaminates the comparison

Assignment     deterministic hash of user id with experiment id

Split          50/50, or a 5% ramp first if there is any risk to revenue

Duration       the pre-computed sample size, and at least two full weeks
               to cover the weekly cycle and outlast novelty

Exposure       log when a user actually SAW recommendations, not everyone
               who was eligible

The recommender-specific traps

Key points

FAQ

The 30-second answer

I would agree the primary metric first, because a recommender optimized for clicks and one optimized for satisfaction are different systems. So one primary metric, a few secondary ones, and guardrails on latency, revenue and return rate, since engagement can go up while the experience gets worse.
Randomization on the user rather than the session, using a deterministic hash, so nobody sees both algorithms. Fifty-fifty, or a small ramp first if revenue is exposed. At least two full weeks to cover the weekly cycle and outlast novelty, and I would log exposure rather than eligibility.
The traps specific to recommenders are novelty, which I would check by splitting new against returning users and watching the effect decay, and interference on a marketplace, where promoting an item to one group can starve another and break the independence the test assumes.

In the interview

Practice this for real