Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
jjallaire committed Sep 6, 2024
1 parent a02d2f6 commit 139705b
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions benchmarks/squad/squad.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
If the question is unanswerable, answer with 'unanswerable' in all lowercase.
"""


@task
def squad():
dataset = hf_dataset(
Expand All @@ -19,24 +20,22 @@ def squad():

return Task(
dataset=dataset,
plan=[
system_message(SYSTEM_MESSAGE),
generate()
],
scorer=[
f1(),
exact()
]
plan=[system_message(SYSTEM_MESSAGE), generate()],
scorer=[f1(), exact()],
)


def record_to_sample(record):
return Sample(
input=format_input(record),
target=record["answers"]["text"] if record["answers"]["text"] else "unanswerable",
id=record["id"],
)
return Sample(
input=format_input(record),
target=record["answers"]["text"]
if record["answers"]["text"]
else "unanswerable",
id=record["id"],
)


def format_input(record) -> str:
passage_str = f"""Context: {record["context"]}"""
question_str = f"""Question: {record["question"]}"""
return "\n".join([passage_str, question_str])
passage_str = f"""Context: {record["context"]}"""
question_str = f"""Question: {record["question"]}"""
return "\n".join([passage_str, question_str])

0 comments on commit 139705b

Please sign in to comment.