model_sharing.rst 17 KB
Newer Older
Sylvain Gugger's avatar
Sylvain Gugger committed
1
2
3
4
5
6
7
8
9
10
11
12
.. 
    Copyright 2020 The HuggingFace Team. All rights reserved.

    Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
    the License. You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
    an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
    specific language governing permissions and limitations under the License.

Sylvain Gugger's avatar
Sylvain Gugger committed
13
14
15
16
17
18
Model sharing and uploading
=======================================================================================================================

In this page, we will show you how to share a model you have trained or fine-tuned on new data with the community on
the `model hub <https://huggingface.co/models>`__.

19
20
21
22
23
24
.. raw:: html

   <iframe width="560" height="315" src="https://www.youtube.com/embed/XvSGPZFEjDY" title="YouTube video player"
   frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope;
   picture-in-picture" allowfullscreen></iframe>

Sylvain Gugger's avatar
Sylvain Gugger committed
25
26
27
28
29
30
31
32
33
.. note::

    You will need to create an account on `huggingface.co <https://huggingface.co/join>`__ for this.

    Optionally, you can join an existing organization or create a new one.


We have seen in the :doc:`training tutorial <training>`: how to fine-tune a model on a given task. You have probably
done something similar on your task, either using the model directly in your own training loop or using the
Sylvain Gugger's avatar
Sylvain Gugger committed
34
35
:class:`~.transformers.Trainer`/:class:`~.transformers.TFTrainer` class. Let's see how you can share the result on the
`model hub <https://huggingface.co/models>`__.
Sylvain Gugger's avatar
Sylvain Gugger committed
36

Lysandre Debut's avatar
Lysandre Debut committed
37
Model versioning
Sylvain Gugger's avatar
Sylvain Gugger committed
38
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sylvain Gugger's avatar
Sylvain Gugger committed
39

Lysandre Debut's avatar
Lysandre Debut committed
40
41
42
43
44
45
46
47
48
49
50
Since version v3.5.0, the model hub has built-in model versioning based on git and git-lfs. It is based on the paradigm
that one model *is* one repo.

This allows:

- built-in versioning
- access control
- scalability

This is built around *revisions*, which is a way to pin a specific version of a model, using a commit hash, tag or
branch.
Sylvain Gugger's avatar
Sylvain Gugger committed
51

Lysandre Debut's avatar
Lysandre Debut committed
52
For instance:
Sylvain Gugger's avatar
Sylvain Gugger committed
53
54
55

.. code-block::

56
    >>> model = AutoModel.from_pretrained(
Lysandre Debut's avatar
Lysandre Debut committed
57
58
59
60
    >>>   "julien-c/EsperBERTo-small",
    >>>   revision="v2.0.1" # tag name, or branch name, or commit hash
    >>> )

Sylvain Gugger's avatar
Sylvain Gugger committed
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78

Push your model from Python
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Preparation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The first step is to make sure your credentials to the hub are stored somewhere. This can be done in two ways. If you
have access to a terminal, you cam just run the following command in the virtual environment where you installed 馃
Transformers:

.. code-block:: bash

    transformers-cli login

It will store your access token in the Hugging Face cache folder (by default :obj:`~/.cache/`).

If you don't have an easy access to a terminal (for instance in a Colab session), you can find a token linked to your
79
account by going on `huggingface.co <https://huggingface.co/>`, click on your avatar on the top left corner, then on
Sylvain Gugger's avatar
Sylvain Gugger committed
80
81
82
83
84
85
`Edit profile` on the left, just beneath your profile picture. In the submenu `API Tokens`, you will find your API
token that you can just copy.

Directly push your model to the hub
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

86
87
88
89
90
91
.. raw:: html

   <iframe width="560" height="315" src="https://www.youtube.com/embed/Z1-XMy-GNLQ" title="YouTube video player"
   frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope;
   picture-in-picture" allowfullscreen></iframe>

Sylvain Gugger's avatar
Sylvain Gugger committed
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
Once you have an API token (either stored in the cache or copied and pasted in your notebook), you can directly push a
finetuned model you saved in :obj:`save_drectory` by calling:

.. code-block:: python

    finetuned_model.push_to_hub("my-awesome-model")

If you have your API token not stored in the cache, you will need to pass it with :obj:`use_auth_token=your_token`.
This is also be the case for all the examples below, so we won't mention it again.

