Pretrained Model not available
Author: punit121
Pull request: no
Labels: name: wontfix

## ❓ Questions & Help

01/05/2020 12:18:00 - INFO - root -   finetuned model not available - loading standard pretrained model
01/05/2020 12:18:00 - INFO - transformers.tokenization_utils -   Model name '/opt/ml/code/pretrained_models/bert-base-uncased' not found in model shortcut 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, bert-base-finnish-cased-v1, bert-base-finnish-uncased-v1). Assuming '/opt/ml/code/pretrained_models/bert-base-uncased' is a path or url to a directory containing tokenizer files.
01/05/2020 12:18:00 - INFO - transformers.tokenization_utils -   Didn't find file /opt/ml/code/pretrained_models/bert-base-uncased/added_tokens.json. We won't load it.
01/05/2020 12:18:00 - INFO - transformers.tokenization_utils -   Didn't find file /opt/ml/code/pretrained_models/bert-base-uncased/special_tokens_map.json. We won't load it.
01/05/2020 12:18:00 - INFO - transformers.tokenization_utils -   Didn't find file /opt/ml/code/pretrained_models/bert-base-uncased/tokenizer_config.json. We won't load it.
01/05/2020 12:18:00 - INFO - transformers.tokenization_utils -   loading file /opt/ml/code/pretrained_models/bert-base-uncased/vocab.txt
01/05/2020 12:18:00 - INFO - transformers.tokenization_utils -   loading file None
01/05/2020 12:18:00 - INFO - transformers.tokenization_utils -   loading file None
01/05/2020 12:18:00 - INFO - transformers.tokenization_utils -   loading file None

Comments:
Could you describe your issue in more details? e.g. share some code on what you are trying to do and what is not working?

I have the same issue.
![捕获](https://user-images.githubusercontent.com/16913904/72400862-7026f200-3785-11ea-9aac-e1331a5ad37d.JPG)




I download a pretrained  model and unzip it to my path. When I load it through BertTokenizer,  it cannot be found.   Could you please tell me what/how to check?  @NaxAlpha 

the Error is 
ValueError : " Can't find a vocabulary file at path  **\.cache\**". 
 it seems the program try to load file through cache instead of assigned path.  

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.


i got the same error from AWS container training... as @punit121 . does it mean it didn't successfully  download the pretrained_model?

@tbs17 Nopes, probably this is path error 
can you share screenshot of your code ? 



Got the same error running in a Docker container, while the same code works completely fine locally. 


```
server_1  | INFO:pytorch_transformers.tokenization_utils:Didn't find file model/added_tokens.json. We won't load it.
server_1  | INFO:pytorch_transformers.tokenization_utils:Didn't find file model/special_tokens_map.json. We won't load it.
```
The pretrained model is saved in the path `/model`. This path setup is the same as how I do it locally/separately. But I can't seem to figure out the issue as to why when I integrate this code into a Docker container, it hits these errors. Furthermore, I have confirmed that I am in the right path and am able to access the `model` subdirectory and that the file `model/bert_config.json` is able to be accessed.

Any ideas for how to resolve this issue? 

@catyeo18, these are not errors, it just indicates that your tokenizer has no additional added tokens or special tokens.

If you're using `model.from_pretrained`, please note that the configuration must absolutely be named `config.json`, and not `bert_config.json`.

@LysandreJik thank you for your response -- I don't understand why that is the case when my tokenizer works fine when I run my scripts locally, but yield those error messages when I run my scripts in a Docker container. There is no difference in my code or file setup.

@catyeo18 I spent some time digging into the code and I think the reason is that in `transformers/file_utils.py`, if the file is not there but you have internet connection to check, the code just let that fail silently, basically it means that the script check in `.cache` as well as try to download but not found so just ignore it. However, when setup in an environment without internet connnection (docker for example), the script cannot find the file in `cache` but also cannot check if the file is available online since there's no internet, thus it throws the error.