chore(mlx-lm): enable to apply default chat template (#577)

* chore(mlx-lm): enable to apply default chat template

* Add option to use default chat template

* chore: rename the flag to use default chat template
This commit is contained in:
Anchen 2024-03-21 15:39:39 +11:00 committed by GitHub
parent d2a99172a6
commit 8f906c859a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -61,6 +61,11 @@ def setup_arg_parser():
action="store_true",
help="Use the raw prompt without the tokenizer's chat template.",
)
parser.add_argument(
"--use-default-chat-template",
action="store_true",
help="Use the default chat template",
)
parser.add_argument(
"--colorize",
action="store_true",
@ -108,6 +113,10 @@ def main(args):
args.model, adapter_file=args.adapter_file, tokenizer_config=tokenizer_config
)
if args.use_default_chat_template:
if tokenizer.chat_template is None:
tokenizer.chat_template = tokenizer.default_chat_template
if not args.ignore_chat_template and (
hasattr(tokenizer, "apply_chat_template")
and tokenizer.chat_template is not None