mirror of
https://github.com/ml-explore/mlx-examples.git
synced 2025-08-09 10:26:38 +08:00
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:
parent
d2a99172a6
commit
8f906c859a
@ -61,6 +61,11 @@ def setup_arg_parser():
|
|||||||
action="store_true",
|
action="store_true",
|
||||||
help="Use the raw prompt without the tokenizer's chat template.",
|
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(
|
parser.add_argument(
|
||||||
"--colorize",
|
"--colorize",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
@ -108,6 +113,10 @@ def main(args):
|
|||||||
args.model, adapter_file=args.adapter_file, tokenizer_config=tokenizer_config
|
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 (
|
if not args.ignore_chat_template and (
|
||||||
hasattr(tokenizer, "apply_chat_template")
|
hasattr(tokenizer, "apply_chat_template")
|
||||||
and tokenizer.chat_template is not None
|
and tokenizer.chat_template is not None
|
||||||
|
Loading…
Reference in New Issue
Block a user