summaryrefslogtreecommitdiff
path: root/llama.cpp
diff options
context:
space:
mode:
authorJohannes Gäßler <johannesg@5d6.de>2024-02-08 09:46:30 +0100
committerGitHub <noreply@github.com>2024-02-08 09:46:30 +0100
commit26d4efd11e48908e14e2ee9471a7fc4c57079a1d (patch)
tree04c16bf0611e416a0f5a792672f276a3cc55af7f /llama.cpp
parent8504d2d0da8cc7a1f2eee0e9e56949f960510b75 (diff)
sampling: fix top_k <= 0 (#5388)
* sampling: fix top_k <= 0 * Update llama.cpp Co-authored-by: Georgi Gerganov <ggerganov@gmail.com> --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
Diffstat (limited to 'llama.cpp')
-rw-r--r--llama.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llama.cpp b/llama.cpp
index c45ae1d5..f8f5796a 100644
--- a/llama.cpp
+++ b/llama.cpp
@@ -8585,6 +8585,10 @@ void llama_sample_top_k(struct llama_context * ctx, llama_token_data_array * can
// }
const int64_t t_start_sample_us = ggml_time_us();
+
+ if (k <= 0) {
+ k = candidates->size;
+ }
k = std::max(k, (int) min_keep);
k = std::min(k, (int) candidates->size);