Giter Site home page Giter Site logo

airalcorn2 / ranknet Goto Github PK

View Code? Open in Web Editor NEW
247.0 8.0 48.0 19 KB

My (slightly modified) Keras implementation of RankNet and PyTorch implementation of LambdaRank.

License: MIT License

Python 100.00%
learning-to-rank ltr machine-learning deep-learning neural-network information-retrieval

ranknet's Introduction

RankNet and LambdaRank

My (slightly modified) Keras implementation of RankNet (as described here) and PyTorch implementation of LambdaRank (as described here). See here for a tutorial demonstating how to to train a model that can be used with Solr.

ranknet's People

Contributors

airalcorn2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ranknet's Issues

Some confuses about ranknet

Hi,

Sorry to disturb you. For me I have confused about the weight that the network learned. This means that for each query [q1,q2,...qn] with documents[d1,d2....dm] the network will learn the w1i[w11,w12....] for the query1 and w2i[w21,w22....] for the query2? Could you please give me some helps. Thank you very much.

Sean

split batches in one query for LambdaRank

Hi @airalcorn2 ,

Thanks for your clear code.

I am a little confused about LambdaRank that I hope you can help with. If I have a total of 2560 docs in one query, can I split it into 10 batches to do 10 backwards, or I have to include all 2560 docs in one batch to do 1 backward. Thanks.

network prediction examples

My 2 cents: The last part of your code generating scores was unclear to me.
Instead, the below exemplified how the trained network outputs 1 when the two vectors are uncorrelated, and something close to 0.5 when they are.
Feel free to add it to your code.
Also, maybe a jupyter notebook would make more sense, as it can display in github the results without you having to copy paste them in-line the code as comments.

(Pdb) model.predict([X_1[0:1,:], np.zeros(shape=(1,50))])
array([[0.9999989]], dtype=float32)
(Pdb) model.predict([X_1[0:1,:], np.ones(shape=(1,50))])
array([[0.9999285]], dtype=float32)
(Pdb) model.predict([X_1[0:1,:], np.random.randn(N, INPUT_DIM)])
array([[0.99992096]], dtype=float32)
(Pdb) model.predict([X_1[0:1,:], X_1[0:1,:]])
array([[0.5]], dtype=float32)
(Pdb) model.predict([X_1[0:1,:], X_2[0:1,:]])
array([[0.9995178]], dtype=float32)
(Pdb) model.predict([X_1[0:1,:], X_1[0:1,:]+0.1])
array([[0.47106665]], dtype=float32)
(Pdb) model.predict([X_1[0:1,:], X_1[0:1,:]+0.2])
array([[0.44332358]], dtype=float32)
(Pdb) model.predict([X_1[0:1,:], X_1[0:1,:]-0.2])
array([[0.5630561]], dtype=float32)
(Pdb) model.predict([X_1[0:1,:], X_1[0:1,:]+0.1*np.random.randn(N, INPUT_DIM)])
array([[0.46504748]], dtype=float32)
(Pdb) model.predict([X_1[0:1,:], X_1[0:1,:]+0.1*np.random.randn(N, INPUT_DIM)])
array([[0.5252977]], dtype=float32)
(Pdb) model.predict([X_1[0:1,:], X_1[0:1,:]+0.1*np.random.randn(N, INPUT_DIM)])
array([[0.4684026]], dtype=float32)

Ranknet to Predict New Query

Hi,
I have question regarding your keras implementation of Ranknet:
How to feed features of a new one query to the model to predict the ranking list ?

thank you

Should we randomly change the order of rel_doc, irr_doc pair?

Hi,
In my training data, there are two columns rel_doc and irr_doc,
which means the ranking of doc in pos_doc should be higher than the one in irr_doc.
If the model input is a (rel_doc, irr_doc) pair,
then all of the label(ground truth) will be just 1.
Should we randomly change the order of rel_doc, irr_doc pair and convert the label to -1?

ps. In the paper From RankNet to LambdaRank to
LambdaMART: An Overview, it say the cost function is symmetric while swapping i,j and change label(S_ij) from 1 to -1,
but in my case, the S_ij is fixed(S_ij=1 or say S_ji=-1).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.