Update comments, more proper application

I see that numbers can go negative so a fix from a referenced commit
pull/20/head
beiller 2 years ago committed by GitHub
parent c90e78edc3
commit 340bff0f0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -391,8 +391,16 @@ gpt_vocab::id llama_sample_top_p(
{
const double scale = 1.0/temp;
for (int i = 0; i < n_logits; ++i) {
// repetition penalty from CTRL paper (https://arxiv.org/abs/1909.05858)
// credit https://github.com/facebookresearch/llama/compare/main...shawwn:llama:main
if ( std::find(last_n_tokens.begin(), last_n_tokens.end(), i) != last_n_tokens.end() ) {
logits_id.push_back(std::make_pair(logits[i]*scale*(1/repeat_penalty), i));
// if score < 0 then repetition penalty has to multiplied to reduce the previous token probability
if(logits[i] < 0.0) {
logits_id.push_back(std::make_pair(logits[i]*scale*repeat_penalty, i));
} else {
logits_id.push_back(std::make_pair(logits[i]*scale/repeat_penalty, i));
}
} else {
logits_id.push_back(std::make_pair(logits[i]*scale, i));
}

Loading…
Cancel
Save