convert_llama_weights_to_hf.py  json.decoder.JSONDecodeError
Author: munitioner
Pull request: no

### System Info

![微信截图_20230829170647](https://github.com/huggingface/transformers/assets/14157458/1c872330-f756-4788-99ea-68de46199418)


### Who can help?

_No response_

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction
```python
!git clone https://github.com/facebookresearch/llama.git
!cd /content/llama/ && bash download.sh
!wget https://raw.githubusercontent.com/huggingface/transformers/main/src/transformers/models/llama/convert_llama_weights_to_hf.py
!pip install git+https://github.com/huggingface/transformers
!pip install accelerate
!pip install sentencepiece
!python convert_llama_weights_to_hf.py \
    --input_dir /content/llama/llama-2-7b --model_size 7B --output_dir /content/llama/models_hf/7B
```
### Expected behavior

error
```python
2023-08-29 08:19:08.150890: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
Traceback (most recent call last):
  File "/content/convert_llama_weights_to_hf.py", line 318, in <module>
    main()
  File "/content/convert_llama_weights_to_hf.py", line 306, in main
    write_model(
  File "/content/convert_llama_weights_to_hf.py", line 92, in write_model
    params = read_json(os.path.join(input_base_path, "params.json"))
  File "/content/convert_llama_weights_to_hf.py", line 75, in read_json
    return json.load(f)
  File "/usr/lib/python3.10/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
```

Comments:
cc @ArthurZucker 

Hey! @munitioner, I am not able to reproduce this on main. I suspect this can come from either one of:
- The `params.json` is wrongly formatted / was manually modified 
- The path is wrong
I tested with a similar setup as you, and I have no problem converting. Can you share the `params.json` file with me? 

i am facing with issues to convert llama-2-13b into vicuna i got all the time the following  #21366 )  "Fetching all parameters from the checkpoint at /content/drive/MyDrive/anomalyGPT/llama/llama-2-13b/13B".a
^C
fter executing that command !python -m transformers.models.llama.convert_llama_weights_to_hf --input_dir /content/drive/MyDrive/anomalyGPT/llama/llama-2-13b  --model_size 13B --output_dir /content/drive/MyDrive/anomalyGPT/llama/huggingface_llama_13B

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.

I am also getting JSONDecodeError.
I have downloaded the CodeLlama-13b.
```
Traceback (most recent call last):
  File "convert_llama_weights_to_hf.py", line 322, in <module>
    main()
  File "convert_llama_weights_to_hf.py", line 310, in main
    write_model(
  File "convert_llama_weights_to_hf.py", line 94, in write_model
    params = read_json(os.path.join(input_base_path, "params.json"))
  File "convert_llama_weights_to_hf.py", line 75, in read_json
    return json.load(f)
  File "/home/.../anaconda3/envs/env_pytorch/lib/python3.8/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/home/.../anaconda3/envs/env_pytorch/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/home/.../anaconda3/envs/env_pytorch/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/home/...
[params.json](https://github.com/huggingface/transformers/files/13215859/params.json)
/anaconda3/envs/env_pytorch/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
```
json.loads(f) is generating error, since the params.json file contains html code. Attaching params.json for reference.
[params.json](https://github.com/huggingface/transformers/files/13215873/params.json)

Can anybody help?

Hey, if you are looking for already converted checkpoints, you should have a look at https://huggingface.co/codellama . I converted the checkpoints (9 different checkpoints 😓 ) with the exact same script and did not have any issue. Where is the param.json file from? 

@ArthurZucker Where is the params.json, i did not find that in the huggingface repo of llama

Strange, here are the links:
- https://huggingface.co/meta-llama/Llama-2-70b/blob/main/params.json
- https://huggingface.co/meta-llama/Llama-2-70b-chat/blob/main/params.json
- https://huggingface.co/meta-llama/Llama-2-13b/blob/main/params.json
- https://huggingface.co/meta-llama/Llama-2-13b-chat/blob/main/params.json
- https://huggingface.co/meta-llama/Llama-2-7b/blob/main/params.json

make sure you are using the checkpoints that do not end with `-hf` , which are already converted and thus do not have the `param.json`. 

TY @ArthurZucker

and where is the tokenizer.json?  @ArthurZucker

The tokenizer.json is not related to the original model so it will be in the `-hf` version. What you have in the original release is the `tokenizer.model` 

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.