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
5c914988
Commit
5c914988
authored
Feb 04, 2025
by
Baber
Browse files
handle doc_to_text is callable
parent
3f671a44
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
7 deletions
+18
-7
lm_eval/tasks/__init__.py
lm_eval/tasks/__init__.py
+18
-7
No files found.
lm_eval/tasks/__init__.py
View file @
5c914988
...
...
@@ -9,6 +9,7 @@ from lm_eval import utils
from
lm_eval.api.group
import
ConfigurableGroup
,
GroupConfig
from
lm_eval.api.task
import
ConfigurableTask
,
Generate_MultipleChoice
,
Task
from
lm_eval.evaluator_utils
import
get_subtask_list
from
lm_eval.tasks.mmlu_pro.utils
import
doc_to_text
GROUP_ONLY_KEYS
=
list
(
GroupConfig
().
to_dict
().
keys
())
...
...
@@ -20,13 +21,23 @@ def convert_mcq_to_generative(cfg: dict):
return
cfg
else
:
cfg
[
"output_type"
]
=
"generate_until"
cfg
[
"doc_to_text"
]
=
(
prompt
+
"
\n
"
+
cfg
.
get
(
"doc_to_text"
,
""
)
+
"
\n
"
+
'Your response should end with "The best answer is [the_answer_letter]" where the [the_answer_letter] is one of choice letters, A, B, C etc.'
)
doc_to_text
=
cfg
.
get
(
"doc_to_text"
,
""
)
if
isinstance
(
doc_to_text
,
str
):
cfg
[
"doc_to_text"
]
=
(
prompt
+
"
\n
"
+
cfg
.
get
(
"doc_to_text"
,
""
)
+
"
\n
"
+
'Your response should be formatted as "The best answer is [the_answer_letter]" where the [the_answer_letter] is one of choice letters, A, B, C etc.'
)
elif
callable
(
doc_to_text
):
cfg
[
"doc_to_text"
]
=
(
lambda
doc
:
prompt
+
"
\n
"
+
doc_to_text
(
doc
)
+
"
\n
"
+
'Your response should be formatted as "The best answer is [the_answer_letter]" where the [the_answer_letter] is one of choice letters, A, B, C etc.'
)
cfg
[
"target_delimiter"
]
=
"
\n\n
"
cfg
[
"gen_prefix"
]
=
"The best answer is"
cfg
[
"generation_kwargs"
]
=
{
"until"
:
[
"."
],
"max_gen_toks"
:
10
}
...
...
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