model_sharing.md 1.8 KB
Newer Older
1
2
3
4
# Model upload and sharing

Starting with `v2.2.2`, you can now upload and share your fine-tuned models with the community, using the <abbr title="Command-line interface">CLI</abbr> that's built-in to the library.

5
**First, create an account on [https://huggingface.co/join](https://huggingface.co/join)**. Optionally, join an existing organization or create a new one. Then:
6
7
8
9
10
11
12
13
14
15
16
17

```shell
transformers-cli login
# log in using the same credentials as on huggingface.co
```
Upload your model:
```shell
transformers-cli upload ./path/to/pretrained_model/

# ^^ Upload folder containing weights/tokenizer/config
# saved via `.save_pretrained()`

Julien Chaumond's avatar
Julien Chaumond committed
18
transformers-cli upload ./config.json [--filename folder/foobar.json]
19
20

# ^^ Upload a single file
Julien Chaumond's avatar
Julien Chaumond committed
21
# (you can optionally override its filename, which can be nested inside a folder)
22
23
```

24
25
26
27
28
29
If you want your model to be namespaced by your organization name rather than your username, add the following flag to any command:
```shell
--organization organization_name
```

Your model will then be accessible through its identifier, a concatenation of your username (or organization name) and the folder name above:
30
```python
Julien Chaumond's avatar
Julien Chaumond committed
31
32
33
"username/pretrained_model"
# or if an org:
"organization_name/pretrained_model"
34
35
```

36
**Please add a README.md model card** to the repo under `model_cards/` with: model description, training params (dataset, preprocessing, hardware used, hyperparameters), evaluation results, intended uses & limitations, etc.
37
38
39

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

40
41
Anyone can load it from code:
```python
42
43
tokenizer = AutoTokenizer.from_pretrained("namespace/pretrained_model")
model = AutoModel.from_pretrained("namespace/pretrained_model")
44
45
```

46
List all your files on S3:
47
```shell
Julien Chaumond's avatar
Julien Chaumond committed
48
transformers-cli s3 ls
49
50
```

51
You can also delete unneeded files:
Julien Chaumond's avatar
Julien Chaumond committed
52
53
54

```shell
transformers-cli s3 rm
55
```