From af0a5b616359809ce886ea433acedebb39b12969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20G=C3=A4=C3=9Fler?= Date: Tue, 7 May 2024 23:07:58 +0200 Subject: server: fix incorrectly reported token probabilities (#7125) * server: normalize token probabilities * fix temperature == 0.0f --- common/sampling.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'common/sampling.cpp') diff --git a/common/sampling.cpp b/common/sampling.cpp index cc83600d..3715a798 100644 --- a/common/sampling.cpp +++ b/common/sampling.cpp @@ -35,6 +35,8 @@ struct llama_sampling_context * llama_sampling_init(const struct llama_sampling_ result->prev.resize(params.n_prev); + result->n_considered = 0; + llama_sampling_set_rng_seed(result, params.seed); return result; @@ -64,6 +66,7 @@ void llama_sampling_reset(llama_sampling_context * ctx) { std::fill(ctx->prev.begin(), ctx->prev.end(), 0); ctx->cur.clear(); + ctx->n_considered = 0; } void llama_sampling_set_rng_seed(struct llama_sampling_context * ctx, uint32_t seed) { @@ -253,6 +256,8 @@ static llama_token llama_sampling_sample_impl( } } + ctx_sampling->n_considered = cur_p.size; + return id; } -- cgit v1.2.3