Skip to content

Commit 5a8c4f6

Browse files
llama : define non-positive top_k; top_k range check (#779)
* Define non-positive top_k; top_k range check * minor : brackets --------- Co-authored-by: Georgi Gerganov <[email protected]>
1 parent ff05d05 commit 5a8c4f6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

llama.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,9 @@ static llama_vocab::id llama_sample_top_p_top_k(
12291229
}
12301230
}
12311231

1232-
sample_top_k(logits_id, top_k);
1232+
if (top_k > 0 && top_k < n_logits) {
1233+
sample_top_k(logits_id, top_k);
1234+
}
12331235

12341236
float maxl = -std::numeric_limits<float>::infinity();
12351237
for (const auto & kv : logits_id) {

0 commit comments

Comments
 (0)