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
bf038375
Commit
bf038375
authored
Sep 14, 2023
by
baberabb
Browse files
Refactor whitespace check and add handling for multiple_targets
parent
a07d05f7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
14 deletions
+18
-14
lm_eval/api/task.py
lm_eval/api/task.py
+18
-14
No files found.
lm_eval/api/task.py
View file @
bf038375
...
@@ -674,11 +674,12 @@ class ConfigurableTask(Task):
...
@@ -674,11 +674,12 @@ class ConfigurableTask(Task):
check_choices
=
test_choice
check_choices
=
test_choice
else
:
else
:
check_choices
=
[
test_target
]
check_choices
=
[
test_target
]
# TODO: is this only for multiple-choice?
if
self
.
config
.
doc_to_choice
is
not
None
:
for
choice
in
check_choices
:
for
choice
in
check_choices
:
choice_has_whitespace
=
True
if
choice
.
startswith
(
" "
)
else
False
choice_has_whitespace
=
True
if
choice
[
0
].
isspace
(
)
else
False
delimiter_has_whitespace
=
(
delimiter_has_whitespace
=
(
True
if
self
.
config
.
target_delimiter
.
startswith
(
" "
)
else
False
True
if
self
.
config
.
target_delimiter
[
-
1
].
isspace
(
)
else
False
)
)
if
delimiter_has_whitespace
and
choice_has_whitespace
:
if
delimiter_has_whitespace
and
choice_has_whitespace
:
...
@@ -1067,6 +1068,9 @@ class ConfigurableTask(Task):
...
@@ -1067,6 +1068,9 @@ class ConfigurableTask(Task):
# it assumes that doc_to_target returns a number.
# it assumes that doc_to_target returns a number.
choices
=
self
.
doc_to_choice
(
doc
)
choices
=
self
.
doc_to_choice
(
doc
)
gold
=
choices
[
gold
]
gold
=
choices
[
gold
]
# we expect multiple_targets to be a list.
elif
self
.
multiple_target
:
pass
else
:
else
:
gold
=
str
(
gold
)
gold
=
str
(
gold
)
...
...
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