Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
lm-evaluation-harness
Commits
7feab5e3
"vscode:/vscode.git/clone" did not exist on "ab9cb56150b1e14f041ac9197fd8d4c305ad9cf9"
Commit
7feab5e3
authored
Jul 03, 2023
by
Benjamin Fattori
Browse files
add race task, with custom HF dataset
parent
4b8e7ca7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
0 deletions
+47
-0
lm_eval/tasks/race/preprocess_race.py
lm_eval/tasks/race/preprocess_race.py
+31
-0
lm_eval/tasks/race/race.yaml
lm_eval/tasks/race/race.yaml
+16
-0
No files found.
lm_eval/tasks/race/preprocess_race.py
0 → 100644
View file @
7feab5e3
def
last_problem
(
doc
):
return
doc
[
"problems"
][
-
1
]
def
get_answer_option
(
problem
):
letter_to_num
=
{
"A"
:
0
,
"B"
:
1
,
"C"
:
2
,
"D"
:
3
}
answer
=
letter_to_num
[
problem
[
"answer"
]]
return
problem
[
"options"
][
answer
]
def
create_choices
(
doc
):
problem
=
last_problem
(
doc
)
choices
=
[
problem
[
"options"
][
i
]
for
i
in
range
(
4
)]
return
choices
def
doc_to_text
(
doc
):
text
=
"Article: "
+
doc
[
"article"
]
+
"
\n\n
"
for
problem
in
doc
[
"problems"
][:
-
1
]:
if
problem
[
"question"
][
-
6
:]
==
" _ ."
:
text
+=
(
problem
[
"question"
][
-
5
:]
+
get_answer_option
(
problem
)
+
"
\n
"
)
else
:
question
=
"Question: "
+
problem
[
"question"
]
+
"
\n
"
answer
=
"Answer: "
+
get_answer_option
(
problem
)
+
"
\n
"
text
+=
question
+
answer
text
+=
last_problem
(
doc
)[
"question"
]
return
text
def
doc_to_target
(
doc
):
letter_to_num
=
{
"A"
:
0
,
"B"
:
1
,
"C"
:
2
,
"D"
:
3
}
answer
=
letter_to_num
[
last_problem
(
doc
)[
"answer"
]]
return
answer
lm_eval/tasks/race/race.yaml
View file @
7feab5e3
group
:
-
multiple_choice
task
:
race
dataset_path
:
bfattori/race_grouped
dataset_name
:
high
output_type
:
multiple_choice
training_split
:
train
validation_split
:
validation
test_split
:
test
create_choices
:
!function
preprocess_race.create_choices
doc_to_text
:
!function
preprocess_race.doc_to_text
doc_to_target
:
!function
preprocess_race.doc_to_target
metric_list
:
-
metric
:
acc
aggregation
:
mean
higher_is_better
:
true
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment