Compare two rankers online with team-draft interleaving
Why it matters Search and recommendation teams use interleaving because it detects ranker differences with far less traffic than A/B tests.
Interleaving tests two rankers on the same user at once: merge their lists, remember which ranker contributed each item, and see whose items get clicked.
Write team_draft(A, B, coins, length, clicks). A and B are ranked item lists, coins a list of booleans consumed in order, clicks a list of positions in the merged list. Build the merged list one pick at a time until it has length items:
- Let nA, nB be the picks made so far by each team. If nA < nB, A picks; if nB < nA, B picks; if equal, take the next coin: True means A picks, False means B.
- The picking team adds its highest-ranked item not already in the merged list. If it has none left, the other team picks instead; if neither has any, stop.
Credit each clicked position to the team that picked it. Return (merged list, list of team labels "A" or "B", winner) where winner is "A", "B" or "tie" by click credit.
def team_draft(A, B, coins, length, clicks)Example
team_draft([1, 2, 3], [2, 4, 5], [True, False], 4, [1]) gives ([1, 2, 4, 3], ['A', 'B', 'B', 'A'], 'B').
Understand the idea
An A/B test needs many users because each user sees only one ranker. Interleaving is more sensitive: every user sees a mix of both rankers' results, and clicks reveal which ranker's picks were better. Team draft works like picking sides for a cricket match: the captains take turns choosing their best remaining player, and a coin toss decides who picks first when they are level.
Example: A = [1, 2, 3], B = [2, 4, 5]. Coin says A first: A picks 1. B is behind, so B picks its best, 2. Level again, coin says B: B picks 4 (its 2 is taken). A is behind and picks 2? Taken, so 3. Merged [1, 2, 4, 3] with teams A, B, B, A. A click at position 1 credits B.
Rule: the team with fewer picks goes next, coin on ties; pick best item not yet shown; credit clicks by team.
It is standard practice for online ranking evaluation in search engines.