# Push model to hugging face hub without Trainer

**URL:** <https://discuss.huggingface.co/t/push-model-to-hugging-face-hub-without-trainer/41067>\
**Category:** Intermediate\
**Created:** [May 26, 2023, 10:54am UTC](https://discuss.huggingface.co/t/push-model-to-hugging-face-hub-without-trainer/41067 "2023-05-26T10:54:18Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zahra99](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/zahra99/32/31827_2.png) [@Zahra99](https://discuss.huggingface.co/u/Zahra99)\
**Post date:** [May 26, 2023, 10:54am UTC](https://discuss.huggingface.co/t/push-model-to-hugging-face-hub-without-trainer/41067/1 "2023-05-26T10:54:18Z")

</div>

Hi, I want to train a model for text classification using `bert-base-uncased` with pure Pytorch (without Trainer). I wanted to push the fine tuned model to hugging face hub and I used this code:

```auto
model.push_to_hub("repository_name")

```

But when I’m trying to see the prediction of the model in the model repository on the example sentence I got this error:  
`Can't load tokenizer using from_pretrained, please update its configuration: Can't load tokenizer for 'Zahra99/pure-python2'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'Zahra99/pure-python2' is the correct path to a directory containing all relevant files for a BertTokenizerFast tokenizer.`  
This is shown in the following image:

 ![Screenshot 2023-05-26 at 14.17.05](https://us1.discourse-cdn.com/hellohellohello/original/3X/2/4/243e281f3bcc54b1ea0e166826cd9e1c70fb6532.png)

I searched about it but actually I couldn’t find solution for my problem which how I can push the model which is trained using pure Pytorch in hugging face hub and load it later.

I apperciate any help 🙏

---

<div class="post-metadata">

**Author:** ![Guldeniz](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/guldeniz/32/16355_2.png) [@Guldeniz](https://discuss.huggingface.co/u/Guldeniz)\
**Post date:** [May 26, 2023, 12:12pm UTC](https://discuss.huggingface.co/t/push-model-to-hugging-face-hub-without-trainer/41067/2 "2023-05-26T12:12:10Z")

</div>

What is in `'Zahra99/pure-python2'`?

---

<div class="post-metadata">

**Author:** ![mariosasko](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/mariosasko/32/31548_2.png) [@mariosasko](https://discuss.huggingface.co/u/mariosasko)\
**Post date:** [May 26, 2023, 12:49pm UTC](https://discuss.huggingface.co/t/push-model-to-hugging-face-hub-without-trainer/41067/3 "2023-05-26T12:49:53Z")

</div>

This error comes from [here](https://github.com/huggingface/api-inference/blob/b3f5797e79143db57e5b4ba8c858108d6608da20/shard/app/model.py#L652). Maybe [this](https://github.com/huggingface/transformers/issues/14334) issue can help.

---

<div class="post-metadata">

**Author:** ![Zahra99](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/zahra99/32/31827_2.png) [@Zahra99](https://discuss.huggingface.co/u/Zahra99)\
**Post date:** [May 26, 2023, 1:48pm UTC](https://discuss.huggingface.co/t/push-model-to-hugging-face-hub-without-trainer/41067/4 "2023-05-26T13:48:30Z")

</div>

My repository includes these files:

 ![my_repo](https://us1.discourse-cdn.com/hellohellohello/original/3X/9/9/991d23cfde016e42348082a0e44dc42da5187779.jpeg)

---

<div class="post-metadata">

**Author:** ![Zahra99](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/zahra99/32/31827_2.png) [@Zahra99](https://discuss.huggingface.co/u/Zahra99)\
**Post date:** [May 26, 2023, 1:55pm UTC](https://discuss.huggingface.co/t/push-model-to-hugging-face-hub-without-trainer/41067/5 "2023-05-26T13:55:04Z")

</div>

I can’t open [this](https://github.com/huggingface/api-inference/blob/b3f5797e79143db57e5b4ba8c858108d6608da20/shard/app/model.py#L652) link.

But I try the comments in the other link you sent and uploaded manually `tokenizer.json` and `tokenizer_config.json` from `bert-base-uncased` repository into my repository and now inference API in my repository is working. Thank you so much

But I have a question, is this work really true? and is there any way to upload `tokenizer` files automatically?

---

<div class="post-metadata">

**Author:** ![mariosasko](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/mariosasko/32/31548_2.png) [@mariosasko](https://discuss.huggingface.co/u/mariosasko)\
**Post date:** [May 26, 2023, 2:08pm UTC](https://discuss.huggingface.co/t/push-model-to-hugging-face-hub-without-trainer/41067/6 "2023-05-26T14:08:52Z")

</div>

> [@Zahra99](#):
>
> But I have a question, is this work really true? and is there any way to upload `tokenizer` files automatically?

I think only the `Trainer` uploads them automatically.

> I can’t open [this](https://github.com/huggingface/api-inference/blob/b3f5797e79143db57e5b4ba8c858108d6608da20/shard/app/model.py#L652) link.

Oops, this link points to a private repo :), and it’s not that useful, to be honest.

---

<div class="post-metadata">

**Author:** ![Zahra99](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/zahra99/32/31827_2.png) [@Zahra99](https://discuss.huggingface.co/u/Zahra99)\
**Post date:** [May 27, 2023, 6:41am UTC](https://discuss.huggingface.co/t/push-model-to-hugging-face-hub-without-trainer/41067/7 "2023-05-27T06:41:16Z")

</div>

Thank you so much 😊  
This piece of code solve the problem

```auto
tokenizer.push_to_hub() # instead of adding tokenizer files manually to repository
model.push_to_hub()

```

---

<div class="post-metadata">

**Author:** ![sarraj19](https://avatars.discourse-cdn.com/v4/letter/s/e47c2d/32.png) [@sarraj19](https://discuss.huggingface.co/u/sarraj19)\
**Post date:** [May 14, 2024, 12:43am UTC](https://discuss.huggingface.co/t/push-model-to-hugging-face-hub-without-trainer/41067/8 "2024-05-14T00:43:58Z")

</div>

Hi Eventhough I use the above, the error still persist for me, any suggesstions?
