From: Georgi Gerganov Date: Sat, 20 May 2023 14:45:49 +0000 (+0300) Subject: common : force --top_k to be at least 1 X-Git-Tag: upstream/0.0.1642~1456 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=3fe20826ac4a5b2e49498aac1194c1d1efb37d71;p=pkg%2Fggml%2Fsources%2Fggml common : force --top_k to be at least 1 --- diff --git a/examples/common.cpp b/examples/common.cpp index 47765056..76da30d9 100644 --- a/examples/common.cpp +++ b/examples/common.cpp @@ -26,7 +26,7 @@ bool gpt_params_parse(int argc, char ** argv, gpt_params & params) { } else if (arg == "-n" || arg == "--n_predict") { params.n_predict = std::stoi(argv[++i]); } else if (arg == "--top_k") { - params.top_k = std::stoi(argv[++i]); + params.top_k = std::max(1, std::stoi(argv[++i])); } else if (arg == "--top_p") { params.top_p = std::stof(argv[++i]); } else if (arg == "--temp") { diff --git a/examples/starcoder/main.cpp b/examples/starcoder/main.cpp index 3d8a4df1..49609405 100644 --- a/examples/starcoder/main.cpp +++ b/examples/starcoder/main.cpp @@ -766,9 +766,9 @@ int main(int argc, char ** argv) { params.n_predict = std::min(params.n_predict, model.hparams.n_ctx - (int) embd_inp.size()); printf("%s: prompt: '%s'\n", __func__, params.prompt.c_str()); - printf("%s: number of tokens in prompt = %zu, first 8 tokens: ", __func__, embd_inp.size()); - for (int i = 0; i < std::min(8, (int) embd_inp.size()); i++) { - printf("%d ", embd_inp[i]); + printf("%s: number of tokens in prompt = %zu\n", __func__, embd_inp.size()); + for (int i = 0; i < embd_inp.size(); i++) { + printf("%s: token[%d] = %6d, %s\n", __func__, i, embd_inp[i], vocab.id_to_token.at(embd_inp[i]).c_str()); } printf("\n\n");