question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Avoiding the time consuming for downloading the pre-trained models

See original GitHub issue

📚 Migration

Very great project! I can successfully run the code:

from transformers import AutoTokenizer, AutoModel

tokenizer = AutoTokenizer.from_pretrained("bert-base-chinese")
model_Bert = AutoModel.from_pretrained("bert-base-chinese")

But, every time I run my code, the downloading processing are repeated, which is time consuming. So I wonder how to load the pre-trained models from my local directory instead of downloading the pre-trained models everytime?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
zartdinovcommented, Nov 9, 2021

Hi! It should work (examples for Linux systems)

# Save model to directory:
model.save_pretrained("./my_model_directory/") 

# Load model from directory:
model = AutoModel.from_pretrained("./my_model_directory/")

####################### OR ###########################

# Cache model to directory:
model = AutoModel.from_pretrained("bert-base-chinese", cache_dir="./my_model_directory/")
0reactions
github-actions[bot]commented, Dec 9, 2021

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handling big models - Hugging Face
When loading a pretrained model in PyTorch, the usual workflow looks like this: ... we load a full version of the model in...
Read more >
Downloading huggingface pre-trained models - Stack Overflow
1 Answer 1 · A simpler way is to use use cache_dir argument (huggingface.co/docs/transformers/v4.21.0/en/main_classes/…) of a from_pretrained ...
Read more >
EfficientNet should be the goto pre-trained model or…
You will need TensorFlow-Nightly as EfficientNet is not currently supported in its stable version and Kaggle for downloading the dataset and ...
Read more >
Pre-trained models: Past, present and future - ScienceDirect
Large-scale pre-trained models (PTMs) such as BERT and GPT have recently achieved great ... However, it is expensive and time-consuming to manually annotate ......
Read more >
Jump-start AI Training with NGC Pretrained Models On ...
Without the availability of the correct pretrained model, it would be necessary to pretrain the model yourself, a monumental task. In fact, the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found