From: Ivan Stepanov Date: Mon, 3 Apr 2023 00:19:04 +0000 (+0300) Subject: Define non-positive temperature behavior (#720) X-Git-Tag: gguf-v0.4.0~1022 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=cd7fa956904cb8e321b72b3499f4a3a82e43c266;p=pkg%2Fggml%2Fsources%2Fllama.cpp Define non-positive temperature behavior (#720) --- diff --git a/llama.cpp b/llama.cpp index 87890718..854bb899 100644 --- a/llama.cpp +++ b/llama.cpp @@ -1194,6 +1194,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);