@@ -445,15 +445,15 @@ def generate(self):
445
445
],
446
446
)
447
447
candidates_p = llama_cpp .ctypes .pointer (
448
- llama_cpp .llama_token_data_array (_arr , len (_arr ), False )
448
+ llama_cpp .llama_token_data_array (_arr , len (_arr ), False ),
449
449
)
450
450
451
451
# Apply penalties
452
452
nl_logit = logits [llama_cpp .llama_token_nl (self .ctx )]
453
453
last_n_repeat = min (len (self .last_n_tokens ), repeat_last_n , self .n_ctx )
454
454
455
455
_arr = (llama_cpp .llama_token * last_n_repeat )(
456
- * self .last_n_tokens [len (self .last_n_tokens ) - last_n_repeat :]
456
+ * self .last_n_tokens [len (self .last_n_tokens ) - last_n_repeat :],
457
457
)
458
458
llama_cpp .llama_sample_repetition_penalties (
459
459
ctx = self .ctx ,
@@ -480,7 +480,7 @@ def generate(self):
480
480
mirostat_mu = 2.0 * self .params .mirostat_tau
481
481
mirostat_m = 100
482
482
llama_cpp .llama_sample_temperature (
483
- self .ctx , candidates_p , llama_cpp .c_float (self .params .temp )
483
+ self .ctx , candidates_p , llama_cpp .c_float (self .params .temp ),
484
484
)
485
485
id = llama_cpp .llama_sample_token_mirostat (
486
486
self .ctx ,
@@ -493,7 +493,7 @@ def generate(self):
493
493
elif self .params .mirostat == 2 :
494
494
mirostat_mu = 2.0 * self .params .mirostat_tau
495
495
llama_cpp .llama_sample_temperature (
496
- self .ctx , candidates_p , llama_cpp .c_float (self .params .temp )
496
+ self .ctx , candidates_p , llama_cpp .c_float (self .params .temp ),
497
497
)
498
498
id = llama_cpp .llama_sample_token_mirostat_v2 (
499
499
self .ctx ,
@@ -529,7 +529,7 @@ def generate(self):
529
529
min_keep = llama_cpp .c_size_t (1 ),
530
530
)
531
531
llama_cpp .llama_sample_temperature (
532
- self .ctx , candidates_p , llama_cpp .c_float (self .params .temp )
532
+ self .ctx , candidates_p , llama_cpp .c_float (self .params .temp ),
533
533
)
534
534
id = llama_cpp .llama_sample_token (self .ctx , candidates_p )
535
535
# print("`{}`".format(candidates_p.size))
@@ -600,7 +600,7 @@ def generate(self):
600
600
601
601
# end of text token
602
602
if len (self .embd ) > 0 and self .embd [- 1 ] == llama_cpp .llama_token_eos (
603
- self .ctx
603
+ self .ctx ,
604
604
):
605
605
if not self .params .instruct :
606
606
for i in self .llama_token_eot :
@@ -636,7 +636,7 @@ def token_to_str(self, token_id: int) -> bytes:
636
636
size = 32
637
637
buffer = (ctypes .c_char * size )()
638
638
n = llama_cpp .llama_token_to_piece (
639
- self .model , llama_cpp .llama_token (token_id ), buffer , size
639
+ self .model , llama_cpp .llama_token (token_id ), buffer , size ,
640
640
)
641
641
assert n <= size
642
642
return bytes (buffer [:n ])
@@ -709,7 +709,7 @@ def interact(self):
709
709
else :
710
710
print (self .params .input_prefix , end = "" )
711
711
self .input (
712
- f"{ self .params .input_prefix } { self .read_input ()} { self .params .input_suffix } "
712
+ f"{ self .params .input_prefix } { self .read_input ()} { self .params .input_suffix } " ,
713
713
)
714
714
print (self .params .input_suffix , end = "" )
715
715
self .set_color (util .CONSOLE_COLOR_DEFAULT )
0 commit comments