mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-09-18 16:55:14 +02:00
unify antislop and token bans
This commit is contained in:
+2
-11
@@ -20,8 +20,7 @@ from datetime import datetime, timezone
|
||||
# constants
|
||||
sampler_order_max = 7
|
||||
stop_token_max = 24
|
||||
ban_token_max = 16
|
||||
ban_phrase_max = 16
|
||||
ban_token_max = 24
|
||||
tensor_split_max = 16
|
||||
logit_bias_max = 24
|
||||
dry_seq_break_max = 24
|
||||
@@ -172,8 +171,7 @@ class generation_inputs(ctypes.Structure):
|
||||
("dynatemp_exponent", ctypes.c_float),
|
||||
("smoothing_factor", ctypes.c_float),
|
||||
("logit_biases", logit_bias * logit_bias_max),
|
||||
("banned_tokens", ctypes.c_char_p * ban_token_max),
|
||||
("banned_phrases", ctypes.c_char_p * ban_phrase_max)]
|
||||
("banned_tokens", ctypes.c_char_p * ban_token_max)]
|
||||
|
||||
class generation_outputs(ctypes.Structure):
|
||||
_fields_ = [("status", ctypes.c_int),
|
||||
@@ -912,7 +910,6 @@ def generate(genparams, is_quiet=False, stream_flag=False):
|
||||
logit_biases = genparams.get('logit_bias', {})
|
||||
render_special = genparams.get('render_special', False)
|
||||
banned_tokens = genparams.get('banned_tokens', [])
|
||||
banned_phrases = genparams.get('banned_phrases', [])
|
||||
bypass_eos_token = genparams.get('bypass_eos', False)
|
||||
|
||||
inputs = generation_inputs()
|
||||
@@ -1031,12 +1028,6 @@ def generate(genparams, is_quiet=False, stream_flag=False):
|
||||
else:
|
||||
inputs.banned_tokens[n] = banned_tokens[n].encode("UTF-8")
|
||||
|
||||
for n in range(ban_phrase_max):
|
||||
if not banned_phrases or n >= len(banned_phrases):
|
||||
inputs.banned_phrases[n] = "".encode("UTF-8")
|
||||
else:
|
||||
inputs.banned_phrases[n] = banned_phrases[n].encode("UTF-8")
|
||||
|
||||
currentusergenkey = genkey
|
||||
totalgens += 1
|
||||
#early exit if aborted
|
||||
|
||||
Reference in New Issue
Block a user