This will create a repository in your namespace name :obj:`my-awesome-model`, so anyone can now run:

.. code-block:: python

    from transformers import AutoModel

    model = AutoModel.from_pretrained("your_username/my-awesome-model")

Even better, you can combine this push to the hub with the call to :obj:`save_pretrained`:

.. code-block:: python

    finetuned_model.save_pretrained(save_directory, push_to_hub=True, repo_name="my-awesome-model")

If you are a premium user and want your model to be private, just add :obj:`private=True` to this call.

If you are a member of an organization and want to push it inside the namespace of the organization instead of yours,
just add :obj:`organization=my_amazing_org`.

Add new files to your model repo
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Once you have pushed your model to the hub, you might want to add the tokenizer, or a version of your model for another
framework (TensorFlow, PyTorch, Flax). This is super easy to do! Let's begin with the tokenizer. You can add it to the
repo you created before like this

.. code-block:: python

    tokenizer.push_to_hub("my-awesome-model")

If you know its URL (it should be :obj:`https://huggingface.co/username/repo_name`), you can also do:

.. code-block:: python

    tokenizer.push_to_hub(repo_url=my_repo_url)

And that's all there is to it! It's also a very easy way to fix a mistake if one of the files online had a bug.

To add a model for another backend, it's also super easy. Let's say you have fine-tuned a TensorFlow model and want to
add the pytorch model files to your model repo, so that anyone in the community can use it. The following allows you to
directly create a PyTorch version of your TensorFlow model:

.. code-block:: python

146
    from transformers import AutoModel
Sylvain Gugger's avatar
Sylvain Gugger committed
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166

    model = AutoModel.from_pretrained(save_directory, from_tf=True)

You can also replace :obj:`save_directory` by the identifier of your model (:obj:`username/repo_name`) if you don't
have a local save of it anymore. Then, just do the same as before:

.. code-block:: python

    model.push_to_hub("my-awesome-model")

or

.. code-block:: python

    model.push_to_hub(repo_url=my_repo_url)


Use your terminal and git
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

167
168
169
170
171
172
.. raw:: html

   <iframe width="560" height="315" src="https://www.youtube.com/embed/rkCly_cbMBk" title="YouTube video player"
   frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope;
   picture-in-picture" allowfullscreen></iframe>

Lysandre Debut's avatar
Lysandre Debut committed
173
174
175
176
Basic steps
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

In order to upload a model, you'll need to first create a git repo. This repo will live on the model hub, allowing
177
178
users to clone it and you (and your organization members) to push to it.

179
You can create a model repo directly from `the /new page on the website <https://huggingface.co/new>`__.
180
181

Alternatively, you can use the ``transformers-cli``. The next steps describe that process:
Sylvain Gugger's avatar
Sylvain Gugger committed
182

183
Go to a terminal and run the following command. It should be in the virtual environment where you installed 馃
Lysandre Debut's avatar
Lysandre Debut committed
184
Transformers, since that command :obj:`transformers-cli` comes from the library.
Sylvain Gugger's avatar
Sylvain Gugger committed
185

Sylvain Gugger's avatar
Sylvain Gugger committed
186
.. code-block:: bash
Sylvain Gugger's avatar
Sylvain Gugger committed
187

Lysandre Debut's avatar
Lysandre Debut committed
188
189
    transformers-cli login

Sylvain Gugger's avatar
Sylvain Gugger committed
190

Lysandre Debut's avatar
Lysandre Debut committed
191
Once you are logged in with your model hub credentials, you can start building your repositories. To create a repo:
Sylvain Gugger's avatar
Sylvain Gugger committed
192

Sylvain Gugger's avatar
Sylvain Gugger committed
193
.. code-block:: bash
Sylvain Gugger's avatar
Sylvain Gugger committed
194

Lysandre Debut's avatar
Lysandre Debut committed
195
    transformers-cli repo create your-model-name
Sylvain Gugger's avatar
Sylvain Gugger committed
196

Patrick von Platen's avatar
Patrick von Platen committed
197
198
199
200
201
202
203
If you want to create a repo under a specific organization, you should add a `--organization` flag:

.. code-block:: bash

    transformers-cli repo create your-model-name --organization your-org-name

This creates a repo on the model hub, which can be cloned.
Sylvain Gugger's avatar
Sylvain Gugger committed
204

