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
3d5fa4c7
Commit
3d5fa4c7
authored
Aug 02, 2025
by
Baber
Browse files
fix doc_to_target to return int rather than str (deprecated)
parent
01daa983
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
7 deletions
+3
-7
lm_eval/api/task.py
lm_eval/api/task.py
+0
-4
lm_eval/tasks/super_glue/record/util.py
lm_eval/tasks/super_glue/record/util.py
+1
-1
tests/test_tasks.py
tests/test_tasks.py
+2
-2
No files found.
lm_eval/api/task.py
View file @
3d5fa4c7
...
@@ -971,10 +971,6 @@ class ConfigurableTask(Task):
...
@@ -971,10 +971,6 @@ class ConfigurableTask(Task):
)
)
test_target
=
test_choice
[
test_target
]
test_target
=
test_choice
[
test_target
]
assert
hasattr
(
test_choice
,
"__iter__"
)
and
not
isinstance
(
test_choice
,
(
str
,
bytes
)
),
f
"[
{
self
.
config
.
task
}
] doc_to_choice must be an iterable!"
for
choice
in
test_choice
:
for
choice
in
test_choice
:
choice_has_whitespace
=
choice
[
0
].
isspace
()
choice_has_whitespace
=
choice
[
0
].
isspace
()
delimiter_has_whitespace
=
(
delimiter_has_whitespace
=
(
...
...
lm_eval/tasks/super_glue/record/util.py
View file @
3d5fa4c7
...
@@ -19,7 +19,7 @@ def format_answer(query, entity):
...
@@ -19,7 +19,7 @@ def format_answer(query, entity):
def
doc_to_target
(
doc
):
def
doc_to_target
(
doc
):
# We only output the first correct entity in a doc
# We only output the first correct entity in a doc
return
format_answer
(
query
=
doc
[
"query"
],
entity
=
doc
[
"answers"
][
0
])
return
doc
[
"entities"
].
index
(
doc
[
"answers"
][
0
])
def
doc_to_choice
(
doc
):
def
doc_to_choice
(
doc
):
...
...
tests/test_tasks.py
View file @
3d5fa4c7
...
@@ -93,7 +93,7 @@ class BaseTasks:
...
@@ -93,7 +93,7 @@ class BaseTasks:
_array
=
[
task
.
doc_to_text
(
doc
)
for
doc
in
arr
]
_array
=
[
task
.
doc_to_text
(
doc
)
for
doc
in
arr
]
# space convention; allow txt to have length 0 for perplexity-like tasks since the model tacks an <|endoftext|> on
# space convention; allow txt to have length 0 for perplexity-like tasks since the model tacks an <|endoftext|> on
target_delimiter
:
str
=
task
.
config
.
target_delimiter
target_delimiter
:
str
=
task
.
config
.
target_delimiter
if
not
task
.
multiple_input
:
if
not
task
.
multiple_input
s
:
for
x
in
_array
:
for
x
in
_array
:
assert
isinstance
(
x
,
str
)
assert
isinstance
(
x
,
str
)
assert
(
assert
(
...
@@ -148,7 +148,7 @@ class BaseTasks:
...
@@ -148,7 +148,7 @@ class BaseTasks:
# ctx is "" for multiple input tasks
# ctx is "" for multiple input tasks
requests
=
[
requests
=
[
task
.
construct_requests
(
task
.
construct_requests
(
doc
=
doc
,
ctx
=
""
if
task
.
multiple_input
else
task
.
doc_to_text
(
doc
)
doc
=
doc
,
ctx
=
""
if
task
.
multiple_input
s
else
task
.
doc_to_text
(
doc
)
)
)
for
doc
in
arr
for
doc
in
arr
]
]
...
...
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