PyTorch Learning to Rank (LTR)
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}
}
Metadata
Release files for pytorchltr 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytorchltr-0.2.1.tar.gz | 144.0 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| pytorchltr-0.2.1-cp38-cp38-win_amd64.whl | CPython 3.8 | CPython 3.8 | Windows x86-64 | Details |
| pytorchltr-0.2.1-cp38-cp38-manylinux1_x86_64.whl | CPython 3.8 | CPython 3.8 | Linux glibc 2.5+ x86-64 | Details |
| pytorchltr-0.2.1-cp38-cp38-macosx_10_14_x86_64.whl | CPython 3.8 | CPython 3.8 | macOS 10.14+ x86-64 | Details |
| pytorchltr-0.2.1-cp37-cp37m-win_amd64.whl | CPython 3.7 | CPython 3.7 pymalloc | Windows x86-64 | Details |
| pytorchltr-0.2.1-cp37-cp37m-manylinux1_x86_64.whl | CPython 3.7 | CPython 3.7 pymalloc | Linux glibc 2.5+ x86-64 | Details |
| pytorchltr-0.2.1-cp37-cp37m-macosx_10_14_x86_64.whl | CPython 3.7 | CPython 3.7 pymalloc | macOS 10.14+ x86-64 | Details |
| pytorchltr-0.2.1-cp36-cp36m-win_amd64.whl | CPython 3.6 | CPython 3.6 pymalloc | Windows x86-64 | Details |
| pytorchltr-0.2.1-cp36-cp36m-manylinux1_x86_64.whl | CPython 3.6 | CPython 3.6 pymalloc | Linux glibc 2.5+ x86-64 | Details |
| pytorchltr-0.2.1-cp36-cp36m-macosx_10_14_x86_64.whl | CPython 3.6 | CPython 3.6 pymalloc | macOS 10.14+ x86-64 | Details |
| pytorchltr-0.2.1-cp35-cp35m-win_amd64.whl | CPython 3.5 | CPython 3.5 pymalloc | Windows x86-64 | Details |
| pytorchltr-0.2.1-cp35-cp35m-manylinux1_x86_64.whl | CPython 3.5 | CPython 3.5 pymalloc | Linux glibc 2.5+ x86-64 | Details |
| pytorchltr-0.2.1-cp35-cp35m-macosx_10_15_x86_64.whl | CPython 3.5 | CPython 3.5 pymalloc | macOS 10.15+ x86-64 | Details |
Total release size: 2.3 MB
Release files / pytorchltr-0.2.1.tar.gz
| Download URL | pytorchltr-0.2.1.tar.gz |
|---|---|
| Size | 144.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
58d60f1da45ab73d29f9594922b9ee601a7f65b42759585baba799f83b0fc945
|
|
BLAKE2b-256 checksum How to use checksums |
c0aee9d44249dd7a7e4b46d3ec6ba563078d2d915635c451c5b60a8b22468715
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / pytorchltr-0.2.1-cp38-cp38-win_amd64.whl
| Download URL | pytorchltr-0.2.1-cp38-cp38-win_amd64.whl |
|---|---|
| Size | 106.5 kB |
| Tags | CPython 3.8 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f5e95b7476a1716e489dd8d1402722713dfb50bb6574dc4d66a737983577e55f
|
|
BLAKE2b-256 checksum How to use checksums |
150ec8c3ff4e7a0db0c2074f0c95fa5a50819fa069a1a8352be67fa07fd111cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / pytorchltr-0.2.1-cp38-cp38-manylinux1_x86_64.whl
| Download URL | pytorchltr-0.2.1-cp38-cp38-manylinux1_x86_64.whl |
|---|---|
| Size | 345.4 kB |
| Tags | CPython 3.8 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
eadf7ca46392870cdb21588adb65c7a7a62f7efb79fb88bab669694602365bac
|
|
BLAKE2b-256 checksum How to use checksums |
7f749e4e19ceb14a1b04172149a4a956ff4ea9d25f0bb65518d3ff5766221daf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / pytorchltr-0.2.1-cp38-cp38-macosx_10_14_x86_64.whl
| Download URL | pytorchltr-0.2.1-cp38-cp38-macosx_10_14_x86_64.whl |
|---|---|
| Size | 106.8 kB |
| Tags | CPython 3.8 macOS 10.14+ x86-64 |
|
SHA-256 checksum How to use checksums |
f82dafe4661ec430f0a2b0b518a9de2ab66501248bdee5b544132798bdc249e4
|
|
BLAKE2b-256 checksum How to use checksums |
6cd8306ead8a4b2854e1f6fbc28ac83cae705f8baef0dced9fc90a47a8d928e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / pytorchltr-0.2.1-cp37-cp37m-win_amd64.whl
| Download URL | pytorchltr-0.2.1-cp37-cp37m-win_amd64.whl |
|---|---|
| Size | 105.4 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
39e9c9dee4f70b41c7062d688e654670ca542906667e9a6a2071ced00751d1fc
|
|
BLAKE2b-256 checksum How to use checksums |
ffa76894ce5bddb63ecb37c8146ddced376d60994ddde4831755486b0b592301
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / pytorchltr-0.2.1-cp37-cp37m-manylinux1_x86_64.whl
| Download URL | pytorchltr-0.2.1-cp37-cp37m-manylinux1_x86_64.whl |
|---|---|
| Size | 335.2 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
cdfc2730c018d5e8146d5ba07882de804d8a1ca186382aa845ef03ef3aff2f6c
|
|
BLAKE2b-256 checksum How to use checksums |
ffbc0eec0fd2113410d6ea180e10e661cea066b3e50b74b44dd82983bd9442b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / pytorchltr-0.2.1-cp37-cp37m-macosx_10_14_x86_64.whl
| Download URL | pytorchltr-0.2.1-cp37-cp37m-macosx_10_14_x86_64.whl |
|---|---|
| Size | 107.4 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc macOS 10.14+ x86-64 |
|
SHA-256 checksum How to use checksums |
2feee5e649f0b8625e4f3239bf0447fcba2e874ed921c0db9b969931be1eb131
|
|
BLAKE2b-256 checksum How to use checksums |
e7143c506f3c91d40a99ac0c7a2feccfa129caf24b49a9eec4d66eaf15ee2df8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / pytorchltr-0.2.1-cp36-cp36m-win_amd64.whl
| Download URL | pytorchltr-0.2.1-cp36-cp36m-win_amd64.whl |
|---|---|
| Size | 105.4 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a109becf65693ddc4694cd782e02fa637a37fe1fbeed09ff1a42e9ba130fa241
|
|
BLAKE2b-256 checksum How to use checksums |
5eb2b9b412cc9fa23db20b0a3be64f5cd50881891125dd358cb21c4bdbe998f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / pytorchltr-0.2.1-cp36-cp36m-manylinux1_x86_64.whl
| Download URL | pytorchltr-0.2.1-cp36-cp36m-manylinux1_x86_64.whl |
|---|---|
| Size | 336.3 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
afedbafdd216826037b35a7407c88634ea6f1d7dc57c3437d211d581ece4ae22
|
|
BLAKE2b-256 checksum How to use checksums |
958b693a42733e0a629b43e3c846fb9b3901e214f606b7cb3174123083d6b4e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / pytorchltr-0.2.1-cp36-cp36m-macosx_10_14_x86_64.whl
| Download URL | pytorchltr-0.2.1-cp36-cp36m-macosx_10_14_x86_64.whl |
|---|---|
| Size | 107.2 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc macOS 10.14+ x86-64 |
|
SHA-256 checksum How to use checksums |
88f87596308063e569313880598fb167a6cdf4b034dd6fd3a0b57fd397ce798a
|
|
BLAKE2b-256 checksum How to use checksums |
42609505f9a16c3089489400f0dbede9b37ebf2cadbd38fbbcd85f665786369d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / pytorchltr-0.2.1-cp35-cp35m-win_amd64.whl
| Download URL | pytorchltr-0.2.1-cp35-cp35m-win_amd64.whl |
|---|---|
| Size | 104.8 kB |
| Tags | CPython 3.5 CPython 3.5 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
17639b1632b7518f92e41a706b86590c8a3b8c29c88e7d559870b86748ac4923
|
|
BLAKE2b-256 checksum How to use checksums |
2bbf2700b4e4408c79718fcfb4432fdd542988e5d9855e65fd9c57b57208cf6c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.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.5.4
|
Release files / pytorchltr-0.2.1-cp35-cp35m-manylinux1_x86_64.whl
| Download URL | pytorchltr-0.2.1-cp35-cp35m-manylinux1_x86_64.whl |
|---|---|
| Size | 332.5 kB |
| Tags | CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
05dfce191056ed72b86198101d6b61b4f3af76485a49e13970696f139a8dc265
|
|
BLAKE2b-256 checksum How to use checksums |
cd8392537027394b51ddfc4172e7d03acb00070f7c20fdb77627e5bb99872667
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.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.5.10
|
Release files / pytorchltr-0.2.1-cp35-cp35m-macosx_10_15_x86_64.whl
| Download URL | pytorchltr-0.2.1-cp35-cp35m-macosx_10_15_x86_64.whl |
|---|---|
| Size | 106.3 kB |
| Tags | CPython 3.5 CPython 3.5 pymalloc macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
e52f173f35434ed442b6ba5134a13ce3ee1fa5ff2867175aae506f1fa37bf830
|
|
BLAKE2b-256 checksum How to use checksums |
ce59da36800daad9ef7014f015b2f833a473ee5c8b2d5ca7d8593d5867f5031e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.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.5.9
|