Sylvain Gugger's avatar
Sylvain Gugger committed
205
.. code-block:: bash
Sylvain Gugger's avatar
Sylvain Gugger committed
206

207
208
209
210
    # Make sure you have git-lfs installed
    # (https://git-lfs.github.com/)
    git lfs install

211
212
    git clone https://huggingface.co/username/your-model-name

213
214
215
216
217
218
When you have your local clone of your repo and lfs installed, you can then add/remove from that clone as you would
with any other git repo.

.. code-block:: bash

    # Commit as usual
Lysandre Debut's avatar
Lysandre Debut committed
219
220
221
222
    cd your-model-name
    echo "hello" >> README.md
    git add . && git commit -m "Update from $USER"

Patrick von Platen's avatar
Patrick von Platen committed
223
224
We are intentionally not wrapping git too much, so that you can go on with the workflow you're used to and the tools
you already know.
Lysandre Debut's avatar
Lysandre Debut committed
225

226
227
228
The only learning curve you might have compared to regular git is the one for git-lfs. The documentation at
`git-lfs.github.com <https://git-lfs.github.com/>`__ is decent, but we'll work on a tutorial with some tips and tricks
in the coming weeks!
Sylvain Gugger's avatar
Sylvain Gugger committed
229

Patrick von Platen's avatar
Patrick von Platen committed
230
231
232
Additionally, if you want to change multiple repos at once, the `change_config.py script
<https://github.com/huggingface/efficient_scripts/blob/main/change_config.py>`__ can probably save you some time.

Sylvain Gugger's avatar
Sylvain Gugger committed
233
234
235
236
237
238
239
240
Make your model work on all frameworks
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. 
    TODO Sylvain: make this automatic during the upload

You probably have your favorite framework, but so will other users! That's why it's best to upload your model with both
PyTorch `and` TensorFlow checkpoints to make it easier to use (if you skip this step, users will still be able to load
Sylvain Gugger's avatar
Sylvain Gugger committed
241
your model in another framework, but it will be slower, as it will have to be converted on the fly). Don't worry, it's
242
super easy to do (and in a future version, it might all be automatic). You will need to install both PyTorch and
Sylvain Gugger's avatar
Sylvain Gugger committed
243
244
245
TensorFlow for this step, but you don't need to worry about the GPU, so it should be very easy. Check the `TensorFlow
installation page <https://www.tensorflow.org/install/pip#tensorflow-2.0-rc-is-available>`__ and/or the `PyTorch
installation page <https://pytorch.org/get-started/locally/#start-locally>`__ to see how.
Sylvain Gugger's avatar
Sylvain Gugger committed
246
247

First check that your model class exists in the other framework, that is try to import the same model by either adding
Sylvain Gugger's avatar
Sylvain Gugger committed
248
or removing TF. For instance, if you trained a :class:`~transformers.DistilBertForSequenceClassification`, try to type
Sylvain Gugger's avatar
Sylvain Gugger committed
249
250
251

.. code-block::

Lysandre Debut's avatar
Lysandre Debut committed
252
    >>> from transformers import TFDistilBertForSequenceClassification
Sylvain Gugger's avatar
Sylvain Gugger committed
253

Sylvain Gugger's avatar
Sylvain Gugger committed
254
and if you trained a :class:`~transformers.TFDistilBertForSequenceClassification`, try to type
Sylvain Gugger's avatar
Sylvain Gugger committed
255
256
257

.. code-block::

Lysandre Debut's avatar
Lysandre Debut committed
258
    >>> from transformers import DistilBertForSequenceClassification
Sylvain Gugger's avatar
Sylvain Gugger committed
259
260
261
262
263
264
265
266
267

