From c160d96860bdd03566be4772d93e87c0bb1ae245 Mon Sep 17 00:00:00 2001 From: Dejian Yang Date: Tue, 9 Jan 2024 21:55:21 +0800 Subject: [PATCH] fix add_generation_prompt in latest version --- Evaluation/HumanEval/eval_instruct.py | 2 +- Evaluation/MBPP/eval_instruct.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Evaluation/HumanEval/eval_instruct.py b/Evaluation/HumanEval/eval_instruct.py index 34bea56..a85aa8c 100644 --- a/Evaluation/HumanEval/eval_instruct.py +++ b/Evaluation/HumanEval/eval_instruct.py @@ -39,7 +39,7 @@ def generate_one(example, lang, tokenizer, model): eos_token_id=stop_id ) - output = tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True) + output = tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True, add_generation_prompt=True) example['output'] = output return extract_generation_code(example, lang_code=lang) diff --git a/Evaluation/MBPP/eval_instruct.py b/Evaluation/MBPP/eval_instruct.py index 78ecd88..ac76224 100644 --- a/Evaluation/MBPP/eval_instruct.py +++ b/Evaluation/MBPP/eval_instruct.py @@ -66,7 +66,7 @@ def generate_one(example, tokenizer, model): prompt = example['prompt'] inputs = tokenizer.apply_chat_template( [{'role': 'user', 'content': prompt }], - return_tensors="pt" + return_tensors="pt", add_generation_prompt=True ).to(model.device) stop_id = tokenizer.convert_tokens_to_ids("<|EOT|>")