Skip to content

Commit

Permalink
apply review comments from shiyu1994 in #4531
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyu1994 committed Jul 29, 2022
1 parent 42072d2 commit ef89b41
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/objective/rank_objective.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class LambdarankNDCG : public RankingObjective {
num_threads_ = omp_get_num_threads();
}

position_bias_regularizer = 1.0f / (1.0f + bias_p_norm_);
position_bias_regularizer_ = 1.0f / (1.0f + bias_p_norm_);
}

explicit LambdarankNDCG(const std::vector<std::string>& strs)
Expand Down Expand Up @@ -229,8 +229,8 @@ class LambdarankNDCG : public RankingObjective {
double p_lambda = GetSigmoid(delta_score);
double p_hessian = p_lambda * (1.0f - p_lambda);

int debias_high_rank = static_cast<int>(std::min(high, truncation_level_ - 1));
int debias_low_rank = static_cast<int>(std::min(low, truncation_level_ - 1));
int debias_high_rank = static_cast<int>(std::min(high_rank, truncation_level_ - 1));
int debias_low_rank = static_cast<int>(std::min(low_rank, truncation_level_ - 1));

if (unbiased_) {
double p_cost = log(1.0f / (1.0f - p_lambda)) * delta_pair_NDCG;
Expand Down Expand Up @@ -329,11 +329,13 @@ class LambdarankNDCG : public RankingObjective {

for (int i = 0; i < truncation_level_; i++) {
// Update bias
i_biases_pow_[i] = pow(i_costs_[i] / i_costs_[0], position_bias_regularizer);
j_biases_pow_[i] = pow(j_costs_[i] / j_costs_[0], position_bias_regularizer);
i_biases_pow_[i] = pow(i_costs_[i] / i_costs_[0], position_bias_regularizer_);
j_biases_pow_[i] = pow(j_costs_[i] / j_costs_[0], position_bias_regularizer_);
}

#ifdef DEBUG
LogDebugPositionBiases();
#endif // DEBUG

for (int i = 0; i < truncation_level_; i++) {
// Clear position info
Expand Down Expand Up @@ -412,7 +414,7 @@ class LambdarankNDCG : public RankingObjective {
double bias_p_norm_;

/*! \brief Position bias regularizer exponent, 1 / (1 + bias_p_norm_) */
double position_bias_regularizer;
double position_bias_regularizer_;

/*! \brief Number of threads */
int num_threads_;
Expand Down

0 comments on commit ef89b41

Please sign in to comment.