Skip to content

Conversation

@vdebergue
Copy link

Bug

Using Tokenizer::from_pretrained does not download the tokenizer into the HF_HOME folder.
Instead it will download it in the user home cache directory.

Fix

Use env variable to load the ApiBuilder so it will read HF_HOME variable.
Currently they are ignored and the default cache location is used $HOME/.cache/huggingface

Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

Not super familiar with API builder, if no evn var is defined I am guessing this is equivalent right? It won't just error out instead?

@vdebergue
Copy link
Author

yes, without env it will fallback to the default and will be equivalent to ApiBuilder::new()

}

let mut builder = ApiBuilder::new();
let mut builder = ApiBuilder::from_env();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
let mut builder = ApiBuilder::from_env();
let mut builder = ApiBuilder::from_env("HF_HOME");

should we not set that?

Copy link
Author

Choose a reason for hiding this comment

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

from_env does not take any parameter: https://github.com/huggingface/hf-hub/blob/main/src/api/sync.rs#L242 and the name of the env variables are already set in the code

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh shit okay, I was looking at https://docs.rs/env_logger/latest/env_logger/struct.Builder.html#method.from_env, thanks for the heads up

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@ArthurZucker
Copy link
Collaborator

Can you run cargo clippy!

@ArthurZucker
Copy link
Collaborator

Sorry found #1737 which was opened sooner!

@vdebergue
Copy link
Author

closing then, thanks !

@vdebergue vdebergue closed this May 27, 2025
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