Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: "No chat template is set for this processor" #23

Open
aymeric-roucher opened this issue Oct 11, 2024 · 2 comments
Open

Error: "No chat template is set for this processor" #23

aymeric-roucher opened this issue Oct 11, 2024 · 2 comments

Comments

@aymeric-roucher
Copy link

I'm trying to run the example in inference/notebooks/01_single_image_understanding.ipynb, but I get this error:

 text = processor.apply_chat_template(messages, add_generation_prompt=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ubuntu/transformers/src/transformers/processing_utils.py", line 1096, in apply_chat_template
    raise ValueError(
ValueError: No chat template is set for this processor. Please either set the `chat_template` attribute, or provide a chat template as an argument. See https://huggingface.co/docs/transformers/main/en/chat_templating for more information.

However, using:

tokenizer = AutoTokenizer.from_pretrained(model_id_or_path)

  processor = AriaProcessor.from_pretrained(
          model_id_or_path, tokenizer_path=model_id_or_path, chat_template=tokenizer.chat_template,
      )

Fixes it. I can open a PR if that helps!

@xffxff
Copy link
Collaborator

xffxff commented Oct 11, 2024

Thanks for catching this, feel free to open a PR to fix it @aymeric-roucher

@aria-hacker
Copy link
Collaborator

@aymeric-roucher Thanks for pointing out this, could you kindly share some more detailed environments to reproduce this error? We just test it with transformers 4.45.0 and it seems errorless in our environment.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants