mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2025-09-10 09:04:36 +00:00
fix-loss-of-destroyed-tokens-in-grammar-pre-pass (#1600)
This commit is contained in:
parent
5bac0fb3d5
commit
f1c9db4174
1 changed files with 2 additions and 2 deletions
|
@ -1653,7 +1653,7 @@ const std::vector<samplers> & sampler_order, llama_grammar * grammar, float dyna
|
|||
|
||||
//prefilter to top 3k tokens for improved speed
|
||||
bool use_grammar = grammar != nullptr;
|
||||
size_t n_pre_cull = candidates_p.size;
|
||||
std::vector<llama_token_data> precache = (use_grammar ? std::vector<llama_token_data>(candidates) : std::vector<llama_token_data>(0));
|
||||
|
||||
sample_top_k(&candidates_p, 3000);
|
||||
|
||||
|
@ -1661,7 +1661,7 @@ const std::vector<samplers> & sampler_order, llama_grammar * grammar, float dyna
|
|||
sample_grammar(file_format, n_vocab, &candidates_p, grammar);
|
||||
// if top_k 3000 doesn't contain a valid candidate for this grammar, try again pre-cull
|
||||
if (candidates_p.size <= 0) {
|
||||
candidates_p.size = n_pre_cull;
|
||||
candidates_p = { precache.data(), precache.size(), false };
|
||||
sample_grammar(file_format, n_vocab, &candidates_p, grammar);
|
||||
sample_top_k(&candidates_p, 3000);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue