Is anyone else getting a JSON loading error?

#4
by olasbondolas - opened

I'm running the provided "How to reproduce HumanEval Results" code:

from transformers import AutoTokenizer, LlamaForCausalLM
from human_eval.data import write_jsonl, read_problems
from tqdm import tqdm

# initialize the model

model_path = "Phind/Phind-CodeLlama-34B-v1"
model = LlamaForCausalLM.from_pretrained(model_path, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained(model_path)

# HumanEval helper

def generate_one_completion(prompt: str):
    tokenizer.pad_token = tokenizer.eos_token
    inputs = tokenizer(prompt, return_tensors="pt", truncation=True, max_length=4096)

    # Generate
    generate_ids = model.generate(inputs.input_ids.to("cuda"), max_new_tokens=256, do_sample=True, top_p=0.75, top_k=40, temperature=0.1)
    completion = tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
    completion = completion.replace(prompt, "").split("\n\n\n")[0]

    return completion

# perform HumanEval
problems = read_problems()

num_samples_per_task = 1
samples = [
    dict(task_id=task_id, completion=generate_one_completion(problems[task_id]["prompt"]))
    for task_id in tqdm(problems)
    for _ in range(num_samples_per_task)
]
write_jsonl("samples.jsonl", samples)

# run `evaluate_functional_correctness samples.jsonl` in your HumanEval code sandbox

but keep getting the error:

PS C:\Users\nicho\Desktop\AI> & C:/Users/nicho/AppData/Local/Programs/Python/Python311/python.exe c:/Users/nicho/Desktop/AI/HumanEval.py
Traceback (most recent call last):
  File "c:\Users\nicho\Desktop\AI\HumanEval.py", line 9, in <module>
    model = LlamaForCausalLM.from_pretrained(model_path, device_map="auto")
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\nicho\AppData\Local\Programs\Python\Python311\Lib\site-packages\transformers\modeling_utils.py", line 2862, in from_pretrained
    resolved_archive_file, sharded_metadata = get_checkpoint_shard_files(
                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\nicho\AppData\Local\Programs\Python\Python311\Lib\site-packages\transformers\utils\hub.py", line 1017, in get_checkpoint_shard_files
    index = json.loads(f.read())
            ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\nicho\AppData\Local\Programs\Python\Python311\Lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\nicho\AppData\Local\Programs\Python\Python311\Lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\nicho\AppData\Local\Programs\Python\Python311\Lib\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)

Has anyone run into the same issue and had success fixing it?

I've encountered this problem, too. Have you solved it now?

Yeah, the model_path has to be model_path = "Phind/Phind-CodeLlama-34B-v1" and not the copy relative path from VS Code or anything other than that

olasbondolas changed discussion status to closed

Sign up or log in to comment