LibAUC provides specialized optimizers and loss functions for optimizing NDCG (Normalized Discounted Cumulative Gain) in ranking tasks.
SONG (Stochastic Optimization of NDCG)
SONG is an algorithm for NDCG optimization with provable convergence. It uses the NDCG_Loss class and the SONG optimizer.
K-SONG
K-SONG is an algorithm for top-K NDCG optimization. It is implemented using the same NDCG_Loss and SONG classes but requires specific parameters for top-K optimization.
Key Hyperparameters
lr: Initial learning rate (highly sensitive).gamma0: Moving average factor for the algorithm (highly sensitive). Recommended range: (0.0, 1.0). Default is 0.1.beta1: Momentum parameter (similar to Adam, typically 0.9).topk_version: For K-SONG, use 'theo' for theoretical K-SONG or 'prac' for practical K-SONG.
# Example setup for K-SONG
from libauc.losses.ranking import NDCG_Loss
from libauc.optimizers import SONG
# Parameters
TOPK = 300
TOPK_V = 'theo' # 'prac' or 'theo'
GAMMA0 = 0.1
# Build optimizer and criterion
criterion = NDCG_Loss(id_mapper, num_relevant_pairs, n_users, n_items, NUM_POS, gamma0=GAMMA0, topk=TOPK, topk_version=TOPK_V)
optimizer = SONG(params=model.parameters(), lr=LR, weight_decay=L2, mode='adam')