From 0a1c308d042ef51fdb2246be638c85e95557b9c1 Mon Sep 17 00:00:00 2001 From: CoderRC <108188026+CoderRC@users.noreply.github.com> Date: Sun, 2 Apr 2023 23:52:27 -0400 Subject: [PATCH] Sync --- llama.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/llama.cpp b/llama.cpp index 805d6af9e..d0be38438 100644 --- a/llama.cpp +++ b/llama.cpp @@ -1242,6 +1242,20 @@ static llama_vocab::id llama_sample_top_p_top_k( const auto & logits = lctx.logits; const auto * plogits = logits.data() + logits.size() - n_logits; + if (temp <= 0) { + // select the token with the highest logit directly + float max_logit = plogits[0]; + llama_vocab::id max_id = 0; + + for (int i = 1; i < n_logits; ++i) { + if (plogits[i] > max_logit) { + max_logit = plogits[i]; + max_id = i; + } + } + return max_id; + } + std::vector> logits_id; logits_id.reserve(n_logits);