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
cf6a8321
Unverified
Commit
cf6a8321
authored
Jan 08, 2024
by
Lintang Sutawika
Committed by
GitHub
Jan 08, 2024
Browse files
fixed fewshot loading for multiple input tasks (#1255)
parent
28ec7fa9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
11 deletions
+16
-11
lm_eval/api/task.py
lm_eval/api/task.py
+16
-11
No files found.
lm_eval/api/task.py
View file @
cf6a8321
...
...
@@ -787,16 +787,19 @@ class ConfigurableTask(Task):
)
example
=
self
.
doc_to_text
(
doc
)
if
isinstance
(
example
,
str
):
return
labeled_examples
+
example
elif
isinstance
(
example
,
list
):
return
[
labeled_examples
+
ex
for
ex
in
example
]
elif
isinstance
(
example
,
int
):
if
self
.
config
.
doc_to_choice
is
not
None
:
choices
=
self
.
doc_to_choice
(
doc
)
return
labeled_examples
+
choices
[
example
]
else
:
return
labeled_examples
+
str
(
example
)
if
self
.
multiple_input
:
return
labeled_examples
else
:
if
isinstance
(
example
,
str
):
return
labeled_examples
+
example
elif
isinstance
(
example
,
list
):
return
[
labeled_examples
+
ex
for
ex
in
example
]
elif
isinstance
(
example
,
int
):
if
self
.
config
.
doc_to_choice
is
not
None
:
choices
=
self
.
doc_to_choice
(
doc
)
return
labeled_examples
+
choices
[
example
]
else
:
return
labeled_examples
+
str
(
example
)
def
apply_filters
(
self
):
if
hasattr
(
self
,
"_filters"
):
...
...
@@ -952,7 +955,9 @@ class ConfigurableTask(Task):
if
self
.
multiple_input
:
# If there are multiple inputs, choices are placed in the ctx
cont
=
self
.
doc_to_target
(
doc
)
arguments
=
[(
ctx
,
f
"
{
target_delimiter
}{
cont
}
"
)
for
ctx
in
choices
]
arguments
=
[
(
ctx
+
choice
,
f
"
{
target_delimiter
}{
cont
}
"
)
for
choice
in
choices
]
else
:
# Otherwise they are placed in the continuation
arguments
=
[(
ctx
,
f
"
{
target_delimiter
}{
cont
}
"
)
for
cont
in
choices
]
...
...
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