Skip to content

Commit 4f34279

Browse files
committed
Update token checks
1 parent 626003c commit 4f34279

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llama_cpp/llama.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def _sample(
304304
else last_n_tokens_size
305305
)
306306
logits = self.eval_logits[-1]
307-
nl_logit = logits[llama_cpp.llama_token_nl().value]
307+
nl_logit = logits[int(Llama.token_nl())]
308308
data = (llama_cpp.llama_token_data * n_vocab)(
309309
*[
310310
llama_cpp.llama_token_data(
@@ -338,7 +338,7 @@ def _sample(
338338
alpha_presence=presence_penalty,
339339
)
340340
if not penalize_nl:
341-
candidates.data[llama_cpp.llama_token_nl().value].logit = nl_logit
341+
candidates.data[int(Llama.token_nl())].logit = nl_logit
342342
if temp.value == 0.0:
343343
return llama_cpp.llama_sample_token_greedy(
344344
ctx=self.ctx,
@@ -677,7 +677,7 @@ def _create_completion(
677677
presence_penalty=presence_penalty,
678678
repeat_penalty=repeat_penalty,
679679
):
680-
if token == llama_cpp.llama_token_eos():
680+
if token == Llama.token_eos():
681681
text = self.detokenize(completion_tokens)
682682
finish_reason = "stop"
683683
break

0 commit comments

Comments
 (0)