Skip to content

Commit 72f895c

Browse files
tom7ggerganov
andauthored
main : fix bug (penalize_nl=false doesn't work) + suppress warning on mingw (#1528)
* Fix bug in main.cpp where penalize_nl=false has no effect. It modifies the underlying logits array, but at this point we are already working on the candidates copy. * Suppress redefinition warning for NOMINMAX on mingw. In my installation, this macro is already defined by /usr/lib/gcc/x86_64-w64-mingw32/11/include/c++/x86_64-w64-mingw32/bits/os_defines.h:45. * main : fix indentation * main : pass ctx to llama_token_nl() --------- Co-authored-by: Georgi Gerganov <[email protected]>
1 parent 50526f3 commit 72f895c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

examples/main/main.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,12 @@ int main(int argc, char ** argv) {
604604
last_n_tokens.data() + last_n_tokens.size() - last_n_repeat,
605605
last_n_repeat, alpha_frequency, alpha_presence);
606606
if (!penalize_nl) {
607-
logits[llama_token_nl(ctx)] = nl_logit;
607+
for (size_t idx = 0; idx < candidates_p.size; idx++) {
608+
if (candidates_p.data[idx].id == llama_token_nl(ctx)) {
609+
candidates_p.data[idx].logit = nl_logit;
610+
break;
611+
}
612+
}
608613
}
609614

610615
if (grammar != NULL) {

0 commit comments

Comments
 (0)