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
9b20e2d0
Commit
9b20e2d0
authored
Jul 11, 2023
by
lintangsutawika
Browse files
update choice process
parent
656c310e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
lm_eval/api/task.py
lm_eval/api/task.py
+8
-7
No files found.
lm_eval/api/task.py
View file @
9b20e2d0
...
@@ -67,7 +67,7 @@ class TaskConfig(dict):
...
@@ -67,7 +67,7 @@ class TaskConfig(dict):
template_aliases
:
Union
[
str
,
list
]
=
None
template_aliases
:
Union
[
str
,
list
]
=
None
doc_to_text
:
Union
[
Callable
,
str
]
=
None
doc_to_text
:
Union
[
Callable
,
str
]
=
None
doc_to_target
:
Union
[
Callable
,
str
]
=
None
doc_to_target
:
Union
[
Callable
,
str
]
=
None
doc_to_choice
:
Union
[
Callable
,
str
]
=
None
doc_to_choice
:
Union
[
Callable
,
str
,
dict
,
list
]
=
None
gold_alias
:
Union
[
Callable
,
str
]
=
None
gold_alias
:
Union
[
Callable
,
str
]
=
None
use_prompt
:
str
=
None
use_prompt
:
str
=
None
description
:
str
=
""
description
:
str
=
""
...
@@ -317,11 +317,9 @@ class Task(abc.ABC):
...
@@ -317,11 +317,9 @@ class Task(abc.ABC):
def
doc_to_choice
(
self
,
doc
):
def
doc_to_choice
(
self
,
doc
):
if
self
.
_config
.
doc_to_choice
is
None
:
if
self
.
_config
.
doc_to_choice
is
None
:
return
ast
.
literal_eval
(
eval_logger
.
error
(
"doc_to_choice was callsed but not set in config"
)
utils
.
apply_template
(
elif
type
(
self
.
_config
.
doc_to_choice
)
==
list
:
self
.
_config
.
template_aliases
+
"{{answer_choices}}"
,
doc
return
self
.
_config
.
doc_to_choice
)
)
elif
type
(
self
.
_config
.
doc_to_choice
)
==
dict
:
elif
type
(
self
.
_config
.
doc_to_choice
)
==
dict
:
return
list
(
self
.
_config
.
doc_to_choice
.
values
())
return
list
(
self
.
_config
.
doc_to_choice
.
values
())
elif
type
(
self
.
_config
.
doc_to_choice
)
==
str
:
elif
type
(
self
.
_config
.
doc_to_choice
)
==
str
:
...
@@ -761,7 +759,10 @@ class ConfigurableTask(Task):
...
@@ -761,7 +759,10 @@ class ConfigurableTask(Task):
if
type
(
doc_to_target
)
==
str
:
if
type
(
doc_to_target
)
==
str
:
if
doc_to_target
in
self
.
features
:
if
doc_to_target
in
self
.
features
:
return
doc
[
doc_to_target
]
if
self
.
_config
.
doc_to_choice
is
not
None
:
return
self
.
doc_to_choice
(
doc
)[
doc
[
doc_to_target
]]
else
:
return
doc
[
doc_to_target
]
else
:
else
:
return
utils
.
apply_template
(
doc_to_target
,
doc
)
return
utils
.
apply_template
(
doc_to_target
,
doc
)
elif
callable
(
doc_to_target
):
elif
callable
(
doc_to_target
):
...
...
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