From 64e2a9a0a7d723dbc4e852d3c3b996e81349a040 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Wed, 24 Apr 2024 01:34:11 -0700 Subject: [PATCH] Fix the Phi-3 template when used in the UI --- modules/models_settings.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/models_settings.py b/modules/models_settings.py index 5c292431..a7fed427 100644 --- a/modules/models_settings.py +++ b/modules/models_settings.py @@ -71,6 +71,7 @@ def get_model_metadata(model): template = template.replace('bos_token', "'{}'".format(bos_token)) template = re.sub(r'raise_exception\([^)]*\)', "''", template) + template = re.sub(r'{% if add_generation_prompt %}.*', '', template, flags=re.DOTALL) model_settings['instruction_template'] = 'Custom (obtained from model metadata)' model_settings['instruction_template_str'] = template @@ -130,6 +131,7 @@ def get_model_metadata(model): template = template.replace(k, "'{}'".format(value)) template = re.sub(r'raise_exception\([^)]*\)', "''", template) + template = re.sub(r'{% if add_generation_prompt %}.*', '', template, flags=re.DOTALL) model_settings['instruction_template'] = 'Custom (obtained from model metadata)' model_settings['instruction_template_str'] = template