airalcorn2/RankNet

Why lamb_upates missing a negative sign

huangyue opened this issue · 1 comments

in lambdarank.py:

lamb_updates = 1 / (1 + exped) * N * dcg_diffs.abs()

but equation (6) in [2]:
lamb(i, j) = -1 / (1 + exped) * N * dcg_diffs.abs()

See the accompanying text in [2] along with equation (9) in [1] and its accompanying text. Specifically:

"Thus for each pair, after the sort, we increment each document’s force by ±λ, where the more relevant document gets the positive increment."

You'll notice that's what I'm doing here. The key thing to understand is that the λs are supposed to help increase the scores of the relevant documents and decrease the scores of the irrelevant documents. Because the partial derivative of the score node with respect to any of its input weights gives the direction you need to move to increase the score, multiplying it by a positive λ keeps the direction the same, which is what we want for relevant documents, while multiplying it by a negative λ reverses the direction, which is what we want for irrelevant documents.