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
2bde99e4
Unverified
Commit
2bde99e4
authored
May 15, 2025
by
tawsif
Committed by
GitHub
May 15, 2025
Browse files
Update utils.py (#2870)
parent
86a3b270
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
23 deletions
+6
-23
lm_eval/tasks/mmlu_pro/utils.py
lm_eval/tasks/mmlu_pro/utils.py
+6
-23
No files found.
lm_eval/tasks/mmlu_pro/utils.py
View file @
2bde99e4
from
functools
import
partial
choices
=
[
"A"
,
"B"
,
"C"
,
"D"
,
"E"
,
"F"
,
"G"
,
"H"
,
"I"
,
"J"
,
"K"
,
"L"
,
"M"
,
"N"
,
"O"
,
"P"
,
]
choices
=
[
"A"
,
"B"
,
"C"
,
"D"
,
"E"
,
"F"
,
"G"
,
"H"
,
"I"
,
"J"
]
def
format_cot_example
(
example
,
including_answer
=
True
):
prompt
=
"Question:
\n
"
...
...
@@ -27,8 +8,12 @@ def format_cot_example(example, including_answer=True):
options
=
example
[
"options"
]
prompt
+=
question
+
"
\n
"
prompt
+=
"Options:
\n
"
for
i
,
opt
in
enumerate
(
options
):
if
i
>=
len
(
choices
):
break
prompt
+=
"{}. {}
\n
"
.
format
(
choices
[
i
],
opt
)
if
including_answer
:
cot_content
=
example
[
"cot_content"
].
replace
(
"A: Let's think step by step."
,
"Answer: Let's think step by step."
...
...
@@ -36,17 +21,15 @@ def format_cot_example(example, including_answer=True):
prompt
+=
cot_content
+
"
\n\n
"
else
:
prompt
+=
"Answer: Let's think step by step."
return
prompt
doc_to_text
=
partial
(
format_cot_example
,
including_answer
=
False
)
fewshot_to_text
=
partial
(
format_cot_example
,
including_answer
=
True
)
def
process_docs
(
dataset
,
subject
):
return
dataset
.
filter
(
lambda
x
:
x
[
"category"
]
==
subject
)
process_biology
=
partial
(
process_docs
,
subject
=
"biology"
)
process_business
=
partial
(
process_docs
,
subject
=
"business"
)
process_chemistry
=
partial
(
process_docs
,
subject
=
"chemistry"
)
...
...
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