All Projects → eggie5 → RankNet

eggie5 / RankNet

Licence: other
Learning to Rank from Pair-wise data

Programming Languages

Jupyter Notebook
11667 projects

Projects that are alternatives of or similar to RankNet

TwinBert
pytorch implementation of the TwinBert paper
Stars: ✭ 36 (-10%)
Mutual labels:  ranking, siamese-network
One-Shot-Learning-with-Siamese-Networks
Implementation of One Shot Learning using Convolutional Siamese Networks on Omniglot Dataset
Stars: ✭ 129 (+222.5%)
Mutual labels:  siamese-network
oneshot-audio
Experiment with "one-shot learning" techniques to recognize a voice signature
Stars: ✭ 22 (-45%)
Mutual labels:  siamese-network
one-shot-steel-surfaces
One-Shot Recognition of Manufacturing Defects in Steel Surfaces
Stars: ✭ 29 (-27.5%)
Mutual labels:  siamese-network
github-user-rank-extension
Your Github fame is getting closer with every open-source project you've built and promoted, with every new follower starring, using and forking your solution. This extension supplements every Github developer profile with language bars that show how far they've advanced on their road to the glory among %that_programming_language% community memb…
Stars: ✭ 38 (-5%)
Mutual labels:  ranking
wikidata-qrank
Ranking signals for Wikidata
Stars: ✭ 31 (-22.5%)
Mutual labels:  ranking
Deep-One-Shot-Logo-Retrieval
A Deep One-Shot Network for Query-based Logo Retrieval [Pattern Recognition 2019, Elsevier]
Stars: ✭ 58 (+45%)
Mutual labels:  siamese-network
PageRank
Page Rank library for Javascript
Stars: ✭ 23 (-42.5%)
Mutual labels:  ranking
Siamese Network MNIST
Siamese Network on MNIST Dataset
Stars: ✭ 17 (-57.5%)
Mutual labels:  siamese-network
visual-compatibility
Context-Aware Visual Compatibility Prediction (https://arxiv.org/abs/1902.03646)
Stars: ✭ 92 (+130%)
Mutual labels:  siamese-network
LTRpred
De novo annotation of young retrotransposons
Stars: ✭ 35 (-12.5%)
Mutual labels:  ltr
dialectID siam
Dialect identification using Siamese network
Stars: ✭ 15 (-62.5%)
Mutual labels:  siamese-network
pytorch-siamese-triplet
One-Shot Learning with Triplet CNNs in Pytorch
Stars: ✭ 74 (+85%)
Mutual labels:  siamese-network
PREREQ-IAAI-19
Inferring Concept Prerequisite Relations from Online Educational Resources (IAAI-19)
Stars: ✭ 22 (-45%)
Mutual labels:  siamese-network
cyberrating
🚥 S&P of Blockchains
Stars: ✭ 13 (-67.5%)
Mutual labels:  ranking
ChangeFormer
Official PyTorch implementation of our IGARSS'22 paper: A Transformer-Based Siamese Network for Change Detection
Stars: ✭ 220 (+450%)
Mutual labels:  siamese-network
FaceRecog
Realtime Facial recognition system using Siamese neural network
Stars: ✭ 47 (+17.5%)
Mutual labels:  siamese-network
vote-schulze
Vote calculation with Schulze method (Condorcet voting)
Stars: ✭ 23 (-42.5%)
Mutual labels:  ranking
Facial-Recognition-Using-FaceNet-Siamese-One-Shot-Learning
Implementation of Facial Recognition System Using Facenet based on One Shot Learning Using Siamese Networks
Stars: ✭ 104 (+160%)
Mutual labels:  siamese-network
Quick-Data-Science-Experiments-2017
Quick-Data-Science-Experiments
Stars: ✭ 19 (-52.5%)
Mutual labels:  ranking

RankNet

Learning to Rank from Pair-wise data

Given a set of items, there is value in being able to rank them from best to worst. A common way to do this is to have a scoring function and then pasing the items in the set through the scoring function, then sorting the scores to give an overall rank. There is a way to learn the scoring function by using pairwise data: in this scenario, we take a pair where one item is higher ranked than the other and then we pass it through a scoring function and try to maximize the difference between the two scores. If we are able to consitently differentiate between the pairs, then we will have been able to learn a scoring function.

I was originally exposed to this technique in the Learning to rank [1] paper by Burges. This paper uses pair-wise data and a Siamese Archecture to learn a scoring function.

For the full code see the github repo: https://github.com/eggie5/RankNet/blob/master/RankNet.ipynb

Archecture

siamese-net

Figure 1: Siamese Nework - Scores between pairs are maximized using binary cross-entropy

Base Network/Scoring Function

This is scoring function is a regression which takes an embedding (some vector describing the item to be scored/ranked) and outputs a single neuron: the score of the item. The network is composed of two of these, one for each item in the pair.

In Figure 1 above, the base network is a Deep CNN w/ the traditional softmax removed from the end and replaced w/ a single neuron. The inputs A & B are of course images.

def create_base_network(input_dim):
    seq = Sequential()
    seq.add(Dense(input_dim, input_shape=(input_dim,), activation='relu'))
    seq.add(Dropout(0.1))
    seq.add(Dense(64, activation='relu'))
    seq.add(Dropout(0.1))
    seq.add(Dense(32, activation='relu'))
    seq.add(Dense(1))
    return seq

Meta Network

The Meta Network takes the outputs of the base network and takes the difference. The cost function then returns a proporital positive on how big the differnece is between the two pairs and a negative feedback if the difference is negative (meaning the ranking was incorrect).

def create_meta_network(input_dim, base_network):
    input_a = Input(shape=(input_dim,))
    input_b = Input(shape=(input_dim,))

    rel_score = base_network(input_a)
    irr_score = base_network(input_b)

    # subtract scores
    diff = Subtract()([rel_score, irr_score])

    # Pass difference through sigmoid function.
    prob = Activation("sigmoid")(diff)

    # Build model.
    model = Model(inputs = [input_a, input_b], outputs = prob)
    model.compile(optimizer = "adam", loss = "binary_crossentropy")

    return model

meta

Figure 2: Siamese Network diagram - The Sequential block in the diagram is any type of function which takes the input vector and outputs a scalar. In this example it's a Neural Network which is learnt. We then subtract the two scores from the pair and pass that to the Activation Sigmoid which is then used in the cost function.

Data & Cost Function

We can use the binary cross-entropy cost function w/ the pairwise data. The label for an instance is a number between 1-0 where 0 means that the right item is 100% more important .5 means the pair is equal and 1 means the left item is 100% more important. The binary cross entropy then compare the sigmoid of the predicted score (probability) w/ the actual probability which then gives feedback to the gradient descent backprop routine.

$$ C_{ij} = - \hat{P_{ij}}o_{ij} + \log(1+e^{o_{ij}}) $$

where $o_{ij}$ is the difference of the output from the scoring function for both items of the pair $i$ and $j$.

learning_to_rank_pdf__page_4_of_8_

Figure 3: Example values of the cost function for 3 different class labels. For example if the training example is a 1, this means the left item is higher ranked. Therefore $C_{ij}$ is very small when the difference is positive large and vary large when the difference is negative giving feedback to the backprop.

Case Study: Ranking Search Results

This was the original use-case explored in the paper: how to more effectivly sort search results. They looked at past examples of click stream data and quries and learnt a scoring function to help sort the results.

Case Study: Image Selection

A common use-case for these types of networks is to automate the selection of an image from a set of images in order to choose the best one by some criteria. The training data would be annotated pairs where the labels would be which image is better according to the criteria. For example, the best quality image. Expedia and trip advisor did something like this to help automate and scale up the default image selection process of a hotel's landing page. For example, show a nice picture of the view or room then the toilet as the first image the user sees.

[1] Burges, Chris, et al. "Learning to rank using gradient descent." Proceedings of the 22nd international conference on Machine learning. ACM, 2005.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].