AbsTrainer#

AbsRerankerTrainer#

class FlagEmbedding.abc.finetune.reranker.AbsRerankerTrainer(*args, processing_class=None, tokenizer=None, **kwargs)[source]#

Abstract class for the trainer of reranker.

Methods#

AbsRerankerTrainer.compute_loss(model, inputs, return_outputs=False, **kwargs)[source]#

How the loss is computed by Trainer. By default, all models return the loss in the first element.

Subclass and override for custom behavior.

Parameters:
  • model (AbsRerankerModel) – The model being trained.

  • inputs (dict) – A dictionary of input tensors to be passed to the model.

  • return_outputs (bool, optional) – If True, returns both the loss and the model’s outputs. Otherwise, returns only the loss. Defaults to False.

Returns:

The computed loss. If return_outputs is True,

also returns the model’s outputs in a tuple (loss, outputs).

Return type:

Union[torch.Tensor, tuple(torch.Tensor, RerankerOutput)]