Skip to content

Commit

Permalink
llama : fix empty ring buffer push (#9358)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggerganov authored Sep 7, 2024
1 parent faf69d4 commit f12295b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion common/sampling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ struct gpt_sampler * gpt_sampler_init(const struct llama_model * model, const st
/* .params = */ params,
/* .grmr = */ llama_sampler_init_grammar(model, params.grammar.c_str(), "root"),
/* .chain = */ llama_sampler_chain_init(lparams),
/* .prev = */ ring_buffer<llama_token>(params.n_prev),
/* .prev = */ ring_buffer<llama_token>(std::max(32, params.n_prev)),
/* .cur = */ {},
/* .cur_p = */ {},
};
Expand Down
4 changes: 3 additions & 1 deletion src/llama-sampling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1226,7 +1226,9 @@ static struct llama_sampler_i llama_sampler_penalties_i = {
/* .name = */ [](const struct llama_sampler * /*smpl*/) { return "penalties"; },
/* .accept = */ [](struct llama_sampler * smpl, llama_token token) {
auto * ctx = (llama_sampler_penalties *) smpl->ctx;
ctx->prev.push_back(token);
if (ctx->prev.size()) {
ctx->prev.push_back(token);
}
},
/* .apply = */ [](struct llama_sampler * smpl, llama_token_data_array * cur_p) {
auto * ctx = (llama_sampler_penalties *) smpl->ctx;
Expand Down

0 comments on commit f12295b

Please sign in to comment.