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

Tweak ESM tokenizer for Nucleotide Transformer #22770

Merged
merged 2 commits into from
Apr 14, 2023

Conversation

Rocketknight1
Copy link
Member

Nucleotide Transformer is a model that takes DNA inputs. It uses the same model architecture as the protein model ESM, but in addition to a different vocabulary it tokenizes inputs without a <sep> or <eos> token at the end. This PR makes a small tweak to the tokenization code for ESM, so that it doesn't try to add self.eos_token_id to sequences when the tokenizer does not have an eos_token set. With this change, we can fully support Nucleotide Transformer as an ESM checkpoint.

return cls + token_ids_0
else:
return cls + token_ids_0 + sep
elif sep is None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be:

Suggested change
elif sep is None:
elif self.eos_token_id is None:

as sep is always a list?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spotted that one just before you got here, and yes you're right!

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Apr 14, 2023

The documentation is not available anymore as the PR was closed or merged.

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Rocketknight1 Rocketknight1 merged commit 06e737f into main Apr 14, 2023
@Rocketknight1 Rocketknight1 deleted the nucleotide_transformer_tokenizer branch April 14, 2023 14:18
novice03 pushed a commit to novice03/transformers that referenced this pull request Jun 23, 2023
* If EOS is None, don't add it to sequences

* If EOS is None, don't add it to sequences
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

Successfully merging this pull request may close these issues.

4 participants