"...tests/git@developer.sourcefind.cn:change/sglang.git" did not exist on "c7962868c1a7b21f20f00507af43710c268ebfd2"
model_sharing.md 1.17 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 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.

**First, create an account on [https://huggingface.co/join](https://huggingface.co/join)**. Then:

```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
```

Julien Chaumond's avatar
Julien Chaumond committed
24
Your model will then be accessible through its identifier, a concatenation of your username and the folder name above:
25
```python
Julien Chaumond's avatar
Julien Chaumond committed
26
"username/pretrained_model"
27
28
29
30
```

Anyone can load it from code:
```python
Julien Chaumond's avatar
Julien Chaumond committed
31
32
tokenizer = AutoTokenizer.from_pretrained("username/pretrained_model")
model = AutoModel.from_pretrained("username/pretrained_model")
33
34
35
36
```

Finally, list all your files on S3:
```shell
Julien Chaumond's avatar
Julien Chaumond committed
37
transformers-cli s3 ls
38
39
40
# List all your S3 objects.
```