TypeError: HfApi.create_repo() got an unexpected keyword argument 'organization'

581 Views Asked by At

I follow tutorial https://huggingface.co/blog/how-to-train-sentence-transformers . Its Colab notebook is https://colab.research.google.com/github/huggingface/blog/blob/main/notebooks/95_Training_Sentence_Transformers.ipynb#scrollTo=sM6pu_adyUw6&line=2&uniqifier=1

My Colab notebook https://colab.research.google.com/drive/1iQdWp0yF82ebGMB9IrYp8EROQE8hL7jp?usp=sharing#scrollTo=I4YYPy87raMn

I have

model.save_to_hub(
    "distilroberta-base-sentence-transformer", 
    organization="donhuvy",
    train_datasets=["embedding-data/QQP_triplets"],
    exist_ok=True, 
    )

Error

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-16-4e42bc771dab> in <cell line: 1>()
----> 1 model.save_to_hub(
      2     "distilroberta-base-sentence-transformer",
      3     organization="donhuvy",
      4     train_datasets=["embedding-data/QQP_triplets"],
      5     exist_ok=True,

1 frames
/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_validators.py in _inner_fn(*args, **kwargs)
    118             kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__, has_token=has_token, kwargs=kwargs)
    119 
--> 120         return fn(*args, **kwargs)
    121 
    122     return _inner_fn  # type: ignore

TypeError: HfApi.create_repo() got an unexpected keyword argument 'organization'

Image https://i.stack.imgur.com/ZOoTV.png

How to fix it? Expected: Running without error.

2

There are 2 best solutions below

0
On

i also followed the same tutorial (https://huggingface.co/blog/how-to-train-sentence-transformers) and encountered the same error as you did.

Finally, i cloned the github repo of sentence-transformer and installed sentence-transformer from sources.

$ pip install -e .

And the problem is solved.

0
On

You can use HfApi from huggingface_hub library, with something like this it should work (make sure you log before) :

from huggingface_hub import HfApi
api = HfApi()

api.upload_folder(
    folder_path='/content/model',
    repo_id='donhuvy/distilroberta-base-sentence-transformer',
    repo_type='model',
)