rhymes-ai / Aria

Codebase for Aria - an Open Multimodal Native MoE
Apache License 2.0
818 stars 70 forks source link

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

Open aymeric-roucher opened 1 month ago

aymeric-roucher commented 1 month ago

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 commented 1 month ago

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

aria-hacker commented 1 month ago

@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