This is a collections of snippets and scripts that come in handy for handling a release on the Hub. There is no order in these snippets, but they have come in clutch in pretty much all the releases.
from huggingface_hub import create_collection, HfApi, move_repo
import os
api = HfApi(token=os.getenv("HF_TOKEN"))
models = api.list_models(model_name = "xx/llama") # Replace with your query
for model in iter(models):
move_repo(from_id=model.id, to_id=f"meta/{model.id.split("/")[-1]}") # Replace with the destination org
from huggingface_hub import update_repo_visibility
models = ["some/repo"]
def do_publish(source):
update_repo_visibility(source, private=False)
for model_id in models:
do_publish(model_id)
from huggingface_hub import metadata_update
for repo_name in ["lol/yolo"]:
metadata_update(repo_name,
{"library_name": "transformers"},
overwrite=True,
create_pr=True)
Run this from the folder you want to upload from. You can choose individual files, or use the .
wildcard to upload everything in the current folder.
huggingface-cli upload --create-pr meta-llama/Llama-Guard-3-11B-Vision .
huggingface-cli download meta-llama/Llama-3.2-3B-Instruct --local-dir Llama-3.2-3B-Instruct --local-dir-use-symlinks False
P.S. for large repos - make sure to setup hf_transfer
-> pip install hf_transfer
from huggingface_hub import HfApi
api = HfApi()
repo_id = "some/repo"
api.super_squash_history(repo_id=repo_id)
In a almost all cases it is a good idea to verify both the slow as well as fast tokenizer after a model has been converted via official scripts.
Refer to this notebook to test the same: https://github.com/Vaibhavs10/scratchpad/blob/main/tokenizer_check_minimal_example.ipynb