KeyError when initialize the tokenizer with Atutokenizer for ernie-1.0-base-zh`
Author: Maydaytyh
Pull request: no
Labels: name: bug

### System Info

- `transformers` version: 4.6.0
- Platform: Linux-3.10.0-1160.49.1.el7.x86_64-x86_64-with-debian-buster-sid
- Python version: 3.6.10
- PyTorch version (GPU?): 1.7.0a0+7036e91 (True)
- Tensorflow version (GPU?): not installed (NA)
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>

### Who can help?

_No response_

### Information

- [X] The official example scripts
- [X] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction

Just use
``` python
tokenizer = AutoTokenizer.from_pretrained("nghuyong/ernie-1.0-base-zh")
```
then I encountered the problem
``` bash
Traceback (most recent call last):
  File "prepro_std_fin.py", line 297, in <module>
    main(args)
  File "prepro_std_fin.py", line 266, in main
    tokenizer = AutoTokenizer.from_pretrained("nghuyong/ernie-1.0-base-zh")
  File "/opt/conda/lib/python3.6/site-packages/transformers/models/auto/tokenization_auto.py", line 402, in from_pretrained
    config = AutoConfig.from_pretrained(pretrained_model_name_or_path, **kwargs)
  File "/opt/conda/lib/python3.6/site-packages/transformers/models/auto/configuration_auto.py", line 432, in from_pretrained
    config_class = CONFIG_MAPPING[config_dict["model_type"]]
KeyError: 'ernie'
```


### Expected behavior

I hope you can help me solve this problem. Thanks!

Comments:
Running into the same issue with "nghuyong/ernie-2.0-base-en".  It was working on Friday so I'm assuming a change to either Transformers or the model's owners repo is causing this. 

Looks like Sat the owner updated the config file for the hosted model which may causing the issue.  I don't believe there is an "ErnieModel"  in the config map that .from_pretrained uses. 
https://huggingface.co/nghuyong/ernie-2.0-base-en/commit/2c22755178879588695a30d68a4d9e861237db7b 

Is there a way to load by the sha id instead of the slug if we want to load an older cached model?



> Running into the same issue with "nghuyong/ernie-2.0-base-en". It was working on Friday so I'm assuming a change to either Transformers or the model's owners repo is causing this.
> 
> Looks like Sat the owner updated the config file for the hosted model which may causing the issue. I don't believe there is an "ErnieModel" in the config map that .from_pretrained uses. https://huggingface.co/nghuyong/ernie-2.0-base-en/commit/2c22755178879588695a30d68a4d9e861237db7b
> 
> Is there a way to load by the sha id instead of the slug if we want to load an older cached model?

I change the  AutoTokenizer to BertTokenizer and it works. But I still don't know the reason.

The ernie model is based on BERT so the tokenizer should work. But I can't load the model weights for "nghuyong/ernie-2.0-base-en"

I am facing the same issue

It might worth posting here as well: https://huggingface.co/nghuyong/ernie-2.0-base-en/discussions/1 

This seems to be an issue with the model config itself and not transformers library. 

The ERNIE model was recently merged on the `main` branch so you'll need to install the library from source in order to use it.

We'll be releasing v4.22.0 later today or tomorrow, so upgrading version then will fix this.

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.

The same issue occurred to me. I solved it with change torch version to 1.12.1 and transformers version to 4.26.1