feat(backend): add guard in case top_k = 0

This commit is contained in:
Morgan Funtowicz 2024-11-28 16:30:20 +01:00
parent 929a2fc718
commit df72c56b5b
1 changed files with 4 additions and 1 deletions

View File

@ -28,7 +28,10 @@ namespace huggingface::tgi::backends::llamacpp {
false,
false
));
llama_sampler_chain_add(pSampler, llama_sampler_init_top_k(static_cast<int32_t>(top_k)));
if (top_k > 0) {
llama_sampler_chain_add(pSampler, llama_sampler_init_top_k(static_cast<int32_t>(top_k)));
}
if (0 < top_p && top_p < 1) {
llama_sampler_chain_add(pSampler, llama_sampler_init_top_p(top_p, 1));