common : fix for two functions when top_k exceeds the vocabulary size. (ggml/1633)

This commit is contained in:
Arianna Method
2026-09-23 20:46:47 +03:00
committed by Georgi Gerganov
parent f6b039ff0f
commit 711ef84442
+2
View File
@@ -406,6 +406,7 @@ gpt_vocab::id gpt_sample_top_k_top_p(
double temp,
std::mt19937 & rng) {
int n_logits = vocab.id_to_token.size();
top_k = std::min(top_k, n_logits);
std::vector<std::pair<double, gpt_vocab::id>> logits_id;
logits_id.reserve(n_logits);
@@ -491,6 +492,7 @@ gpt_vocab::id gpt_sample_top_k_top_p_repeat(
std::mt19937 & rng) {
int n_logits = vocab.id_to_token.size();
top_k = std::min(top_k, n_logits);
const auto * plogits = logits;