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
65e5bc69
Commit
65e5bc69
authored
Aug 30, 2023
by
lintangsutawika
Browse files
added checks for if gold is outside choice options
parent
c052637f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
4 deletions
+22
-4
lm_eval/api/task.py
lm_eval/api/task.py
+22
-4
No files found.
lm_eval/api/task.py
View file @
65e5bc69
...
...
@@ -1014,18 +1014,36 @@ class ConfigurableTask(Task):
gold
=
self
.
doc_to_text
(
doc
)
else
:
gold
=
self
.
doc_to_target
(
doc
)
if
type
(
gold
)
is
str
:
gold
=
choices
.
index
(
gold
)
gold_index_error
=
False
if
type
(
gold
)
is
list
:
gold
=
[
i
if
i
<
len
(
choices
)
else
-
1000
for
i
in
gold
]
if
-
1000
in
gold
:
gold_index_error
=
True
else
:
if
type
(
gold
)
is
int
:
gold
=
gold
if
i
<
len
(
choice
)
else
-
1000
elif
type
(
gold
)
is
str
:
gold
=
choices
.
index
(
gold
)
if
gold
in
choices
else
-
1000
if
gold
==
-
1000
:
gold_index_error
=
True
if
gold_index_error
:
eval_logger
.
warning
(
f
"Label index was not in within range of availabel choices,"
f
"Sample:
\n\n
{
doc
}
\n\n
"
)
if
self
.
multiple_target
:
acc
=
1.0
if
pred
in
gold
else
0.0
acc_norm
=
1.0
if
pred_norm
in
gold
else
0.0
exact_match
=
int
(
any
([
is_greedy
[
i
]
for
i
in
gold
]))
exact_match
=
int
(
any
([
is_greedy
[
i
]
if
i
!=
-
1000
else
0
for
i
in
gold
]))
else
:
acc
=
1.0
if
pred
==
gold
else
0.0
acc_norm
=
1.0
if
pred_norm
==
gold
else
0.0
# TODO: this gets score of 0 on arc_challenge for pythia-70m. need to test that this works properly
exact_match
=
int
(
is_greedy
[
gold
])
exact_match
=
int
(
is_greedy
[
gold
])
if
i
!=
-
1000
else
0
result_dict
=
{
**
({
"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