Skip to content

push_to_hf

allennlp.common.push_to_hf

[SOURCE]


Utilities for pushing models to the Hugging Face Hub (hf.co).

README_TEMPLATE

README_TEMPLATE = """---
tags:
- allennlp
---

# TODO: Fill this model card
"""

push_to_hf

def push_to_hf(
    repo_name: str,
    serialization_dir: Optional[Union[str, PathLike]] = None,
    archive_path: Optional[Union[str, PathLike]] = None,
    organization: Optional[str] = None,
    commit_message: str = "Update repository",
    local_repo_path: Union[str, PathLike] = "hub",
    use_auth_token: Union[bool, str] = True
) -> str

Pushes model and related files to the Hugging Face Hub (hf.co)

Parameters

  • repo_name : str
    Name of the repository in the Hugging Face Hub.

  • serialization_dir : Union[str, PathLike], optional (default = None)
    Full path to a directory with the serialized model.

  • archive_path : Union[str, PathLike], optional (default = None)
    Full path to the zipped model (e.g. model/model.tar.gz). Use serialization_dir if possible.

  • organization : Optional[str], optional (default = None)
    Name of organization to which the model should be uploaded.

  • commit_message : str, optional (default = Update repository)
    Commit message to use for the push.

  • local_repo_path : Union[str, Path], optional (default = hub)
    Local directory where the repository will be saved.

use_auth_token (str or bool, optional, defaults True): huggingface_token can be extract from HfApi().login(username, password) and is used to authenticate against the Hugging Face Hub (useful from Google Colab for instance). It's automatically retrieved if you've done huggingface-cli login before.