28/31
Part 6 of 6 · What interviewers ask nextLearn and do

Interleaving puts both rankers on one page

Interleaving is faster. Each user sees one list that merges both rankers, and each click is credited to the ranker that contributed the clicked item. Radlinski, Kurup and Joachims's team-draft interleaving works like picking teams for a game. Each round a coin decides which ranker picks first, and each picks its best item that hasn't been taken:

import random

def team_draft(a: list[str], b: list[str], k: int) -> tuple[list[str], dict[str, str]]:
    """Interleaves rankings a and b into k items. Returns the shown list and each item's team."""
    shown, team = [], {}
    while len(shown) < k:
        n_a = sum(t == "A" for t in team.values())
        n_b = len(team) - n_a
        a_picks = n_a < n_b or (n_a == n_b and random.random() < 0.5)
        ranking, name = (a, "A") if a_picks else (b, "B")
        pick = next((d for d in ranking if d not in team), None)
        if pick is None:
            break
        shown.append(pick)
        team[pick] = name
    return shown, team

Read the loop body from the top:

  • team maps each shown item to the ranker that picked it, so n_a and n_b count each side's picks.
  • a_picks is true when A is behind, or when the sides are even and the coin, random.random() < 0.5, falls to A. Every even score starts a new round with a fresh flip.
  • The next line takes the picker's list and name together.
  • next((d for d in ranking if d not in team), None) is the first item on that list nobody has taken yet, or None when there isn't one.

Here are two rounds, where A ranks h1, h2, h3, h4, and B ranks h3, h1, h6, h2:

RoundCoinFirst pickSecond pick
1A firstA takes h1B takes h3
2B firstB takes h6, since h3 and h1 are goneA takes h2, since h1 is gone

Shown: h1 from A, h3 from B, h6 from B, then h2 from A.

Two coin flips give four possible lists, each with probability 1/4:

Coin flipsInterleaved list, with each item's team
A first, A firsth1 (A), h3 (B), h2 (A), h6 (B)
A first, B firsth1 (A), h3 (B), h6 (B), h2 (A)
B first, A firsth3 (B), h1 (A), h2 (A), h6 (B)
B first, B firsth3 (B), h1 (A), h6 (B), h2 (A)

Whichever ranker's items get more clicks wins the query. The share of wins over many queries says which ranker users prefer.

Airbnb credits bookings rather than clicks (1 source). In 2022 it reported a 50x speedup over an A/B test at the same traffic (1 source).

The speed comes from pairing. Every query compares both rankers on the same person at the same moment, so differences between people cancel. On arXiv's search engine, Radlinski and coauthors found that paired tests like these give substantially more accurate and sensitive results than absolute usage metrics. The coin flip matters as much. If one ranker always picked first, position bias alone would hand it more clicks.

Interleaving tells you which ranker users prefer, not how much bookings will move. The A/B test still makes the launch call.

In the editor, write winner(team, clicked): A, B or tie, by whose items got more clicks. team is the list shown in the example above, each item with the ranker that picked it. Then write preference(winners): A's share of the wins, leaving out the ties.