Skip to main content

Learning to Rank with PyTorch

Project description

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.6 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}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytorchltr-0.2.0.tar.gz (137.5 kB view details)

Uploaded Source

Built Distributions

pytorchltr-0.2.0-cp38-cp38-win_amd64.whl (106.4 kB view details)

Uploaded CPython 3.8 Windows x86-64

pytorchltr-0.2.0-cp38-cp38-manylinux1_x86_64.whl (345.4 kB view details)

Uploaded CPython 3.8

pytorchltr-0.2.0-cp38-cp38-macosx_10_14_x86_64.whl (106.7 kB view details)

Uploaded CPython 3.8 macOS 10.14+ x86-64

pytorchltr-0.2.0-cp37-cp37m-win_amd64.whl (105.4 kB view details)

Uploaded CPython 3.7m Windows x86-64

pytorchltr-0.2.0-cp37-cp37m-manylinux1_x86_64.whl (335.2 kB view details)

Uploaded CPython 3.7m

pytorchltr-0.2.0-cp37-cp37m-macosx_10_14_x86_64.whl (107.4 kB view details)

Uploaded CPython 3.7m macOS 10.14+ x86-64

pytorchltr-0.2.0-cp36-cp36m-win_amd64.whl (105.4 kB view details)

Uploaded CPython 3.6m Windows x86-64

pytorchltr-0.2.0-cp36-cp36m-manylinux1_x86_64.whl (336.3 kB view details)

Uploaded CPython 3.6m

pytorchltr-0.2.0-cp36-cp36m-macosx_10_14_x86_64.whl (107.1 kB view details)

Uploaded CPython 3.6m macOS 10.14+ x86-64

File details

Details for the file pytorchltr-0.2.0.tar.gz.

File metadata

  • Download URL: pytorchltr-0.2.0.tar.gz
  • Upload date:
  • Size: 137.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.2

File hashes

Hashes for pytorchltr-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3f4349367d9cb7cb98d28c5659180ea76a5c7a007557fbfd87cf60b1e0db50db
MD5 61ee7c391fdfb71713555a71c72b0aa7
BLAKE2b-256 8025926bada3a60b892885267baa80b6b937defc9cc23949c34796da054d8590

See more details on using hashes here.

File details

Details for the file pytorchltr-0.2.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: pytorchltr-0.2.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 106.4 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

File hashes

Hashes for pytorchltr-0.2.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 56a52ad9bbd5b80eb85cf08768c25383eb72b4bcc305e4feff1a040d015ad298
MD5 b13d5a1dc359d50ba0d55d7381298b0e
BLAKE2b-256 f7bd1064cbfd6eb08b8bbd0f03aa83b8765c70be89ae4550474c51a79e347ae5

See more details on using hashes here.

File details

Details for the file pytorchltr-0.2.0-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: pytorchltr-0.2.0-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 345.4 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

File hashes

Hashes for pytorchltr-0.2.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 5db122b33ccaa02a1ad354fd61ef6ff23f806430d8a4d63b8132a489b833c84c
MD5 4e00635827c098e0d649dbd9b30d8b41
BLAKE2b-256 a936e3099d272bc44976f5e9949c86bca360e40199c2d0fa003ccd01f4ef148e

See more details on using hashes here.

File details

Details for the file pytorchltr-0.2.0-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: pytorchltr-0.2.0-cp38-cp38-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 106.7 kB
  • Tags: CPython 3.8, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

File hashes

Hashes for pytorchltr-0.2.0-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 133e4282c444d282d430a1ed374a44f0a2a1eaac52cf5ab110454b6f65d537ad
MD5 5cc492ec27d331c785afff77a0fb8063
BLAKE2b-256 d1f41d1a55549655929aef743e34c81e77940f6df6ef21091e219a71f3ddb42c

See more details on using hashes here.

File details

Details for the file pytorchltr-0.2.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: pytorchltr-0.2.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 105.4 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.9

File hashes

Hashes for pytorchltr-0.2.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 00277ebf0624e88dbd4f3d409eb848ccf56f2445e4876ae75fb042fef99900db
MD5 56486440d931e9f35c7b23d24a34e1ab
BLAKE2b-256 ad7a5e4b61076acde2d91181393b08b0df2b20b50ea1b12fee424ab77c79f106

See more details on using hashes here.

File details

Details for the file pytorchltr-0.2.0-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pytorchltr-0.2.0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 335.2 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.9

File hashes

Hashes for pytorchltr-0.2.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ab2196899dd9057423424b38d00fc05a6bc2fe0a6fa9e4ad7da19e3b2ba3a0b2
MD5 69143e1278a73132ab45fafc937baba9
BLAKE2b-256 c89556699cce67db76112a2aac2e782fb6b62f525cefbcdd4cf8ae9894d2e1f2

See more details on using hashes here.

File details

Details for the file pytorchltr-0.2.0-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: pytorchltr-0.2.0-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 107.4 kB
  • Tags: CPython 3.7m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.9

File hashes

Hashes for pytorchltr-0.2.0-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 a27c9dfcf16e5189ddb469dcafff2eb636a6dc8179cd0c7ef66fc709b840270c
MD5 90c7b5fb5d16d7e3b790806d86d985cb
BLAKE2b-256 09c43c9052cbf55b866aa0c827ecaf7d8ec4995880cd11ca53ba16048c00feb9

See more details on using hashes here.

File details

Details for the file pytorchltr-0.2.0-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: pytorchltr-0.2.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 105.4 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.6.8

File hashes

Hashes for pytorchltr-0.2.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 46da1ed4a0235d84bb4d489d0ff011e0c0a188ab2bd1285b2c1096a25af319ee
MD5 61da2e9526b5a520e578c9c82f55724c
BLAKE2b-256 84412a41084da57b2af14dd016779c96bbcce9cc4f34e0d0c4cf60f85176cd31

See more details on using hashes here.

File details

Details for the file pytorchltr-0.2.0-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pytorchltr-0.2.0-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 336.3 kB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.6.12

File hashes

Hashes for pytorchltr-0.2.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3eee2363c3c47252b26e4c53e28d7a4e39e8786eb20a8d447f929ab8457b8b69
MD5 db7c2f39a2296ef1c2f179bbd1e294a1
BLAKE2b-256 ef6985b0ed986988dac84f1e0fb5f4f054fd6e2675f2b427646c8fb7764580eb

See more details on using hashes here.

File details

Details for the file pytorchltr-0.2.0-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: pytorchltr-0.2.0-cp36-cp36m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 107.1 kB
  • Tags: CPython 3.6m, macOS 10.14+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.6.12

File hashes

Hashes for pytorchltr-0.2.0-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 aa0126cbfefbbc43f3bfe6fec06b4eed2081074f9cbfe34bd15734d1a4a9ed43
MD5 aa281e817c7ba0aceab8223529e9213c
BLAKE2b-256 356fa62d9ecc07bf4fb95305ba63774aa7877698177d94645e674576b9c56f00

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page