rewrite ternary expressions
Co-authored-by: Henri Vasserman <henv@hot.ee>
This commit is contained in:
parent
414f25104b
commit
18e6221ade
1 changed files with 8 additions and 5 deletions
13
llama.cpp
13
llama.cpp
|
@ -2293,11 +2293,14 @@ void llama_sample_grammar(struct llama_context * ctx, llama_token_data_array * c
|
||||||
|
|
||||||
// prune tokens based on first char only - in `llama_grammar_accept_token` we will find the
|
// prune tokens based on first char only - in `llama_grammar_accept_token` we will find the
|
||||||
// full matching prefix of the selected token
|
// full matching prefix of the selected token
|
||||||
const bool valid = str[0] == ' '
|
bool valid = false;
|
||||||
? llama_grammar_peek(stacks_after_space, str[1])
|
if (id == eos) {
|
||||||
: str[0] || id == eos
|
valid = llama_grammar_peek(grammar->stacks, 0);
|
||||||
? llama_grammar_peek(grammar->stacks, id == eos ? 0 : str[0])
|
} else if (str[0] == ' ') {
|
||||||
: false;
|
valid = llama_grammar_peek(stacks_after_space, str[1]);
|
||||||
|
} else if (str[0] != 0) {
|
||||||
|
valid = llama_grammar_peek(grammar->stacks, str[0]);
|
||||||
|
}
|
||||||
|
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
candidates->data[i].logit = -INFINITY;
|
candidates->data[i].logit = -INFINITY;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue