loss¶
- fairdiverse.search.utils.loss.list_pairwise_loss(score_1, score_2, delta)[source]¶
Computes the accuracy and list-pairwise loss based on the difference between two scores.
- Parameters:
score_1 – A tensor containing the scores for the first set of items.
score_2 – A tensor containing the scores for the second set of items.
delta – A tensor representing the weight for each pairwise comparison.
- Returns:
The accuracy and the computed list-pairwise loss.
- fairdiverse.search.utils.loss.ndcg_loss(score, div)[source]¶
Computes the NDCG (Normalized Discounted Cumulative Gain) loss for ranking tasks.
- Parameters:
score – A tensor containing the predicted scores for each document.
div – A tensor containing the relevance or diversity values for each document.
- Returns:
The computed NDCG loss.