Coder Social home page Coder Social logo

shoelace's Introduction

Shoelace

Build Status Coverage Status

Shoelace is a neural Learning to Rank library using Chainer. The goal is to make it easy to do offline learning to rank experiments on annotated learning to rank data.

Documentation

Comprehensive documentation is available online here

Requirements

python3
numpy >= 1.12.0
chainer >= 2.0.0

Installation

pip install shoelace

Features

Dataset loading facilities

We currently provide ability to load learning to rank datasets (SVMRank format) into chainer.

from shoelace.dataset import LtrDataset

with open('./dataset.txt', 'r') as file:
    dataset = LtrDataset.load_txt(file)

Additionally, we provide minibatch iterators for Learning to Rank datasets. These generate variable-sized minibatches, where each minibatch represents one query and all associated query-document instances. You can additionally specify whether the iterator should repeat infinitely and/or shuffle the data on every epoch.

from shoelace.iterator import LtrIterator

iterator = LtrIterator(dataset, repeat=True, shuffle=True)

Loss functions

Currently we provide implementations for the following loss functions

  • Top-1 ListNet: shoelace.loss.listwise.listnet
  • ListMLE: shoelace.loss.listwise.listmle
  • ListPL: shoelace.loss.listwise.listpl

Example

Here is an example script that will train up a single-layer linear neural network with a ListNet loss function:

from shoelace.dataset import LtrDataset
from shoelace.iterator import LtrIterator
from shoelace.loss.listwise import listnet
from chainer import training, optimizers, links, Chain
from chainer.training import extensions

# Load data and set up iterator
with open('./path/to/ranksvm.txt', 'r') as f:
    training_set = LtrDataset.load_txt(f)
training_iterator = LtrIterator(training_set, repeat=True, shuffle=True)

# Create neural network with chainer and apply loss function
predictor = links.Linear(None, 1)
class Ranker(Chain):
    def __call__(self, x, t):
        return listnet(self.predictor(x), t)
loss = Ranker(predictor=predictor)

# Build optimizer, updater and trainer
optimizer = optimizers.Adam()
optimizer.setup(loss)
updater = training.StandardUpdater(training_iterator, optimizer)
trainer = training.Trainer(updater, (40, 'epoch'))
trainer.extend(extensions.ProgressBar())

# Train neural network
trainer.run()

Citing

If you find this project useful in your research, please cite the following paper in your publication(s):

Rolf Jagerman, Julia Kiseleva and Maarten de Rijke. "Modeling Label Ambiguity for Neural List-Wise Learning to Rank" (2017)

@article{jagerman2017modeling,
  title={Modeling Label Ambiguity for Neural List-Wise Learning to Rank},
  author={Jagerman, Rolf and Kiseleva, Julia and de Rijke, Maarten},
  journal={arXiv preprint arXiv:1707.07493},
  year={2017}
}

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.