Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

humaneval instruct #2650

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lm_eval/tasks/humaneval/humaneval_64_instruct.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include: humaneval_64.yaml
task: humaneval_64_instruct
doc_to_text: "Write a solution to the following problem and make sure that it passes the tests:\n```{{prompt}}"
gen_prefix: "Here is the completed function:\\n```python\\n{{prompt}}\\n"
filter_list:
- name: "create_test"
filter:
- function: "custom"
filter_fn: !function utils.build_predictions_instruct
9 changes: 9 additions & 0 deletions lm_eval/tasks/humaneval/humaneval_instruct.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include: humaneval.yaml
task: humaneval_instruct
doc_to_text: "Write a solution to the following problem and make sure that it passes the tests:\n```{{prompt}}"
gen_prefix: "Here is the completed function:\\n```python\\n{{prompt}}\\n"
filter_list:
- name: "create_test"
filter:
- function: "custom"
filter_fn: !function utils.build_predictions_instruct
12 changes: 12 additions & 0 deletions lm_eval/tasks/humaneval/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,15 @@ def pass_at_k(references: list[str], predictions: list[list[str]], k: list[int]

def build_predictions(resps: list[list[str]], docs: list[dict]) -> list[list[str]]:
return [[doc["prompt"] + r for r in resp] for resp, doc in zip(resps, docs)]


def build_predictions_instruct(
resps: list[list[str]], docs: list[dict]
) -> list[list[str]]:
return [
[
doc["prompt"] + (r if r.rfind("```") == -1 else r[: r.rfind("```")])
for r in resp
]
for resp, doc in zip(resps, docs)
]
Loading