summaryrefslogtreecommitdiff
path: root/llama.cpp
diff options
context:
space:
mode:
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);