Former-commit-id: 079ebe038b11f36a11681dc8688f8ea48bccf324
This commit is contained in:
hiyouga
2024-11-02 12:52:35 +08:00
parent 83479c9ef0
commit fa2386e73c
2 changed files with 4 additions and 4 deletions

View File

@@ -398,11 +398,11 @@ def get_template_and_fix_tokenizer(tokenizer: "PreTrainedTokenizer", data_args:
if num_added_tokens > 0:
logger.warning("New tokens have been added, make sure `resize_vocab` is True.")
if template.replace_jinja_template:
if tokenizer.chat_template is None or template.replace_jinja_template:
try:
tokenizer.chat_template = _get_jinja_template(template, tokenizer)
except ValueError:
logger.info("Cannot add this chat template to tokenizer.")
except ValueError as e:
logger.info(f"Cannot add this chat template to tokenizer: {e}.")
return template