ludwig-ai / ludwig

Low-code framework for building custom LLMs, neural networks, and other AI models
http://ludwig.ai
Apache License 2.0
11.22k stars 1.19k forks source link

Add utility function for uploading local folders to huggingface hub #3805

Closed arnavgarg1 closed 12 months ago

arnavgarg1 commented 12 months ago

This is useful for uploading any local files to huggingface hub. In particular, I use this for saving dequantized base model weights. Usage is very simple!

from ludwig.utils.hf_utils import upload_folder_to_hfhub
upload_folder_to_hfhub(repo_id="", folder_path="")

This will create a repository on huggingface hub if it doesn't exist, and upload all files in the local folder to huggingface hub at that repo id.

There are a variety of optional parameters that can be specified:


Here's an example of how I used it:

>>> from ludwig.utils.hf_utils import upload_folder_to_hfhub
>>> upload_folder_to_hfhub(repo_id="arnavgrg/codallama-7b-instruct-nf4-fp16-upscaled", folder_path="/home/ray/codellama-7b-instruct-upscaled")
arnavgrg/codallama-7b-instruct-nf4-fp16-upscaled does not exist. Creating.
Uploading folder /home/ray/codellama-7b-instruct-upscaled to repo arnavgrg/codallama-7b-instruct-nf4-fp16-upscaled.
tokenizer.model: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████| 500k/500k [00:00<00:00, 1.00MB/s]
model-00003-of-00003.safetensors: 100%|████████████████████████████████████████████████████████████████████████████████| 3.59G/3.59G [01:35<00:00, 37.8MB/s]
model-00001-of-00003.safetensors: 100%|████████████████████████████████████████████████████████████████████████████████| 4.94G/4.94G [02:03<00:00, 40.1MB/s]
model-00002-of-00003.safetensors: 100%|████████████████████████████████████████████████████████████████████████████████| 4.95G/4.95G [02:03<00:00, 40.1MB/s]
Upload 4 LFS files: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████| 4/4 [02:03<00:00, 30.89s/it]

and the artifacts live here: https://huggingface.co/arnavgrg/codallama-7b-instruct-nf4-fp16-upscaled/tree/main

Screenshot 2023-12-05 at 9 05 35 PM
github-actions[bot] commented 12 months ago

Unit Test Results

  6 files  ±0    6 suites  ±0   14m 32s :stopwatch: +11s 12 tests ±0    9 :heavy_check_mark: ±0    3 :zzz: ±0  0 :x: ±0  60 runs  ±0  42 :heavy_check_mark: ±0  18 :zzz: ±0  0 :x: ±0 

Results for commit 304f6c4d. ± Comparison against base commit 21d3ab28.