position-debiasing

The mechanism through which position bias impacts a model is that:

  • some items tend to appear higher / more frequently on screen
  • thus the model will assign a higher score to those specific items (or when it sees features associated with those specific items) more than what is due i.e. confounding.

there are two things:

  • correcting the model for position bias
  • correcting evaluation metrics for position bias

We assume the following causal model:

Let:

  • uu be a user and ii be an item. x=(u,i)x = (u, i) represents the context.
  • k∈{1,2,…,K}k \in \{1, 2, \dots, K\} be the rank/position of item ii displayed to user uu.
  • R∈{0,1}R \in \{0, 1\} be the true relevance (unobserved). R=1R=1 if the user would engage with the item provided they examined it.
  • O∈{0,1}O \in \{0, 1\} be the examination (unobserved). O=1O=1 if the user examines the item at position kk.
  • C∈{0,1}C \in \{0, 1\} be the click (observed).

This model asserts that a click occurs if and only if the item is both examined and relevant: C=O⋅RC = O \cdot R

The probability of a click is given by:

P(C=1∣x,k)=P(O=1∣k)⋅P(R=1∣x)=pk⋅P(R=1∣x)\mathbb{P}(C=1 \mid x, k) = \mathbb{P}(O=1 \mid k) \cdot \mathbb{P}(R=1 \mid x) = p_k \cdot \mathbb{P}(R=1 \mid x)

Because C=O⋅RC = O \cdot R, and because O⊥ ⁣ ⁣ ⁣⊥R∣x,kO \perp\!\!\!\perp R \mid x, k, the expectation over their joint distribution factors into the product of their marginal expectations:

EO,R[C∣x,k]=EO,R[O⋅R∣x,k]=EO[O∣k]⋅ER[R∣x]=pk⋅P(R=1∣x)\mathbb{E}_{O,R}[C \mid x, k] = \mathbb{E}_{O,R}[O \cdot R \mid x, k] = \mathbb{E}_O[O \mid k] \cdot \mathbb{E}_R[R \mid x]=p_k \cdot \mathbb{P}(R=1 \mid x)

(since OO and RR are Bernoulli variables, their expectations are their probabilities)

Thus:

ER[R∣x]=P(R=1∣x)=EC[Cpk∣x,k]\mathbb{E}_R[R \mid x] = \mathbb{P}(R=1 \mid x) = \mathbb{E}_{C}[ \frac{C}{p_k} \vert x, k]

I - inverse propensity weighting

Instead of learning a biased quantity P(C=1∣x,k)\mathbb{P}(C=1|x,k), learn true relevance P(R=1∣x)=E[Cpk∣x]\mathbb{P}(R=1 | x)=\mathbb{E}\bigg[\frac{C}{p_k}\vert x\bigg] (which is an unbiased estimator for relevance).

We can formulate the expected loss of a single item with respect to that item’s relevance:

ER[l(y,y^)∣x]=P(R=1∣x)l(1,y^)+(1−P(R=1∣x))l(0,y^)\mathbb{E_R}[l(y,\hat{y}) | x] = \mathbb{P}(R=1 | x)l(1,\hat{y}) + (1-\mathbb{P}(R=1 | x))l(0, \hat{y}) where l(y,y^)l(y, \hat{y}) is the loss function.

Since we have an unbiased estimator for the item’s relevance, we can plug it into the above formula:

ER[l(y,y^∣x)]=EC[Cpk∣x,k]ℓ(1,y^)+(1−EC[Cpk∣x,k])ℓ(0,y^)\mathbb{E_R}[l(y,\hat{y}|x)] = \mathbb{E}_C\left[ \frac{C}{p_k} \mathrel{\Big|} x, k \right] \ell(1,\hat{y}) + \left( 1 - \mathbb{E}_C\left[ \frac{C}{p_k} \mathrel{\Big|} x, k \right] \right) \ell(0,\hat{y})

Because ℓ(1,y^)\ell(1,\hat{y}) and ℓ(0,y^)\ell(0,\hat{y}) are deterministic functions with respect to the model's predictions, we can pull them inside the expectation over CC by the linearity of expectation:ER[l(y,y^∣x)]=EC[Cpkℓ(1,y^)+(1−Cpk)ℓ(0,y^)∣x,k]\mathbb{E_R}[l(y,\hat{y}\vert x)] = \mathbb{E}_C\left[ \frac{C}{p_k}\ell(1,\hat{y}) + \left(1-\frac{C}{p_k}\right)\ell(0,\hat{y}) \mathrel{\Big|} x, k \right]

Finally, an estimator of the above loss function is:

1N∑j=1N[cjpkjℓ(1,y^j)+(1−cjpkj)ℓ(0,y^j)]\frac{1}{N} \sum_{j=1}^N \left[ \frac{c_j}{p_{k_j}}\ell(1,\hat{y}_j) + \left(1-\frac{c_j}{p_{k_j}}\right)\ell(0,\hat{y}_j) \right]

Where we can replace ll by the log loss.

