LossFunction

class lightning_ir.loss.base.LossFunction[source]

Bases: ABC

Base class for loss functions in the Lightning IR framework.

Methods

compute_loss(output, *args, **kwargs)

Compute the loss for the given output.

process_scores(output)

Process the scores from the output.

process_targets(scores, batch)

Process the targets from the batch.

abstractmethod compute_loss(output: LightningIROutput, *args, **kwargs) torch.Tensor[source]

Compute the loss for the given output.

Parameters:

output (LightningIROutput) – The output from the model.

Returns:

The computed loss.

Return type:

torch.Tensor

process_scores(output: LightningIROutput) torch.Tensor[source]

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[source]

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