Commit 9db56820 authored by Baber's avatar Baber
Browse files

`self.tokenizer.bos_token` can be None

parent 03f6ad01
...@@ -21,6 +21,7 @@ from lm_eval.api.model import TemplateLM ...@@ -21,6 +21,7 @@ from lm_eval.api.model import TemplateLM
from lm_eval.api.registry import register_model from lm_eval.api.registry import register_model
from lm_eval.models.utils import ( from lm_eval.models.utils import (
Collator, Collator,
bos_already_added,
configure_pad_token, configure_pad_token,
handle_stop_sequences, handle_stop_sequences,
postprocess_generated_text, postprocess_generated_text,
...@@ -349,10 +350,11 @@ class VLLM(TemplateLM): ...@@ -349,10 +350,11 @@ class VLLM(TemplateLM):
else {} else {}
) )
# handle chat template # handle chat template
if self.tokenizer.bos_token and ( if bos_already_added(
string[0] if isinstance(string, list) else string string[0] if isinstance(string, list) else string, self.tokenizer.bos_token
).startswith(self.tokenizer.bos_token): ):
add_special_kwargs = {"add_special_tokens": False} add_special_kwargs = {"add_special_tokens": False}
encoding: list[list[int]] | list[int] = self.tokenizer( encoding: list[list[int]] | list[int] = self.tokenizer(
string, string,
truncation=truncation, truncation=truncation,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment