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

Fix tiny model script: not using from_pt=True #27372

Merged
merged 1 commit into from
Nov 8, 2023

Conversation

ydshieh
Copy link
Collaborator

@ydshieh ydshieh commented Nov 8, 2023

What does this PR do?

After #27064, the checkpoint is saved with format safetensors. If we specify from_pretrained("...", from_pt=True) while the checkpoint is in safetensors format, we get error like invalid load key *\xa0* (or *\xd8* etc.).

This PR remove the usage of from_pt=True and therefore fix 1 issue in the failing CI (that checks the script working).

Code snippet

from transformers import BertModel, TFBertModel


ckpt = "hf-internal-testing/tiny-random-BertModel"

bert_pt = BertModel.from_pretrained(ckpt)
bert_pt.save_pretrained("my-bert")

# this works
bert_tf = TFBertModel.from_pretrained("my-bert")

# this fail
bert_tf = TFBertModel.from_pretrained("my-bert", from_pt=True)
print(bert_tf)

@ydshieh ydshieh requested a review from amyeroberts November 8, 2023 15:53
Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

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

Thanks for fixing!

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Nov 8, 2023

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

@ydshieh ydshieh merged commit bd8f45b into main Nov 8, 2023
3 checks passed
@ydshieh ydshieh deleted the fix_tiny_model_script_001 branch November 8, 2023 16:15
EduardoPach pushed a commit to EduardoPach/transformers that referenced this pull request Nov 19, 2023
fix

Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
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.

3 participants