documents and demos for rank_cost and lambda_cost
I want to use the rank_cost layer and lambda_cost layer in paddle for training. Are there some documents or demos for these two costs for reference? Thanks~
@CrossLee1
Backgroud
These are cost layers used in problem known as Learning To Rank(LTR). rank_cost is an implementation of RankNet, and lambda_cost is an implementation of LambdaRank. You can check out this paper for a thorough introduction.
Current situation
PaddlePaddle doesn't have a document or demo dedicated to this specific topic for now. We are actually trying to find an open dataset for ranking to write a demo, but it may not be finished anytime soon.
Advice
If you decided to try it out anyway, PaddlePaddle documentation will be a good place to start.
Now let's take the pairwise method rank_cost for example.
Suppose you have a query q and two document d1, d2 to rank. You need to:
- firstly, design some network structure to capture the relation between query and document, which in the last layer outputs a real valued score. I will call this part of network
scorer_nets. To be clear,scorer_netsis not a specific PaddlePaddle layer, it can be any structure you choose to score the relation between query and document. - then you apply the _same_ architecture on both
(q d1)and(q d2). The key point is to use parameter sharing on both sides of network.
out_left = scorer_nets(input=[q, d1], parameter='parameter')
out_right = scorer_nets(input=[q, d2], parameter='parameter')
- finally, a
rank_costlayer.label = 1meansd1should be ranked higher thand2, and vice versa.
cost = rank_cost(left=out_left,
right=out_right,
label=label)
Hope this post is helpful :)
@zhouxiao-coder Thanks a lot for the thorough explanation for the rank_cost layer~ It is very kind of you~
@CrossLee1
Thanks for your appreciation :) LTR seems to be a very popular topic among PaddlePaddle users. We will try to make a demo in the future.