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
1d7d3de5
Commit
1d7d3de5
authored
Jun 20, 2023
by
haileyschoelkopf
Committed by
lintangsutawika
Jun 22, 2023
Browse files
fix small TaskConfig bugs
parent
fd33fb97
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
lm_eval/api/task.py
lm_eval/api/task.py
+8
-2
No files found.
lm_eval/api/task.py
View file @
1d7d3de5
...
@@ -98,13 +98,16 @@ class TaskConfig(dict):
...
@@ -98,13 +98,16 @@ class TaskConfig(dict):
if
type
(
self
.
gold_alias
)
==
str
:
if
type
(
self
.
gold_alias
)
==
str
:
self
.
gold_alias
=
self
.
template_aliases
+
self
.
gold_alias
self
.
gold_alias
=
self
.
template_aliases
+
self
.
gold_alias
if
self
.
generation_kwargs
or
self
.
output_type
==
"greedy_until"
:
if
self
.
generation_kwargs
:
assert
(
assert
(
self
.
output_type
==
"greedy_until"
self
.
output_type
==
"greedy_until"
),
"passed `generation_kwargs`, but not using a generation request type!"
),
"passed `generation_kwargs`, but not using a generation request type!"
elif
self
.
output_type
==
"greedy_until"
:
# ensure that we greedily generate in absence of explicit arguments otherwise
# ensure that we greedily generate in absence of explicit arguments otherwise
self
.
generation_kwargs
=
{
"do_sample"
:
False
,
"temperature"
:
0.0
}
self
.
generation_kwargs
=
{
"do_sample"
:
False
,
"temperature"
:
0.0
}
# TODO: how to make TaskConfigs be de- and re-serializable, even when using the !function constructor?
def
__getitem__
(
self
,
item
):
def
__getitem__
(
self
,
item
):
return
getattr
(
self
,
item
)
return
getattr
(
self
,
item
)
...
@@ -123,6 +126,9 @@ class TaskConfig(dict):
...
@@ -123,6 +126,9 @@ class TaskConfig(dict):
for
k
,
v
in
list
(
cfg_dict
.
items
()):
for
k
,
v
in
list
(
cfg_dict
.
items
()):
if
v
is
None
:
if
v
is
None
:
cfg_dict
.
pop
(
k
)
cfg_dict
.
pop
(
k
)
elif
isinstance
(
v
,
Callable
):
# TODO: this should handle Promptsource template objects as a separate case?
cfg_dict
[
k
]
=
str
(
v
)
return
cfg_dict
return
cfg_dict
...
@@ -877,7 +883,7 @@ class ConfigurableTask(Task):
...
@@ -877,7 +883,7 @@ class ConfigurableTask(Task):
for
key
,
result
in
zip
(
self
.
_metric_fn_list
.
keys
(),
results
):
for
key
,
result
in
zip
(
self
.
_metric_fn_list
.
keys
(),
results
):
_dict
=
self
.
_metric_fn_list
[
key
].
compute
(
_dict
=
self
.
_metric_fn_list
[
key
].
compute
(
references
=
[
gold
],
predictions
=
[
result
],
**
self
.
_metric_kwargs
[
key
]
references
=
[
gold
],
predictions
=
[
result
],
**
self
.
_metric_
fn_
kwargs
[
key
]
)
)
result_dict
=
{
**
result_dict
,
**
_dict
}
result_dict
=
{
**
result_dict
,
**
_dict
}
...
...
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