pytorch-examples
pytorch-examples copied to clipboard
Something Wrong with decay_diff ?
Hi~Thank you for providing such an excellent work! But I have some questions about the calculation of the "decay_diff" term. ( LambdaRank.py, line 197)
I noticed that you are using "sort_order" as the discounted factor.
Sort_order is the the indices that would sort Y, which means sort_order[0] is the index of the document which is the most relevant to the query. But this is not cosistent with the gain_diff calculation!
Gain_diff (i, j) is the gain difference between douc i and douc j,but decay_diff is not the decay difference between douc i and douc j.
@ownnaruto you could refer https://github.com/haowei01/pytorch-examples/blob/master/ranking/LambdaRank.py#L13 for the formula:
lambda += - N / (1 + exp(Si - Sj)) * (gain(rel_i) - gain(rel_j)) * |1/log(pos_i+1) - 1/log(pos_j+1)|
I will need to compute for document_i and document_j what is their position. I think the np.argsort would be able to do it, and provide the array result.
Please let me know if you have additional question