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
6b20ae8c
Commit
6b20ae8c
authored
Sep 08, 2025
by
Baber
Browse files
add create_cloze_choices function
parent
1646596a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
8 deletions
+5
-8
lm_eval/config/utils.py
lm_eval/config/utils.py
+5
-8
No files found.
lm_eval/config/utils.py
View file @
6b20ae8c
...
@@ -36,19 +36,16 @@ def maybe_serialize(
...
@@ -36,19 +36,16 @@ def maybe_serialize(
)
)
def
create_mc_choices
(
choices
:
list
[
str
],
choice_delimiter
:
str
|
None
=
"
\n
"
)
->
str
:
def
create_mc_choices
(
choices
:
list
[
str
],
choice_delimiter
:
str
=
"
\n
"
)
->
str
:
"""Creates a multiple-choice question format from a list of choices."""
"""Creates a multiple-choice question format from a list of choices."""
if
len
(
choices
)
<
2
:
raise
ValueError
(
"At least two choices are required for a multiple-choice question."
)
if
choice_delimiter
is
None
:
choice_delimiter
=
"
\n
"
formatted_choices
=
[
f
"
{
chr
(
65
+
i
)
}
.
{
choice
}
"
for
i
,
choice
in
enumerate
(
choices
)]
formatted_choices
=
[
f
"
{
chr
(
65
+
i
)
}
.
{
choice
}
"
for
i
,
choice
in
enumerate
(
choices
)]
return
choice_delimiter
.
join
(
formatted_choices
)
return
choice_delimiter
.
join
(
formatted_choices
)
def
create_cloze_choices
(
choices
:
list
[
str
],
choice_delimiter
:
str
=
"
\n
"
)
->
str
:
"""Creates a cloze-style question format from a list of choices."""
def
doc_to_closure
(
fn
:
Callable
[...,
T
])
->
Callable
[...,
T
]:
def
doc_to_closure
(
fn
:
Callable
[...,
T
])
->
Callable
[...,
T
]:
"""Closure that allows the function to be called with 'self'."""
"""Closure that allows the function to be called with 'self'."""
...
...
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