Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

documents and demos for rank_cost and lambda_cost

Open CrossLee1 opened this issue 10 years ago • 3 comments

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 avatar Nov 02 '16 07:11 CrossLee1

@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_nets is 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_cost layer. label = 1 means d1 should be ranked higher than d2, and vice versa.
cost = rank_cost(left=out_left,
                 right=out_right,
                 label=label)

Hope this post is helpful :)

zhouxiao-coder avatar Nov 02 '16 08:11 zhouxiao-coder

@zhouxiao-coder Thanks a lot for the thorough explanation for the rank_cost layer~ It is very kind of you~

CrossLee1 avatar Nov 02 '16 08:11 CrossLee1

@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.

zhouxiao-coder avatar Nov 02 '16 09:11 zhouxiao-coder