模型下載
藉助git lfs下載
- 該方式會將模型整體目錄下載到當前目錄下
$ git lfs install $ git clone https://huggingface.co/THUDM/chatglm3-6b $ git clone https://huggingface.co/BAAI/bge-large-zh
程式碼直接下載
- 需要開啟代理
- jupyter有可能不支援,需要切換到終端裡面執行程式碼下載
- 下載的模型目錄會自動儲存在 ~/.cache/huggingface/hub
from transformers import BertTokenizer, BertModel tokenizer = BertTokenizer.from_pretrained("bert-base-uncased") model = BertModel.from_pretrained("bert-base-uncased")
- 指定下載目錄
custom_cache_dir = "/path/to/your/custom/cache/directory" model = BertModel.from_pretrained("bert-base-uncased", cache_dir=custom_cache_dir)