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
ff4b2fac
Unverified
Commit
ff4b2fac
authored
Jun 16, 2023
by
Hailey Schoelkopf
Committed by
GitHub
Jun 16, 2023
Browse files
Merge pull request #598 from EleutherAI/patch-multiple-choice
fixes for multiple_choice
parents
c87fc788
b4dd86e3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
7 deletions
+13
-7
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
setup.py
setup.py
+1
-1
No files found.
lm_eval/api/task.py
View file @
ff4b2fac
...
...
@@ -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 @
ff4b2fac
...
...
@@ -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
...
...
setup.py
View file @
ff4b2fac
...
...
@@ -15,7 +15,7 @@ setuptools.setup(
packages
=
setuptools
.
find_packages
(),
# required to include yaml files in pip installation
package_data
=
{
"lm_eval"
:
[
"**/*.yaml"
],
"lm_eval"
:
[
"**/*.yaml"
],
"examples"
:
[
"**/*.yaml"
],
},
include_package_data
=
True
,
...
...
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