To use the evaluation harness, you must first generate model completions and save them in a JSON Lines (.jsonl) format. Each line in the file must be a single JSON object with the following keys:
task_id: The corresponding HumanEval task ID.completion: The model-generated code completion (without the prompt).
Example format:
{"task_id": "Corresponding HumanEval task ID", "completion": "Completion only without the prompt"}
Security Warning: This program executes untrusted model-generated code. It is strongly recommended to run this within a robust security sandbox. You must manually enable execution in human_eval/execution.py as the execution call is commented out by default for safety.
from human_eval.data import write_jsonl, read_problems
problems = read_problems()
num_samples_per_task = 200
samples = [
dict(task_id=task_id, completion=generate_one_completion(problems[task_id]["prompt"]))
for task_id in problems
for _ in range(num_samples_per_task)
]
write_jsonl("samples.jsonl", samples)