Skip to content

Commit 38ad11c

Browse files
committed
sampling: add comments on modifications
1 parent 1834d9f commit 38ad11c

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

common/sampling.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,11 @@ std::string common_params_sampling::print() const {
187187
struct common_sampler * common_sampler_init(const struct llama_model * model, struct common_params_sampling & params) {
188188
const llama_vocab * vocab = llama_model_get_vocab(model);
189189

190+
// if the user did not specify a value for penalty_last_n, set it to the model's context size
190191
if (params.penalty_last_n == -1) {
191192
params.penalty_last_n = llama_model_n_ctx_train(model);
192193
}
194+
// ensure that n_prev is at least as large as penalty_last_n, sampler needs to remember at least that many tokens for the penalties to work correctly
193195
params.penalty_last_n = std::max(params.penalty_last_n, 0);
194196
params.n_prev = std::max(params.n_prev, params.penalty_last_n);
195197

0 commit comments

Comments
 (0)