ScoringLossFunction

class lightning_ir.loss.base.ScoringLossFunction[source]

Bases: LossFunction

Base class for loss functions that operate on scores.

__init__()

Methods

compute_loss(output, batch)

Compute the loss based on the scores and targets in the output and batch.

abstract compute_loss(output: LightningIROutput, batch: TrainBatch) torch.Tensor[source]

Compute the loss based on the scores and targets in the output and batch.

Parameters:
  • output (LightningIROutput) – The output from the model containing scores.

  • batch (TrainBatch) – The training batch containing targets.

Returns:

The computed loss.

Return type:

torch.Tensor

process_scores(output: LightningIROutput) torch.Tensor

Process the scores from the output.

Parameters:

output (LightningIROutput) – The output from the model.

Returns:

The scores tensor.

Return type:

torch.Tensor

process_targets(scores: torch.Tensor, batch: TrainBatch) torch.Tensor

Process the targets from the batch.

Parameters:
  • scores (torch.Tensor) – The scores tensor.

  • batch (TrainBatch) – The training batch.

Returns:

The processed targets tensor.

Return type:

torch.Tensor