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
155160a1
Commit
155160a1
authored
Jul 11, 2023
by
lintangsutawika
Browse files
add ast.literal_eval to doc_to_choice
parent
c37ad6ec
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
lm_eval/api/task.py
lm_eval/api/task.py
+10
-3
No files found.
lm_eval/api/task.py
View file @
155160a1
...
@@ -323,7 +323,9 @@ class Task(abc.ABC):
...
@@ -323,7 +323,9 @@ class Task(abc.ABC):
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
:
return
utils
.
apply_template
(
self
.
_config
.
doc_to_choice
,
doc
)
return
ast
.
literal_eval
(
utils
.
apply_template
(
self
.
_config
.
doc_to_choice
,
doc
)
)
else
:
else
:
return
self
.
_config
.
doc_to_choice
(
doc
)
return
self
.
_config
.
doc_to_choice
(
doc
)
...
@@ -720,7 +722,12 @@ class ConfigurableTask(Task):
...
@@ -720,7 +722,12 @@ class ConfigurableTask(Task):
def
doc_to_decontamination_query
(
self
,
doc
):
def
doc_to_decontamination_query
(
self
,
doc
):
if
self
.
_config
.
should_decontaminate
:
if
self
.
_config
.
should_decontaminate
:
return
utils
.
apply_template
(
self
.
_config
.
doc_to_decontamination_query
,
doc
)
if
self
.
_config
.
doc_to_decontamination_query
in
self
.
features
:
return
doc
[
self
.
_config
.
doc_to_decontamination_query
]
else
:
return
ast
.
literal_eval
(
utils
.
apply_template
(
self
.
_config
.
doc_to_decontamination_query
,
doc
)
)
def
_process_doc
(
self
,
doc
):
def
_process_doc
(
self
,
doc
):
"""
"""
...
@@ -943,7 +950,7 @@ class ConfigurableTask(Task):
...
@@ -943,7 +950,7 @@ class ConfigurableTask(Task):
pred
=
choices
[
pred_idx
]
pred
=
choices
[
pred_idx
]
pred_norm
=
choices
[
pred_idx_norm
]
pred_norm
=
choices
[
pred_idx_norm
]
gold
=
self
.
doc_to_target
(
doc
)
gold
=
self
.
doc_to_target
(
doc
)
if
self
.
multiple_output
:
if
self
.
multiple_output
>
0
:
if
type
(
gold
[
0
])
==
int
:
if
type
(
gold
[
0
])
==
int
:
gold_idx
=
gold
gold_idx
=
gold
gold
=
[
choices
[
idx
]
for
idx
in
gold_idx
]
gold
=
[
choices
[
idx
]
for
idx
in
gold_idx
]
...
...
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