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

add cache_dir for tokenizer verification loading #14508

Conversation

vmaryasin
Copy link
Contributor

@vmaryasin vmaryasin commented Nov 24, 2021

When loading a pretrained tokenizer, a verification is done to ensure
that the actual tokenizer class matches the class it was called from.
If the tokenizer is absent, its config file is loaded from the repo.

However, the cache_dir for downloading is not provided, which leads to
ignoring of the user-specified cache_dir, storing files in several
places and and may result in incorrect warnings when the default
cache_dir is unreachsble.

See Issue #14138 for more details.

This commit fixes that.

What does this PR do?

Fixes #14138 Propagates user-specified cache_dir to tokenizer download during the tokenizer class check

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@n1t0, @LysandreJik

When loading a pretrained tokenizer, a verification is done to ensure
that the actual tokenizer class matches the class it was called from.
If the tokenizer is absent, its config file is loaded from the repo.

However, the cache_dir for downloading is not provided, which leads to
ignoring of the user-specified cache_dir, storing files in several
places and and may result in incorrect warnings when the default
cache_dir is unreachsble.

This commit fixes that.
@vmaryasin vmaryasin changed the title add cache_dir for tokenizer verification loading (#14138) add cache_dir for tokenizer verification loading Nov 24, 2021
@vmaryasin vmaryasin marked this pull request as ready for review November 24, 2021 10:37
Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

That looks good to me, thanks @vmaryasin!

@LysandreJik LysandreJik merged commit 6c4d688 into huggingface:master Nov 24, 2021
@vmaryasin vmaryasin deleted the fix-cache_dir-when-inferring-the-tokenizer-class branch March 17, 2022 10:18
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.

wrong cache_dir is used when tokenizer is trying to infer config_tokenizer_class
2 participants