L1Regularization

class lightning_ir.loss.regularization.L1Regularization(query_weight: float = 0.0001, doc_weight: float = 0.0001)[source]

Bases: RegularizationLossFunction

L1 Regularization loss function for query and document embeddings. Originally proposed in: Regression Shrinkage and Selection via the Lasso

Methods

compute_loss(output)

Compute the L1 regularization loss.

compute_loss(output: BiEncoderOutput) torch.Tensor[source]

Compute the L1 regularization loss.

Parameters:

output (BiEncoderOutput) – The output from the model containing query and document embeddings.

Returns:

The computed loss.

Return type:

torch.Tensor