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
4e72f165
"vscode:/vscode.git/clone" did not exist on "25549433e8ff9965cbbbb8efe9d450753ca23356"
Commit
4e72f165
authored
Jun 16, 2023
by
lintangsutawika
Browse files
fixes for multiple_choice
parent
bafaef26
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
+12
-6
lm_eval/api/task.py
lm_eval/api/task.py
+10
-5
lm_eval/tasks/sciq/sciq.yaml
lm_eval/tasks/sciq/sciq.yaml
+2
-1
No files found.
lm_eval/api/task.py
View file @
4e72f165
...
...
@@ -73,7 +73,7 @@ class TaskConfig(dict):
repeats
:
int
=
1
metric_list
:
str
=
None
gold_alias
:
str
=
None
gold_alias
:
Union
[
Callable
,
str
]
=
None
output_type
:
str
=
"greedy_until"
generation_kwargs
:
dict
=
None
delimiter
:
str
=
"
\n\n
"
...
...
@@ -95,7 +95,7 @@ class TaskConfig(dict):
self
.
doc_to_target
=
self
.
template_aliases
+
self
.
doc_to_target
if
type
(
self
.
gold_alias
)
==
str
:
self
.
gold_alias
=
self
.
template_aliases
+
self
.
doc_to_target
self
.
gold_alias
=
self
.
template_aliases
+
self
.
gold_alias
if
self
.
generation_kwargs
or
self
.
output_type
==
"greedy_until"
:
assert
(
...
...
@@ -737,10 +737,11 @@ class ConfigurableTask(Task):
def
gold_alias
(
self
,
doc
):
# TODO: reevaluate if we need this. implemented to have a
# processed version of answer to put into gsm8k exact_match scoring as ref.
if
self
.
_config
.
gold_alias
:
if
self
.
_config
.
gold_alias
is
not
None
:
doc_to_target
=
self
.
_config
.
gold_alias
else
:
doc_to_target
=
self
.
_config
.
doc_to_target
# doc_to_target = self._config.doc_to_target
return
self
.
doc_to_target
(
doc
)
if
type
(
doc_to_target
)
==
str
:
return
utils
.
apply_template
(
doc_to_target
,
doc
)
...
...
@@ -842,7 +843,11 @@ class ConfigurableTask(Task):
elif
self
.
OUTPUT_TYPE
==
"multiple_choice"
:
lls
,
is_greedy
=
zip
(
*
results
)
gold
=
int
(
self
.
doc_to_target
(
doc
))
if
self
.
_config
.
gold_alias
is
not
None
:
gold
=
int
(
self
.
gold_alias
(
doc
))
else
:
gold
=
int
(
self
.
doc_to_target
(
doc
))
pred
=
np
.
argmax
(
lls
)
# retrieve choices in List[str] form, to compute choice lengths, etc.
choices
=
ast
.
literal_eval
(
...
...
lm_eval/tasks/sciq/sciq.yaml
View file @
4e72f165
...
...
@@ -9,7 +9,8 @@ validation_split: validation
test_split
:
test
template_aliases
:
"
{%
set
answer_choices
=
[distractor1,
distractor2,
distractor3,
correct_answer]
%}{%
set
gold
=
3
%}"
# set the list of possible answer choices, and set what this doc's gold label idx is
doc_to_text
:
"
{{support.lstrip()}}
\n
Question:
{{question}}
\n
Answer:"
doc_to_target
:
"
{{gold}}"
# this will be cast to an int.
doc_to_target
:
"
{{correct_answer}}"
gold_alias
:
"
{{gold}}"
# this will be cast to an int.
metric_list
:
-
metric
:
acc
aggregation
:
mean
...
...
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