InBatchCrossEntropy
- class lightning_ir.loss.in_batch.InBatchCrossEntropy(pos_sampling_technique: 'all' | 'first' = 'all', neg_sampling_technique: 'all' | 'first' | 'all_and_non_first' = 'all', max_num_neg_samples: int | None = None)[source]
Bases:
InBatchLossFunctionIn-batch cross-entropy loss function for ranking tasks. Originally proposed in: Fast Single-Class Classification and the Principle of Logit Separation
Methods
compute_loss(output)Compute the in-batch cross-entropy loss.
- compute_loss(output: LightningIROutput) torch.Tensor[source]
Compute the in-batch cross-entropy loss.
- Parameters:
output (LightningIROutput) – The output from the model containing scores.
- Returns:
The computed loss.
- Return type:
torch.Tensor