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

Tokenizer pad token not saved with save_pretrained #26500

Closed
4 tasks
jonathanasdf opened this issue Sep 30, 2023 · 4 comments · Fixed by #26538
Closed
4 tasks

Tokenizer pad token not saved with save_pretrained #26500

jonathanasdf opened this issue Sep 30, 2023 · 4 comments · Fixed by #26538

Comments

@jonathanasdf
Copy link

System Info

works on 4.33.3 (with tokenizers==0.13.3), fails on main (with tokenizers==0.14.0)

Who can help?

@ArthurZucker

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

import transformers
tokenizer = transformers.AutoTokenizer.from_pretrained('stabilityai/FreeWilly2')
tokenizer.pad_token_id = 0
print(tokenizer.pad_token)
tokenizer.save_pretrained('/tmp/tok_test')
tok = transformers.AutoTokenizer.from_pretrained('/tmp/tok_test')
print(tok.pad_token)

Expected behavior

expected:

>>> print(tok.pad_token)
<unk>

actual:

>>> print(tok.pad_token)
Using pad_token, but it is not set yet.
None
@ArthurZucker
Copy link
Collaborator

Having a look now! Thanks

@ArthurZucker
Copy link
Collaborator

Okay, quite suprisingly, the previous behaviour only saved the pad token to special_tokens_map.json and not in the tokenizer_config.json. Thus the padding was set to null in both the tokenizer_config.json and the tokenizer.json. Which IMO is not good 😄

@jonathanasdf
Copy link
Author

This particular example was fixed, thanks.

However a similar example now fails

import transformers
tokenizer = transformers.AutoTokenizer.from_pretrained('tiiuae/falcon-40b-instruct')
tokenizer.pad_token = tokenizer.eos_token
print(tokenizer.pad_token)  # '<|endoftext|>'
tokenizer.save_pretrained('/tmp/tok_test')
tok = transformers.AutoTokenizer.from_pretrained('/tmp/tok_test')
print(tok.pad_token)  # None!

@ArthurZucker
Copy link
Collaborator

Thanks I'll fix this in #26570 🤗

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 a pull request may close this issue.

2 participants