Learning to rank

Learning to rank is handled by various classes :

  • the learner is the main class that runs the full process

  • trainers that iterate over batches of data

The main class is the Learner task.

XPM Taskxpmir.letor.learner.Learner(*, random, trainer, scorer, max_epochs, steps_per_epoch, use_fp16, optimizers, listeners, checkpoint_interval, device, hooks)

Bases: experimaestro.core.objects.Task, xpmir.utils.EasyLogger

Submit type: xpmir.letor.learner.LearnerOutput

Model Learner

The learner task is generic, and takes two main arguments: (1) the scorer defines the model (e.g. DRMM), and (2) the trainer defines how the model should be trained (e.g. pointwise, pairwise, etc.)

When submitted, it returns a dictionary based on the listeners

random: xpmir.letor.Random

The random generator

trainer: xpmir.letor.trainers.Trainer

Specifies how to train the model

scorer: xpmir.rankers.LearnableScorer

Defines the model that scores documents

max_epochs: int = 1000

Maximum number of epochs

steps_per_epoch: int = 128

Number of steps for one epoch (after each epoch results are logged)

use_fp16: bool = False

Use mixed precision when training

optimizers: List[xpmir.letor.optim.ParameterOptimizer]

The list of parameter optimizers

listeners: Dict[str, xpmir.letor.learner.LearnerListener]

Listeners are in charge of handling the validation of the model, and saving the relevant checkpoints

checkpoint_interval: int = 1

Number of epochs between each checkpoint

logpath: Pathgenerated

The path to the tensorboard logs

checkpointspath: Pathgenerated

The path to the checkpoints

device: xpmir.letor.devices.Device = xpmir.letor.devices.Device()

The device(s) to be used for the model

hooks: List[xpmir.context.Hook] = []

Global learning hooks Initialization hooks are called before and after the initialization of the trainer and listeners.

namedtuple xpmir.letor.learner.LearnerOutput(listeners)

Bases: NamedTuple


  1.  listeners (Dict[str, Any]) – Alias for field number 0


Scorers are able to give a score to a (query, document) pair. Among the scorers, some are have learnable parameters.

XPM Configxpmir.rankers.Scorer

Bases: experimaestro.core.objects.Config, xpmir.utils.EasyLogger

Query-document scorer

A model able to give a score to a list of documents given a query

XPM Configxpmir.rankers.RandomScorer(*, random)

Bases: xpmir.rankers.Scorer

A random scorer

random: xpmir.letor.Random

The random number generator

XPM Configxpmir.rankers.LearnableScorer(*, checkpoint)

Bases: xpmir.rankers.Scorer

Learnable scorer

A scorer with parameters that can be learnt

checkpoint: Path

A checkpoint path from which the model should be loaded (or None otherwise)


Scores can be used as retrievers through a xpmir.rankers.TwoStageRetriever