FileNotFoundError: [Errno 2] No such file or directory: '/home/chaizhihua/.cache/huggingface/hub/models--.--resources--ltp/refs/main'
Author: limuyun99
Pull request: no
Labels: name: bug

### System Info

when i run (https://github.com/huggingface/transformers/blob/main/examples/research_projects/mlm_wwm/run_chinese_ref.py) this code , the code throw this error:

```
Traceback (most recent call last):
  File "temp.py", line 147, in <module>
    main(args)
  File "temp.py", line 122, in main
    ltp_tokenizer = LTP(args.ltp)  # faster in GPU device
  File "/home/chaizhihua/anaconda3/envs/graph/lib/python3.8/site-packages/ltp/interface.py", line 102, in LTP
    config_file = hf_hub_download(
  File "/home/chaizhihua/anaconda3/envs/graph/lib/python3.8/site-packages/huggingface_hub/file_download.py", line 1078, in hf_hub_download
    with open(ref_path) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/chaizhihua/.cache/huggingface/hub/models--.--resources--ltp/refs/main'
```

my transformers ==4.19.0

### Who can help?

@[julien-c](https://github.com/huggingface/transformers/commits?author=julien-c)


### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

- [X] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

### Expected behavior

modify this error

Comments:
Hi limuyun99, would you mind providing your script for running `run_chinese_ref.py`? According to your traceback, I think you may provide the wrong params for the `--ltp`. Your cmd for running `run_chinese_ref.py` should look like the below:
```
export TRAIN_FILE=/path/to/train/file
export LTP_RESOURCE=LTP/small
export BERT_RESOURCE=bert-base-uncased
export SAVE_PATH=/path/to/data/ref.txt

python run_chinese_ref.py \
    --file_name=$TRAIN_FILE \
    --ltp=$LTP_RESOURCE \
    --bert=$BERT_RESOURCE \
    --save_path=$SAVE_PATH
```

have you seen other paths like those @LysandreJik @Wauplin? 

`/home/chaizhihua/.cache/huggingface/hub/models--.--resources--ltp/refs/main` looks incorrect, like it's encoding a local path instead of a repo id or something. (Not sure where the issue is though, if any)

A few things here:

1. [`--ltp` arg](https://github.com/huggingface/transformers/blob/main/examples/research_projects/mlm_wwm/run_chinese_ref.py#L141) is set by default to `"./resources/ltp"`
2. This value is then passed when initializing LTP, as `pretrained_model_name_or_path` (see [LTP source code](https://github.com/HIT-SCIR/ltp/blob/5c07bf909710c75c246da8abe3f5c44b89c0eea0/python/interface/ltp/interface.py#L14)). Script either expect a model name (e.g. `LTP/tiny` - see [list](https://huggingface.co/LTP)) or a path to an existing folder.
  a. Here it seems you are using the default value `"./resources/ltp"` which refers to an empty/missing folder. Source code from `LTP` falls back to considering it as a model_id and download it from HF Hub.
  b. To download it from the hub, it uses [`huggingface_hub`](https://github.com/huggingface/huggingface_hub) which doesn't throw an error because the model id is wrong but because it cannot access the cache at the given path.
  
From that:
1.  As mentioned by @aRyBernAlTEglOTRO in [its comment](https://github.com/huggingface/transformers/issues/18691#issuecomment-1221293043), you need to provide a valid `--ltp` value.
2. In `huggingface_hub` it would still be good to throw an error that `"./resources/ltp" is not a valid repo_id` instead of the current `FileNotFoundError: [Errno 2] No such file or directory: '/home/chaizhihua/.cache/huggingface/hub/models--.--resources--ltp/refs/main'`. I'll create an issue to track that.

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.