ensure scale before rep pen

This commit is contained in:
Concedo 2025-02-09 16:59:56 +08:00
parent 076e61effc
commit bdade9be1b

View file

@ -398,9 +398,9 @@ int32_t kcpp_quick_sample(float * logits, const int n_logits, const std::vector<
if (rep_pen>1.0f && std::find(last_n_tokens.begin(), last_n_tokens.end(), i) != last_n_tokens.end()) { if (rep_pen>1.0f && std::find(last_n_tokens.begin(), last_n_tokens.end(), i) != last_n_tokens.end()) {
// if score < 0 then repetition penalty has to multiplied to reduce the previous token probability // if score < 0 then repetition penalty has to multiplied to reduce the previous token probability
if (logits[i] < 0.0f) { if (logits[i] < 0.0f) {
logits_id.push_back(std::make_pair(logits[i]*scale*rep_pen, i)); logits_id.push_back(std::make_pair((logits[i]*scale)*rep_pen, i));
} else { } else {
logits_id.push_back(std::make_pair(logits[i]*scale/rep_pen, i)); logits_id.push_back(std::make_pair((logits[i]*scale)/rep_pen, i));
} }
} else { } else {
logits_id.push_back(std::make_pair(logits[i]*scale, i)); logits_id.push_back(std::make_pair(logits[i]*scale, i));