mirror of
https://github.com/wassname/prob_jsonformer.git
synced 2026-09-09 11:29:57 +08:00
fix len
This commit is contained in:
@@ -26,8 +26,14 @@ class StringStoppingCriteria(StoppingCriteria):
|
||||
|
||||
if self.max_length is not None:
|
||||
# because of tokens this wont work pefectly
|
||||
str_l = len(self.tokenizer.decode(input_ids[0], skip_special_tokens=True))
|
||||
if str_l > self.max_length:
|
||||
gen_ids = input_ids[0][self.prompt_length :]
|
||||
o = self.tokenizer.decode(gen_ids, skip_special_tokens=True)
|
||||
# print("o", o)
|
||||
str_l = len(o)
|
||||
# print(
|
||||
# f"stopping? self.max_length={self.max_length} str_l={str_l},self.prompt_length={self.prompt_length}"
|
||||
# )
|
||||
if (str_l - -self.prompt_length) > self.max_length:
|
||||
return True
|
||||
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user