Skip to content

Commit

Permalink
Merge pull request #62 from HiroakiMikami/fix-eval
Browse files Browse the repository at this point in the history
Fix HumanEval evaluation script.
  • Loading branch information
Nathan Cooper authored Oct 9, 2021
2 parents 56a49a8 + 883adc2 commit 1711eb3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions evaluation/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def clean_text(generation):
return generation


def generate_text(prompt, n, tokenizer, model):
def generate_text(prompt, n, tokenizer, model, include_prompt=True):
inputs = tokenizer(prompt, truncation=True, max_length=MAX_TOKS, return_tensors="pt").to("cuda")
output_seq = model.generate(
input_ids=inputs.input_ids, max_length=MAX_TOKS,
Expand All @@ -52,7 +52,7 @@ def generate_text(prompt, n, tokenizer, model):
generated_text = []
for o in outputs:
cleaned = clean_text(o.replace(prompt, ""))
generated_text.append(prompt + cleaned)
generated_text.append(prompt + cleaned if include_prompt else cleaned)

return generated_text

Expand Down Expand Up @@ -92,7 +92,8 @@ def _eval_human_eval(path, out_path, tokenizer, model):
problems[task_id]["prompt"],
num_samples_per_task,
tokenizer,
model
model,
include_prompt=False,
):
samples.append(dict(task_id=task_id, completion=text))

Expand Down

0 comments on commit 1711eb3

Please sign in to comment.