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
4bba7abb
Commit
4bba7abb
authored
Aug 21, 2023
by
lintangsutawika
Browse files
no need to iterate over results for greedy_until
parent
a38a0450
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
26 deletions
+26
-26
lm_eval/api/task.py
lm_eval/api/task.py
+26
-26
No files found.
lm_eval/api/task.py
View file @
4bba7abb
...
@@ -1017,37 +1017,37 @@ class ConfigurableTask(Task):
...
@@ -1017,37 +1017,37 @@ class ConfigurableTask(Task):
else
:
else
:
gold
=
str
(
gold
)
gold
=
str
(
gold
)
result
,
_
=
results
for
metric
in
self
.
_metric_fn_list
.
keys
():
for
metric
in
self
.
_metric_fn_list
.
keys
():
for
result
in
results
:
if
self
.
multiple_target
:
if
self
.
multiple_target
:
# in the case where we have multiple targets,
# in the case where we have multiple targets,
# return true if any are true
# return true if any are true
# TODO: this may break for multipLe_target, non zero-or-1 metrics
# TODO: this may break for multipLe_target, non zero-or-1 metrics
scores
=
[]
scores
=
[]
for
gold_option
in
gold
:
for
gold_option
in
gold
:
res
=
self
.
_metric_fn_list
[
metric
](
res
=
self
.
_metric_fn_list
[
metric
](
references
=
[
gold_option
],
references
=
[
gold_option
],
predictions
=
[
result
],
**
self
.
_metric_fn_kwargs
[
metric
],
)
if
isinstance
(
res
,
dict
):
# TODO: this handles the case where HF evaluate returns a dict.
res
=
res
[
metric
]
scores
.
append
(
res
)
if
any
(
scores
):
result_score
=
1.0
else
:
result_score
=
0.0
else
:
result_score
=
self
.
_metric_fn_list
[
metric
](
references
=
[
gold
],
predictions
=
[
result
],
predictions
=
[
result
],
**
self
.
_metric_fn_kwargs
[
metric
],
**
self
.
_metric_fn_kwargs
[
metric
],
)
)
if
isinstance
(
res
ult_score
,
dict
):
if
isinstance
(
res
,
dict
):
# TODO: this handles the case where HF evaluate returns a dict.
# TODO: this handles the case where HF evaluate returns a dict.
result_score
=
result_score
[
metric
]
res
=
res
[
metric
]
result_dict
[
metric
]
=
result_score
scores
.
append
(
res
)
if
any
(
scores
):
result_score
=
1.0
else
:
result_score
=
0.0
else
:
result_score
=
self
.
_metric_fn_list
[
metric
](
references
=
[
gold
],
predictions
=
[
result
],
**
self
.
_metric_fn_kwargs
[
metric
],
)
if
isinstance
(
result_score
,
dict
):
# TODO: this handles the case where HF evaluate returns a dict.
result_score
=
result_score
[
metric
]
result_dict
[
metric
]
=
result_score
else
:
else
:
raise
ValueError
(
raise
ValueError
(
f
"Passed invalid output_type '
{
self
.
OUTPUT_TYPE
}
' ! Please use one of "
,
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