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
d70f7134
Commit
d70f7134
authored
Jul 14, 2023
by
haileyschoelkopf
Browse files
make sure boolq works
parent
ee633332
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
6 deletions
+29
-6
lm_eval/api/task.py
lm_eval/api/task.py
+29
-6
No files found.
lm_eval/api/task.py
View file @
d70f7134
...
...
@@ -979,13 +979,36 @@ class ConfigurableTask(Task):
gold
=
self
.
doc_to_target
(
doc
)
for
key
,
result
in
zip
(
self
.
_metric_fn_list
.
keys
(),
results
):
_dict
=
self
.
_metric_fn_list
[
key
](
references
=
gold
if
self
.
multiple_target
else
[
gold
],
predictions
=
[
result
],
**
self
.
_metric_fn_kwargs
[
key
],
)
if
self
.
multiple_target
:
# in the case where we have multiple targets,
# return true if any are true
# TODO: this may break for multipLe_target, non zero-or-1 metrics
scores
=
[]
for
gold_option
in
gold
:
res
=
self
.
_metric_fn_list
[
key
](
references
=
[
gold_option
],
predictions
=
[
result
],
**
self
.
_metric_fn_kwargs
[
key
],
)
if
isinstance
(
res
,
dict
):
# TODO: this handles the case where HF evaluate returns a dict.
res
=
res
[
key
]
scores
.
append
(
res
)
if
any
(
scores
):
result
=
1.0
else
:
result
=
0.0
else
:
result
=
self
.
_metric_fn_list
[
key
](
references
=
[
gold
],
predictions
=
[
result
],
**
self
.
_metric_fn_kwargs
[
key
],
)
result_dict
=
{
**
result_dict
,
**
_dict
}
if
isinstance
(
result
,
dict
):
result_dict
.
update
(
result
)
else
:
result_dict
[
key
]
=
result
else
:
raise
ValueError
(
f
"Passed invalid output_type '
{
self
.
OUTPUT_TYPE
}
' ! Please use one of "
,
...
...
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