@@ -586,6 +586,37 @@ def push_to_hub(
586
586
create_pr : bool = False ,
587
587
tags : list [str ] | None = None ,
588
588
) -> str :
589
+ """
590
+ Upload the CrossEncoder model to the Hugging Face Hub.
591
+
592
+ Example:
593
+ ::
594
+
595
+ from sentence_transformers import CrossEncoder
596
+
597
+ model = CrossEncoder("cross-encoder/ms-marco-MiniLM-L6-v2")
598
+ model.push_to_hub("username/my-crossencoder-model")
599
+ # => "https://huggingface.co/username/my-crossencoder-model"
600
+
601
+ Args:
602
+ repo_id (str): The name of the repository on the Hugging Face Hub, e.g. "username/repo_name",
603
+ "organization/repo_name" or just "repo_name".
604
+ token (str, optional): The authentication token to use for the Hugging Face Hub API.
605
+ If not provided, will use the token stored via the Hugging Face CLI.
606
+ private (bool, optional): Whether to create a private repository. If not specified,
607
+ the repository will be public.
608
+ safe_serialization (bool, optional): Whether or not to convert the model weights in safetensors
609
+ format for safer serialization. Defaults to True.
610
+ commit_message (str, optional): The commit message to use for the push. Defaults to "Add new CrossEncoder model".
611
+ exist_ok (bool, optional): If True, do not raise an error if the repository already exists.
612
+ Ignored if ``create_pr=True``. Defaults to False.
613
+ revision (str, optional): The git branch to commit to. Defaults to the head of the 'main' branch.
614
+ create_pr (bool, optional): Whether to create a Pull Request with the upload or directly commit. Defaults to False.
615
+ tags (list[str], optional): A list of tags to add to the model card. Defaults to None.
616
+
617
+ Returns:
618
+ str: URL of the commit or pull request (if create_pr=True)
619
+ """
589
620
api = HfApi (token = token )
590
621
repo_url = api .create_repo (
591
622
repo_id = repo_id ,
0 commit comments