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
c37ad6ec
Commit
c37ad6ec
authored
Jul 11, 2023
by
lintangsutawika
Browse files
process multiple_output
parent
4c363ef8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
11 deletions
+19
-11
lm_eval/api/task.py
lm_eval/api/task.py
+19
-11
No files found.
lm_eval/api/task.py
View file @
c37ad6ec
...
@@ -919,9 +919,6 @@ class ConfigurableTask(Task):
...
@@ -919,9 +919,6 @@ class ConfigurableTask(Task):
choices
=
self
.
doc_to_choice
(
doc
)
choices
=
self
.
doc_to_choice
(
doc
)
completion_len
=
np
.
array
([
float
(
len
(
i
))
for
i
in
choices
])
completion_len
=
np
.
array
([
float
(
len
(
i
))
for
i
in
choices
])
if
self
.
multiple_output
:
pass
if
(
if
(
2
*
len
(
choices
)
==
len
(
lls
)
2
*
len
(
choices
)
==
len
(
lls
)
and
"acc_mutual_info"
in
self
.
_metric_fn_list
.
keys
()
and
"acc_mutual_info"
in
self
.
_metric_fn_list
.
keys
()
...
@@ -946,14 +943,25 @@ class ConfigurableTask(Task):
...
@@ -946,14 +943,25 @@ class ConfigurableTask(Task):
pred
=
choices
[
pred_idx
]
pred
=
choices
[
pred_idx
]
pred_norm
=
choices
[
pred_idx_norm
]
pred_norm
=
choices
[
pred_idx_norm
]
gold
=
self
.
doc_to_target
(
doc
)
gold
=
self
.
doc_to_target
(
doc
)
if
type
(
gold
)
==
int
:
if
self
.
multiple_output
:
gold_idx
=
gold
if
type
(
gold
[
0
])
==
int
:
gold
=
choices
[
gold_idx
]
gold_idx
=
gold
elif
type
(
gold
)
==
str
:
gold
=
[
choices
[
idx
]
for
idx
in
gold_idx
]
gold_idx
=
choices
.
index
(
gold
)
elif
type
(
gold
[
0
])
==
str
:
gold_idx
=
[
choices
.
index
(
g
)
for
g
in
gold
]
acc
=
1.0
if
pred
==
gold
else
0.0
else
:
acc_norm
=
1.0
if
pred_norm
==
gold
else
0.0
if
type
(
gold
)
==
int
:
gold_idx
=
gold
gold
=
choices
[
gold_idx
]
elif
type
(
gold
)
==
str
:
gold_idx
=
choices
.
index
(
gold
)
if
self
.
multiple_output
:
acc
=
1.0
if
pred
in
gold
else
0.0
acc_norm
=
1.0
if
pred_norm
in
gold
else
0.0
else
:
acc
=
1.0
if
pred
==
gold
else
0.0
acc_norm
=
1.0
if
pred_norm
==
gold
else
0.0
result_dict
=
{
result_dict
=
{
**
({
"acc"
:
acc
}
if
"acc"
in
use_metric
else
{}),
**
({
"acc"
:
acc
}
if
"acc"
in
use_metric
else
{}),
...
...
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