Loading a model from local files achieves way too lower accuracy in comparison to model downloading
Author: sstojanoska
Pull request: no

## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->

- `transformers` version: 4.3.2
- Platform: Linux-4.19.112+-x86_64-with-Ubuntu-18.04-bionic
- Python version: 3.6.9
- PyTorch version (GPU?): 1.7.0+cu101 (True)
- Tensorflow version (GPU?): 2.4.1 (True)
- Using GPU in script?: yes
- Using distributed or parallel set-up in script?: no

### Who can help

@LysandreJik, @sgugger, @patrickvonplaten

<!-- Your issue will be replied to more quickly if you can figure out the right person to tag with @
 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.



Models:

- albert, bert, xlm: @LysandreJik
- blenderbot, bart, marian, pegasus, encoderdecoder,  t5: @patrickvonplaten, @patil-suraj
- longformer, reformer, transfoxl, xlnet: @patrickvonplaten
- fsmt: @stas00
- funnel: @sgugger
- gpt2: @patrickvonplaten, @LysandreJik
- rag: @patrickvonplaten, @lhoestq
- tensorflow: @jplu

Library:

- benchmarks: @patrickvonplaten
- deepspeed: @stas00
- ray/raytune: @richardliaw, @amogkam
- text generation: @patrickvonplaten
- tokenizers: @n1t0, @LysandreJik
- trainer: @sgugger
- pipelines: @LysandreJik

Documentation: @sgugger

HF projects:

- nlp datasets: [different repo](https://github.com/huggingface/nlp)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Examples:

- maintained examples (not research project or legacy): @sgugger, @patil-suraj
- research_projects/bert-loses-patience: @JetRunner
- research_projects/distillation: @VictorSanh

 -->

## Information

I am using a few models from the 'Models hub' ( https://huggingface.co/models ) and
I am working on token classification task. Since I have to repeat some of the experiments several times I have downloaded  the models locally, to avoid downloading on each run.

Downloading:
```
model_name = "X"
model = AutoModelForTokenClassification.from_pretrained(model_name, num_labels=len(tag2idx))
tokenizer = AutoTokenizer.from_pretrained(model_name)
```
Saving locally the model and tokenizer ( and renaming tokenizer_config.json to config.json)
```
model.save_pretrained("/content/drive/MyDrive/model/model_name/")
tokenizer.save_pretrained("/content/drive/MyDrive/tokenizer/model_name/")
```
Loading the model and tokenizer from local directories
```
config = AutoConfig.from_pretrained("/content/drive/MyDrive/model/model_name/")
config.num_labels = len(tag2idx)
model = AutoModelForTokenClassification.from_config(config)
tokenizer = AutoTokenizer.from_pretrained("/content/drive/MyDrive/tokenizer/model_name/")
```

The problem arises when using the model from local files. I have noticed that the accuracy of the local model for the exact same configuration (same data, number of epochs, lr,  etc.) is around 20% lower than downloading the model for each experiment.
I would like to know why this happens.

## Expected behavior
The model should achieve similar results whether being loaded from local files or downloaded from the models hub.



Comments:
> The problem arises when using the model from local files. I have noticed that the accuracy of the local model for the exact same configuration (same data, number of epochs, lr, etc.) is around 20% lower than downloading the model for each experiment.

This is extremely vague and we can't help you solve your bug if you don't give us something more tangible than this. What code are you then running? What's the difference in accuracy?


Thanks. It was my mistake. 
The issue was that I was trying to dynamically change the model config file and reuse it for models with different number of output labels.