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
f2b52d26
Commit
f2b52d26
authored
Jul 13, 2023
by
lintangsutawika
Browse files
doc_to_target should also be able to output str instead of solely int
parent
e454df7f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
1 deletion
+6
-1
lm_eval/api/samplers.py
lm_eval/api/samplers.py
+4
-1
lm_eval/api/task.py
lm_eval/api/task.py
+2
-0
No files found.
lm_eval/api/samplers.py
View file @
f2b52d26
...
@@ -42,7 +42,10 @@ class Sampler:
...
@@ -42,7 +42,10 @@ class Sampler:
+
self
.
target_delimiter
+
self
.
target_delimiter
+
(
+
(
self
.
doc_to_target
(
doc
)
self
.
doc_to_target
(
doc
)
if
self
.
config
.
doc_to_choice
is
None
if
(
self
.
config
.
doc_to_choice
is
None
or
type
(
self
.
doc_to_target
(
doc
))
is
str
)
else
self
.
doc_to_choice
(
doc
)[
self
.
doc_to_target
(
doc
)]
else
self
.
doc_to_choice
(
doc
)[
self
.
doc_to_target
(
doc
)]
)
)
for
doc
in
selected_docs
for
doc
in
selected_docs
...
...
lm_eval/api/task.py
View file @
f2b52d26
...
@@ -946,6 +946,8 @@ class ConfigurableTask(Task):
...
@@ -946,6 +946,8 @@ class ConfigurableTask(Task):
gold
=
self
.
doc_to_text
(
doc
)
gold
=
self
.
doc_to_text
(
doc
)
else
:
else
:
gold
=
self
.
doc_to_target
(
doc
)
gold
=
self
.
doc_to_target
(
doc
)
if
type
(
gold
)
is
str
:
gold
=
choices
.
index
(
gold
)
if
self
.
multiple_target
:
if
self
.
multiple_target
:
acc
=
1.0
if
pred
in
gold
else
0.0
acc
=
1.0
if
pred
in
gold
else
0.0
...
...
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