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 toFalse.
- Returns:
- The computed loss. If
return_outputsisTrue, also returns the model’s outputs in a tuple
(loss, outputs).
- The computed loss. If
- Return type:
Union[torch.Tensor, tuple(torch.Tensor, RerankerOutput)]