fix error for chat template
This commit is contained in:
parent
8108f1bf11
commit
e539965740
1 changed files with 9 additions and 1 deletions
|
|
@ -744,13 +744,21 @@ class InferenceBackend:
|
|||
)
|
||||
else:
|
||||
logger.info(
|
||||
f"No registered template for {self.active_model_name}, using tokenizer default"
|
||||
f"No registered Unsloth template for {self.active_model_name}, using tokenizer default"
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(f"Could not apply get_chat_template: {e}")
|
||||
|
||||
# Step 2: Format with tokenizer.apply_chat_template()
|
||||
try:
|
||||
if not (hasattr(tokenizer, 'chat_template') and tokenizer.chat_template):
|
||||
raise ValueError(
|
||||
f"Model '{self.active_model_name}' has no chat_template set in its "
|
||||
f"tokenizer_config.json. This is usually a problem with the model's "
|
||||
f"HuggingFace repository — it is missing a 'chat_template' key. "
|
||||
f"Please use a model that includes a chat template, or manually set "
|
||||
f"one via tokenizer.chat_template before inference."
|
||||
)
|
||||
formatted_prompt = tokenizer.apply_chat_template(
|
||||
messages, tokenize = False, add_generation_prompt = True
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue