Fix incorrect logic in chat template handling. (#9336)
Signed-off-by: Xinyuan Tong <xinyuantong.cs@gmail.com> Co-authored-by: Xinyuan Tong <xinyuantong.cs@gmail.com>
This commit is contained in:
@@ -89,6 +89,7 @@ class TemplateManager:
|
|||||||
if template is None:
|
if template is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# TODO: remove this hard code the reasoning pattern
|
||||||
force_reasoning_pattern = r"<\|im_start\|>assistant\\n<think>\\n"
|
force_reasoning_pattern = r"<\|im_start\|>assistant\\n<think>\\n"
|
||||||
has_reasoning = re.search(force_reasoning_pattern, template) is not None
|
has_reasoning = re.search(force_reasoning_pattern, template) is not None
|
||||||
|
|
||||||
@@ -128,11 +129,12 @@ class TemplateManager:
|
|||||||
logger.info(
|
logger.info(
|
||||||
f"Using default HuggingFace chat template with detected content format: {self._jinja_template_content_format}"
|
f"Using default HuggingFace chat template with detected content format: {self._jinja_template_content_format}"
|
||||||
)
|
)
|
||||||
return
|
else:
|
||||||
|
# Default to string content format if no template was found
|
||||||
# Default to string content format if no template was found
|
self._jinja_template_content_format = "string"
|
||||||
self._jinja_template_content_format = "string"
|
logger.info(
|
||||||
logger.info("No chat template found, defaulting to 'string' content format")
|
"No chat template found, defaulting to 'string' content format"
|
||||||
|
)
|
||||||
|
|
||||||
# Detect reasoning pattern from chat template
|
# Detect reasoning pattern from chat template
|
||||||
if tokenizer_manager.tokenizer:
|
if tokenizer_manager.tokenizer:
|
||||||
|
|||||||
Reference in New Issue
Block a user