diff --git a/scripts/checkpoint_converters/convert_mistral_7b_hf_to_nemo.py b/scripts/checkpoint_converters/convert_mistral_7b_hf_to_nemo.py index 71aa6ecc7dea..5785db656217 100644 --- a/scripts/checkpoint_converters/convert_mistral_7b_hf_to_nemo.py +++ b/scripts/checkpoint_converters/convert_mistral_7b_hf_to_nemo.py @@ -448,18 +448,19 @@ def save_to_nemo(args, checkpoint): if getattr(tokenizer, 'chat_template', None) is not None: import hashlib - assert ( - hashlib.md5(tokenizer.chat_template.encode('utf-8')).hexdigest() == "0b629f783db54e02509999196956ff40" - ), "Got unkown chat template" - from omegaconf import OmegaConf, open_dict - - with open_dict(model.cfg): - model.cfg.tokenizer.chat_template = OmegaConf.create( - { - 'prefix': "{_bos_}", - 'roles': {'User': "[INST] {_content_} [/INST]", 'Assistant': "{_content_}{_eos_}"}, - } - ) + template_hash = hashlib.md5(tokenizer.chat_template.encode('utf-8')).hexdigest() + if template_hash != "0b629f783db54e02509999196956ff40": + logging.warning("Got unkown chat template") + else: + from omegaconf import OmegaConf, open_dict + + with open_dict(model.cfg): + model.cfg.tokenizer.chat_template = OmegaConf.create( + { + 'prefix': "{_bos_}", + 'roles': {'User': "[INST] {_content_} [/INST]", 'Assistant': "{_content_}{_eos_}"}, + } + ) model.save_to(args.output_path) logging.info(f'NeMo model saved to: {args.output_path}')