This will give back an error if your model does not exist in the other framework (something that should be pretty rare
since we're aiming for full parity between the two frameworks). In this case, skip this and go to the next step.

Now, if you trained your model in PyTorch and have to create a TensorFlow version, adapt the following code to your
model class:

.. code-block::

Lysandre Debut's avatar
Lysandre Debut committed
268
269
    >>> tf_model = TFDistilBertForSequenceClassification.from_pretrained("path/to/awesome-name-you-picked", from_pt=True)
    >>> tf_model.save_pretrained("path/to/awesome-name-you-picked")
Sylvain Gugger's avatar
Sylvain Gugger committed
270
271
272
273
274
275

and if you trained your model in TensorFlow and have to create a PyTorch version, adapt the following code to your
model class:

.. code-block::

Lysandre Debut's avatar
Lysandre Debut committed
276
277
    >>> pt_model = DistilBertForSequenceClassification.from_pretrained("path/to/awesome-name-you-picked", from_tf=True)
    >>> pt_model.save_pretrained("path/to/awesome-name-you-picked")
Sylvain Gugger's avatar
Sylvain Gugger committed
278
279
280

That's all there is to it!

Lysandre Debut's avatar
Lysandre Debut committed
281
Check the directory before pushing to the model hub.
Sylvain Gugger's avatar
Sylvain Gugger committed
282
283
284
285
286
287
288
289
290
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Make sure there are no garbage files in the directory you'll upload. It should only have:

- a `config.json` file, which saves the :doc:`configuration <main_classes/configuration>` of your model ;
- a `pytorch_model.bin` file, which is the PyTorch checkpoint (unless you can't have it for some reason) ;
- a `tf_model.h5` file, which is the TensorFlow checkpoint (unless you can't have it for some reason) ;
- a `special_tokens_map.json`, which is part of your :doc:`tokenizer <main_classes/tokenizer>` save;
- a `tokenizer_config.json`, which is part of your :doc:`tokenizer <main_classes/tokenizer>` save;
Sylvain Gugger's avatar
Sylvain Gugger committed
291
292
- files named `vocab.json`, `vocab.txt`, `merges.txt`, or similar, which contain the vocabulary of your tokenizer, part
  of your :doc:`tokenizer <main_classes/tokenizer>` save;
Sylvain Gugger's avatar
Sylvain Gugger committed
293
294
295
296
297
- maybe a `added_tokens.json`, which is part of your :doc:`tokenizer <main_classes/tokenizer>` save.

Other files can safely be deleted.


Lysandre Debut's avatar
Lysandre Debut committed
298
299
Uploading your files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sylvain Gugger's avatar
Sylvain Gugger committed
300

Lysandre Debut's avatar
Lysandre Debut committed
301
302
Once the repo is cloned, you can add the model, configuration and tokenizer files. For instance, saving the model and
tokenizer files:
Sylvain Gugger's avatar
Sylvain Gugger committed
303
304
305

.. code-block::

Lysandre Debut's avatar
Lysandre Debut committed
306
307
    >>> model.save_pretrained("path/to/repo/clone/your-model-name")
    >>> tokenizer.save_pretrained("path/to/repo/clone/your-model-name")
Sylvain Gugger's avatar
Sylvain Gugger committed
308

Lysandre Debut's avatar
Lysandre Debut committed
309
Or, if you're using the Trainer API
Sylvain Gugger's avatar
Sylvain Gugger committed
310
311
312

.. code-block::

Lysandre Debut's avatar
Lysandre Debut committed
313
    >>> trainer.save_model("path/to/awesome-name-you-picked")
Sylvain Gugger's avatar
Sylvain Gugger committed
314
    >>> tokenizer.save_pretrained("path/to/repo/clone/your-model-name")
Sylvain Gugger's avatar
Sylvain Gugger committed
315

Lysandre Debut's avatar
Lysandre Debut committed
316
317
You can then add these files to the staging environment and verify that they have been correctly staged with the ``git
status`` command:
Sylvain Gugger's avatar
Sylvain Gugger committed
318

Sylvain Gugger's avatar
Sylvain Gugger committed
319
.. code-block:: bash
Sylvain Gugger's avatar
Sylvain Gugger committed
320

Lysandre Debut's avatar
Lysandre Debut committed
321
322
    git add --all
    git status
Sylvain Gugger's avatar
Sylvain Gugger committed
323

324
Finally, the files should be committed:
Sylvain Gugger's avatar
Sylvain Gugger committed
325

Sylvain Gugger's avatar
Sylvain Gugger committed
326
.. code-block:: bash
Sylvain Gugger's avatar
Sylvain Gugger committed
327

Lysandre Debut's avatar
Lysandre Debut committed
328
    git commit -m "First version of the your-model-name model and tokenizer."
Sylvain Gugger's avatar
Sylvain Gugger committed
329

Lysandre Debut's avatar
Lysandre Debut committed
330
And pushed to the remote:
Sylvain Gugger's avatar
Sylvain Gugger committed
331

Sylvain Gugger's avatar
Sylvain Gugger committed
332
.. code-block:: bash
Sylvain Gugger's avatar
Sylvain Gugger committed
333

Lysandre Debut's avatar
Lysandre Debut committed
334
    git push
Sylvain Gugger's avatar
Sylvain Gugger committed
335

Lysandre Debut's avatar
Lysandre Debut committed
336
This will upload the folder containing the weights, tokenizer and configuration we have just prepared.
Sylvain Gugger's avatar
Sylvain Gugger committed
337
338
339
340
341


Add a model card
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

342
343
To make sure everyone knows what your model can do, what its limitations, potential bias or ethical considerations are,
please add a README.md model card to your model repo. You can just create it, or there's also a convenient button
344
345
titled "Add a README.md" on your model page. A model card documentation can be found `here
<https://huggingface.co/docs/hub/model-repos>`__ (meta-suggestions are welcome). model card template (meta-suggestions
346
are welcome).
Sylvain Gugger's avatar
Sylvain Gugger committed
347

348
.. note::
Sylvain Gugger's avatar
Sylvain Gugger committed
349

350
351
    Model cards used to live in the 馃 Transformers repo under `model_cards/`, but for consistency and scalability we
    migrated every model card from the repo to its corresponding huggingface.co model repo.
Sylvain Gugger's avatar
Sylvain Gugger committed
352

353
354
If your model is fine-tuned from another model coming from the model hub (all 馃 Transformers pretrained models do),
don't forget to link to its model card so that people can fully trace how your model was built.
Sylvain Gugger's avatar
Sylvain Gugger committed
355
356
357
358
359
360
361
362
363
364
365


Using your model
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Your model now has a page on huggingface.co/models 馃敟

Anyone can load it from code:

.. code-block::

Lysandre Debut's avatar
Lysandre Debut committed
366
367
    >>> tokenizer = AutoTokenizer.from_pretrained("namespace/awesome-name-you-picked")
    >>> model = AutoModel.from_pretrained("namespace/awesome-name-you-picked")
Sylvain Gugger's avatar
Sylvain Gugger committed
368
369


Lysandre Debut's avatar
Lysandre Debut committed
370
You may specify a revision by using the ``revision`` flag in the ``from_pretrained`` method:
Sylvain Gugger's avatar
Sylvain Gugger committed
371
372
373

.. code-block::

Lysandre Debut's avatar
Lysandre Debut committed
374
375
376
377
    >>> tokenizer = AutoTokenizer.from_pretrained(
    >>>   "julien-c/EsperBERTo-small",
    >>>   revision="v2.0.1" # tag name, or branch name, or commit hash
    >>> )
Sylvain Gugger's avatar
Sylvain Gugger committed
378
379
380
381
382
383
384
385
386
387
388
389
390

Workflow in a Colab notebook
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you're in a Colab notebook (or similar) with no direct access to a terminal, here is the workflow you can use to
upload your model. You can execute each one of them in a cell by adding a ! at the beginning.

First you need to install `git-lfs` in the environment used by the notebook:

.. code-block:: bash

    sudo apt-get install git-lfs

391
392
Then you can use either create a repo directly from `huggingface.co <https://huggingface.co/>`__ , or use the
:obj:`transformers-cli` to create it:
Sylvain Gugger's avatar
Sylvain Gugger committed
393
394
395
396
397
398
399
400
401
402
403


.. code-block:: bash

    transformers-cli login
    transformers-cli repo create your-model-name

Once it's created, you can clone it and configure it (replace username by your username on huggingface.co):

.. code-block:: bash

404
405
    git lfs install

406
407
408
409
410
    git clone https://username:password@huggingface.co/username/your-model-name
    # Alternatively if you have a token,
    # you can use it instead of your password
    git clone https://username:token@huggingface.co/username/your-model-name

Sylvain Gugger's avatar
Sylvain Gugger committed
411
412
    cd your-model-name
    git config --global user.email "email@example.com"
413
414
    # Tip: using the same email than for your huggingface.co account will link your commits to your profile
    git config --global user.name "Your name"
Sylvain Gugger's avatar
Sylvain Gugger committed
415

416
417
Once you've saved your model inside, and your clone is setup with the right remote URL, you can add it and push it with
usual git commands.
Sylvain Gugger's avatar
Sylvain Gugger committed
418
419
420
421
422

.. code-block:: bash

    git add .
    git commit -m "Initial commit"
423
    git push