GithubHelp home page GithubHelp logo

zhengjiawei001 / pytorchltr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rjagerman/pytorchltr

0.0 0.0 0.0 195 KB

Learning to Rank in PyTorch

Home Page: https://pytorchltr.readthedocs.io

License: MIT License

Python 90.29% C 9.71%

pytorchltr's Introduction

PyTorch Learning to Rank (LTR)

Build Documentation Coverage CodeFactor License

This is a library for Learning to Rank (LTR) with PyTorch. The goal of this library is to support the infrastructure necessary for performing LTR experiments in PyTorch.

Installation

In your virtualenv simply run:

pip install pytorchltr 

Note that this library requires Python 3.5 or higher.

Documentation

Documentation is available here.

Example

See examples/01-basic-usage.py for a more complete example including evaluation

import torch
from pytorchltr.datasets import Example3
from pytorchltr.loss import PairwiseHingeLoss

# Load dataset
train = Example3(split="train")
collate_fn = train.collate_fn()

# Setup model, optimizer and loss
model = torch.nn.Linear(train[0].features.shape[1], 1)
optimizer = torch.optim.SGD(model.parameters(), lr=0.1)
loss = PairwiseHingeLoss()

# Train for 3 epochs
for epoch in range(3):
    loader = torch.utils.data.DataLoader(train, batch_size=2, collate_fn=collate_fn)
    for batch in loader:
        xs, ys, n = batch.features, batch.relevance, batch.n
        l = loss(model(xs), ys, n).mean()
        optimizer.zero_grad()
        l.backward()
        optimizer.step()

Dataset Disclaimer

This library provides utilities to automatically download and prepare several public LTR datasets. We cannot vouch for the quality, correctness or usefulness of these datasets. We do not host or distribute these datasets and it is ultimately your responsibility to determine whether you have permission to use each dataset under its respective license.

Citing

If you find this software useful for your research, we kindly ask you to cite the following publication:

@inproceedings{jagerman2020accelerated,
    author = {Jagerman, Rolf and de Rijke, Maarten},
    title = {Accelerated Convergence for Counterfactual Learning to Rank},
    year = {2020},
    publisher = {Association for Computing Machinery},
    address = {New York, NY, USA},
    booktitle = {Proceedings of the 43rd International ACM SIGIR Conference on Research and Development in Information Retrieval},
    doi = {10.1145/3397271.3401069},
    series = {SIGIR’20}
}

pytorchltr's People

Contributors

rjagerman avatar dependabot[bot] avatar

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.