References:

  • [https://decisionmaking4ir.github.io/WSDM-2022/papers/Suguru.pdf](Unbiased Recommender Learning from Biased Graded Implicit Feedback)

II - Late fusion position feature

We still assume the same model:

P(C=1∣x,k)=P(O=1∣k)⋅P(R=1∣x)\mathbb{P}(C=1 \mid x, k) = \mathbb{P}(O=1 \mid k) \cdot \mathbb{P}(R=1 \mid x)

and split the model into two towers:

  • the main tower: a deep neural network fθ(x)f_{\theta}(x) that takes only user and item features. This parameterizes the true relevance.
  1. the shallow tower: a very simple network (just an embedding layer or a single linear layer) gϕ(k)g_{\phi}(k) that takes only the position kk (and potentially other bias features like device type). This parameterizes the observation probability.

We fuse these two towers only at the very end, in logit space, right before the final sigmoid activation function:

logit(C)=fθ(x)+gϕ(k)\text{logit}(C) = f_{\theta}(x) + g_{\phi}(k) Implementation details from Google's paper:

  • 10% position feature drop-out rate to prevent over-reliance on position
  • at serving time, position is treated as missing
  • they actually cross position feature with device info because different types of devices exhibit different position biases

Ref: Recommending What Video to Watch Next: A Multitask Ranking System

Question: don't we still learn a biased quantity, if we learn the click label?

Instead of correcting click for position bias, we force the model's architecture to mirror the causal mechanism that generated the biased data, hoping that the network naturally disentangles the hidden variables. We are performing Maximum Likelihood Estimation (MLE) of a model that separates the relevance parameters from the position bias parameters. Mechanically, the shallow tower provides the easy gradient that items at k=1k=1 are universally clicked more often, while the main tower is forced to explain whatever variation is left over.

Mesuring position bias p_k

We need to actually measure position bias to generate the corrected biased used in inverse propensity weighting

Ref: Position Bias Estimation for Unbiased Learning to Rank in Personal Search

The paper depicts 3 approaches to estimate the propensity of every position k:

  • Randomize TopN (result randomization): top N documents are randomly shuffled
  • Randomize Pair (result randomization, smaller intervention): randomly swap adjacent positions
  • Estimation from Regular Clicks using the Expectation Maximization algorithm: user is not exposed to any randomized results, but accuracy is lower

Randomize Top N

the relevance component rq,dr_{q,d} is hidden. We can average out this variable by randomizing the result list. For a randomized dataset where the top N documents are randomly shuffled before showing them to users, let RkR_k be the subset of collected logs from position kk.

E[C∣k]=∑q,d∈RkE[C∣q,d,k]P(q,d)=∑q,d∈Rkpkrq,dP(q,d)=pk∑q,d∈RkP(q,d)∝pk\mathbb{E}[C|k]=\sum_{q,d\in R_k} \mathbb{E}[C\vert q,d,k]\mathbb{P}(q,d)=\sum_{q,d\in R_k}p_k r_{q,d} \mathbb{P}(q,d) =p_k \sum_{q,d\in R_k} \mathbb{P}(q,d)\propto p_k

since ∑q,d∈RkP(q,d)\sum_{q,d\in R_k}\mathbb{P}(q,d) is constant across all NN positions (can be thought of as the average relevance of the candidate pool).

We can just normalize all propensities and return pk/p0p_k/p_0

Randomize Pair

Let us denote dkd_k a document that is originally at position kk. Recall that our model assumes P(C∣q,dk)=pkrq,dk\mathbb{P}(C\vert q,d_k)=p_k r_{q,d_k}

By swapping documents kk and k+1k+1 in the final results, the user now needs to examine position k+1k+1 to see document dkd_k:

P(C∣q,dk,swap)=pk+1rq,dk\mathbb{P}(C\vert q,d_k,\text{swap})=p_{k+1}r_{q,d_k}

Thus:

P(C∣q,d,swap)P(C∣q,d,no swap)=pk+1pk\frac{\mathbb{P}(C\vert q,d,\text{swap})}{\mathbb{P}(C\vert q,d,\text{no swap})} = \frac{p_{k+1}}{p_k}

Meaning, if we can estimate the probabilities on the left-hand side, we can estimate the position bias of k+1k+1 with respect to kk.

Now, notice that both quantities on the left-hand side are click through rates (conditioned on query, document and whether we swap or not). Let us denote DkD_k the set of documents that were originally in position kk, for a query qq:

E[C∣Dk,no swap]=∑q,d∈DkE[C∣q,d,k,no swap]P(q,d)=∑q,d∈DkP(C∣q,d,k,no swap)P(q,d)=∑q,d∈Dkpkrq,dP(q,d)=pk∑q,d∈Dkrq,dP(q,d)\begin{aligned}\mathbb{E}[C\vert D_k, \text{no swap}] &= \sum_{q,d\in D_k} \mathbb{E}[C\vert q,d,k,\text{no swap}]\mathbb{P}(q,d) \\& = \sum_{q,d\in D_k} \mathbb{P}(C\vert q,d,k,\text{no swap})\mathbb{P}(q,d) \\&= \sum_{q,d\in D_k}p_k r_{q,d}\mathbb{P}(q,d) \\&= p_k \sum_{q,d\in D_k} r_{q,d}\mathbb{P}(q,d)\end{aligned}

Similarly: E[C∣Dk,swap]=pk+1∑q,d∈Dkrq,dP(q,d)\mathbb{E}[C\vert D_k, \text{swap}] = p_{k+1}\sum_{q,d\in D_k}r_{q,d}\mathbb{P}(q,d)

both expectations can be estimated by taking the sum of clicks, conditioned on the proper variables. i.e.:

pk+1pk=avg number of clicks for position k with swapavg number of clicks for position k without swap\frac{p_{k+1}}{p_k} = \frac{\text{avg number of clicks for position k with swap}}{\text{avg number of clicks for position k without swap}}

The relative ratio between any two positions is given by the chaining the ratios: pkp1=pkpk−1…p2p1\frac{p_k}{p_1} = \frac{p_k}{p_{k-1}}\dots\frac{p_2}{p_1}

We can see the limitations of the position bias model by performing RandomizeTopN:

  • after L2 scoring (L2 set)
  • without L2 scoring (L1 set)

the propensity values will display different curves, showing that they are not independent of the relevance of the document set. In the L2 set, whatever item randomization drops into position 0 is likely to be good, so the user is often satisfied immediately and stops scanning. Examination at lower positions collapses which explains the steep decay. The next step would be to move to a cascade-aware or relevance-conditioned propensity model.

When applying filters for analysis (e.g. US users only, initial impressions without scrolling, 9+ results), make sure they are all unaffected by the treatment (pre-treatment filters).

Some filters are necessary. For example, some sessions might display less than NN candidates. This adds a bias towards earlier positions and we will only retain sessions with more than NN candidates displayed.

other methods for correcting position bias

1. randomized exploration

Rather than correcting observational bias retrospectively, this approach alters the data generation process. A small fraction of user traffic is subjected to a policy where items are ranked uniformly at random.

recall the original data generation process:


r -> k -> o

 \       /

  \     /

   v   v

   click 

this treatment removes the causal link between relevance (r) and position (k) meaning:

P(C∣do(randomize))=P(C∣r)P(r)+P(C∣o)P(o∣k)⏟pkP(k)⏟∼U\mathbb{P}(C \vert \text{do(randomize)})=\mathbb{P}(C|r)\mathbb{P}(r)+\mathbb{P}(C|o)\underbrace{\mathbb{P}(o|k)}_{p_k}\underbrace{\mathbb{P}(k)}_{\sim \mathbb{U}}

whereas before:

P(C)=P(r)⋅(P(C∣r)+P(C∣o)P(o∣k)P(k∣r))\mathbb{P}(C) = \mathbb{P}(r)\cdot(\mathbb{P}(C|r)+\mathbb{P}(C|o)\mathbb{P}(o|k)\mathbb{P}(k|r))

Under a purely random policy, the position assignment kk is perfectly independent of the item covariates xx. Consequently, pkp_k becomes a known uniform constant, and the resulting interaction logs are mathematically guaranteed to be an unbiased sample of true relevance. This data can be used as a pristine validation set or to perfectly calibrate propensity scores for the rest of the dataset.

sequential / cascade click models

Until now, our model (click = observation x relevance) was point-wise: it assumed that the probability of observing the item at position kk is independent of the items placed above it. Instead, cascade models use a Markovian process where the user scans a list linearly from top to bottom.

A user observes position kk iff they observed k−1k-1 and did not find it relevant enough to terminate their search.

P(Ok=1)=P(Ok−1=1)⋅P(Rk−1=0)P(O_k=1) = P(O_{k-1}=1) \cdot P(R_{k-1}=0)

instead of being fixed, the propensity pkp_k is context-dependent.

other approaches worth looking into:

  • heckman sample selection (mills ratio)
  • unbiased pairwise and listwise ranking: debias ranking functions like LambdaMART that optimize relative order by applying inverse propensity weighting to the pairwise gradient.

Evaluation

offline metrics (AUC)

Since click is confounded by position bias, so are offline metrics. We expect a debiased model to:

  • perform worse on the regular (biased) logs
  • perform better on the debiased logs

We can correct AUC inverse propensity weighting (IPS-AUC) and determine if this improves the offline / online correlation (AUC percent difference vs CTR percent difference for example).

online metrics

if the only difference between Model A and Model B is how we handle the position bias correction (IPW correction, late fusion position feature), then any engagement gains in the A/B test are strictly caused by position bias correction.

However this does not tell us the extent to which we successfully eliminated position bias from our model. I haven't found any convincing way to evaluate this.

head vs tail analysis

If we expect the change to reduce popularity bias and increase exposure to tail items, we can group items by historical exposure and verify that we see most gains on tail items.