Skip to content

Commit

Permalink
add chat_template warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
yonigozlan committed Oct 22, 2024
1 parent f39669c commit 46d6891
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/transformers/pipelines/image_text_to_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ def __call__(
text[0], (list, tuple, dict)
):
# We have one or more prompts in list-of-dicts format, so this is chat mode

if isinstance(text[0], dict):
return super().__call__(Chat(text, images), **kwargs)
else:
Expand All @@ -287,6 +286,13 @@ def __call__(
chats = [Chat(chat, image) for chat, image in zip(text, images)] # 🐈 🐈 🐈
return super().__call__(chats, **kwargs)

# encourage the user to use the chat format if supported
if hasattr(self.processor, "chat_template") and self.processor.chat_template is not None:
logger.warning_once(
"The pipeline detected no chat format in the prompt, but this model supports chat format. "
"Consider using the chat format for better results. For more information, see https://huggingface.co/docs/transformers/en/chat_templating"
)

# support text only generation
if images is None:
return super().__call__(text, **kwargs)
Expand Down

0 comments on commit 46d6891

Please sign in to comment.