Skip to content

Commit 859ebe1

Browse files
committed
stricter check
Signed-off-by: alessiodevoto <devoto.alessio@gmail.com>
1 parent dd559ad commit 859ebe1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

logits_processor_zoo/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def text_to_token(tokenizer: PreTrainedTokenizer, text: str, last: bool):
2424
tokens = tokenizer.encode(text, add_special_tokens=False)
2525

2626
# We allow 2 tokens to account for the BOS token
27-
max_token_count = 2 if tokenizer.bos_token_id else 1
27+
max_token_count = 2 if tokenizer.bos_token and tokenizer.bos_token_id in tokens else 1
2828

2929
if not last and len(tokens) > max_token_count:
3030
raise Exception(f"Can't convert {text} to token. It has {len(tokens)} tokens.")

0 commit comments

Comments
 (0)