# Load fine tuned model from local

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fload-fine-tuned-model-from-local%2F1651%3E%5C
**Category:** Beginners\
**Created:** [October 20, 2020, 1:25pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fload-fine-tuned-model-from-local%2F1651 "2020-10-20T13:25:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![datistiquo](https://avatars.discourse-cdn.com/v4/letter/d/f0a364/32.png) [@datistiquo](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fdatistiquo)%5C
**Post date:** [October 20, 2020, 1:25pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fload-fine-tuned-model-from-local%2F1651%2F1 "2020-10-20T13:25:34Z")

</div>

Hey,

if I fine tune a BERT model is the tokneizer somehow affected?

If I save my finetuned model like:

bert\_model.save\_pretrained(’./Fine\_tune\_BERT/’)

is the tokenizer saved too? is the tokenizer modified? Do I need to save it too?

Bercause loading the tokenizer like:

tokenizer = BertTokenizer.from\_pretrained(‘Fine\_tune\_BERT/’)

is giving error.  
\>  
\> OSError: Model name ‘Fine\_tune\_BERT/’ was not found in tokenizers model name list (bert-base-uncased, bert-large-uncased, bert-base-cased, bert-large-cased, bert-base-multilingual-uncased, bert-base-multilingual-cased, bert-base-chinese, bert-base-german-cased, bert-large-uncased-whole-word-masking, bert-large-cased-whole-word-masking, bert-large-uncased-whole-word-masking-finetuned-squad, bert-large-cased-whole-word-masking-finetuned-squad, bert-base-cased-finetuned-mrpc, bert-base-german-dbmdz-cased, bert-base-german-dbmdz-uncased, TurkuNLP/bert-base-finnish-cased-v1, TurkuNLP/bert-base-finnish-uncased-v1, wietsedv/bert-base-dutch-cased). We assumed ‘Fine\_tune\_BERT/’ was a path, a model identifier, or url to a directory containing vocabulary files named [‘vocab.txt’] but couldn’t find such vocabulary files at this path or url.

SO I assume I can load the tokenizer in the normal way?

---

<div class="post-metadata">

**Author:** ![sgugger](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sgugger/32/2291_2.png) [@sgugger](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsgugger)%5C
**Post date:** [October 20, 2020, 1:48pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fload-fine-tuned-model-from-local%2F1651%2F2 "2020-10-20T13:48:50Z")

</div>

The model is independent from your tokenizer, so you need to also do:

```python
tokenizer.save_pretrained(’./Fine_tune_BERT/’)

```

to be able to load it back with `from_pretrained`.

---

<div class="post-metadata">

**Author:** ![datistiquo](https://avatars.discourse-cdn.com/v4/letter/d/f0a364/32.png) [@datistiquo](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fdatistiquo)%5C
**Post date:** [October 20, 2020, 2:11pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fload-fine-tuned-model-from-local%2F1651%2F3 "2020-10-20T14:11:16Z")

</div>

But the important issue is, do I need this? Can I still download it the normal way? Is the tokenizer affected by model fientuning? I assume no, so I could still use the tokenizer from your API?

> <https://stackoverflow.com/questions/64446355/huggingface-save-fine-tuned-model-locally-and-tokenizer-too>

---

<div class="post-metadata">

**Author:** ![datistiquo](https://avatars.discourse-cdn.com/v4/letter/d/f0a364/32.png) [@datistiquo](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fdatistiquo)%5C
**Post date:** [October 20, 2020, 2:13pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fload-fine-tuned-model-from-local%2F1651%2F4 "2020-10-20T14:13:19Z")

</div>

So:

tokenizer = BertTokenizer.from\_pretrained(‘bert-base-cased’)

but

bert\_model = TFBertModel.from\_pretrained(‘Fine\_tune\_BERT/’)

---

<div class="post-metadata">

**Author:** ![sgugger](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sgugger/32/2291_2.png) [@sgugger](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsgugger)%5C
**Post date:** [October 20, 2020, 2:45pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fload-fine-tuned-model-from-local%2F1651%2F5 "2020-10-20T14:45:19Z")

</div>

Yes, if you didn’t do any change to the tokenizer, you can still use the pretrained version.
