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

Compatibility Issue: Adapting MolGen Transformers (4.31.0) with Swift Framework (Transformers 4.47.1) #22

Open
hotwa opened this issue Jan 3, 2025 · 2 comments

Comments

@hotwa
Copy link

hotwa commented Jan 3, 2025

I am using the swift framework, which relies on transformers==4.47.1. It's can use in NPU by huawei. However, this MolGen project is built on transformers==4.31.0 and uses custom Bart model code that is not compatible with the Chat Template feature introduced in transformers==4.47.1.

Specifically, I encounter the following error when using the swift framework:

ValueError: Cannot use chat template functions because tokenizer.chat_template is not set and no template argument was passed!

I want to adapt my MolGen project to work with transformers==4.47.1 to maintain compatibility with swift.

What I’ve Tried:
Downgrading transformers to 4.31.0 resolves the issue for MolGen, but it breaks the swift framework as it requires 4.47.1.
Investigating the use of chat_template but found MolGen's implementation heavily relies on the old API.
Questions:
What is the best way to adapt the MolGen project to support transformers==4.47.1 without breaking compatibility with its custom Bart model code?
Are there specific changes I can make to MolGen's codebase to ensure compatibility with swift while maintaining its functionality?
Any guidance or suggestions would be greatly appreciated. Thank you!

@Fangyinfff
Copy link
Collaborator

Hi, thanks for your interest. Below are some possible adaptation ideas. They’re not guaranteed to work for every setup, so please test them yourself:

  1. In the custom Bart/Tokenizer code, ensure tokenizer.chat_template is defined. For example, assign an empty ChatPromptTemplate during initialization, and ignore (or minimally handle) any chat-specific parameters in generate().
  2. Look at the differences between the official Bart code in Transformers 4.31.0 and 4.47.1, then apply your custom modifications on top of the newer version. This likely involves editing files in the MolGen/model/bart folder.

@zxlzr
Copy link
Contributor

zxlzr commented Jan 8, 2025

hi, do you have any further questions?

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