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
597bf747
Commit
597bf747
authored
Apr 27, 2022
by
jon-tow
Browse files
Add `"\n###\n"` example separator
parent
567e24c9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
lm_eval/base.py
lm_eval/base.py
+11
-4
scripts/write_out.py
scripts/write_out.py
+1
-1
No files found.
lm_eval/base.py
View file @
597bf747
...
@@ -645,14 +645,18 @@ class Task(abc.ABC):
...
@@ -645,14 +645,18 @@ class Task(abc.ABC):
# get rid of the doc that's the one we're evaluating, if it's in the fewshot
# get rid of the doc that's the one we're evaluating, if it's in the fewshot
fewshotex
=
[
x
for
x
in
fewshotex
if
x
!=
doc
][:
num_fewshot
]
fewshotex
=
[
x
for
x
in
fewshotex
if
x
!=
doc
][:
num_fewshot
]
# See Webson & Pavlick (2022) https://arxiv.org/pdf/2109.01247.pdf
# for justification of this separator.
example_separator
=
"
\n
###
\n
"
labeled_examples
=
(
labeled_examples
=
(
"
\n\n
"
.
join
(
example_separator
.
join
(
[
[
self
.
doc_to_text
(
doc
)
+
self
.
doc_to_target
(
doc
)
self
.
doc_to_text
(
doc
)
+
self
.
doc_to_target
(
doc
)
for
doc
in
fewshotex
for
doc
in
fewshotex
]
]
)
)
+
"
\n\n
"
+
example_separator
)
)
example
=
self
.
doc_to_text
(
doc
)
example
=
self
.
doc_to_text
(
doc
)
...
@@ -942,15 +946,18 @@ class PromptSourceTask(Task):
...
@@ -942,15 +946,18 @@ class PromptSourceTask(Task):
fewshotex
[:
num_fewshot
],
fewshotex
[:
num_fewshot
],
fewshotidx
[:
num_fewshot
],
fewshotidx
[:
num_fewshot
],
)
)
# See Webson & Pavlick (2022) https://arxiv.org/pdf/2109.01247.pdf
# for justification of this separator.
example_separator
=
"
\n
###
\n
"
labeled_examples
=
(
labeled_examples
=
(
"
\n\n
"
.
join
(
example_separator
.
join
(
[
[
self
.
doc_to_text
(
doc
)
+
self
.
doc_to_target
(
doc
)
self
.
doc_to_text
(
doc
)
+
self
.
doc_to_target
(
doc
)
for
doc
in
fewshotex
for
doc
in
fewshotex
]
]
)
)
+
"
\n\n
"
+
example_separator
)
)
example
=
self
.
doc_to_text
(
doc
)
example
=
self
.
doc_to_text
(
doc
)
...
...
scripts/write_out.py
View file @
597bf747
...
@@ -60,7 +60,7 @@ def main():
...
@@ -60,7 +60,7 @@ def main():
with
open
(
os
.
path
.
join
(
args
.
output_base_path
,
task_name
),
"w"
)
as
f
:
with
open
(
os
.
path
.
join
(
args
.
output_base_path
,
task_name
),
"w"
)
as
f
:
for
i
,
doc
in
zip
(
range
(
args
.
num_examples
),
docs
)
if
args
.
num_examples
>
0
else
enumerate
(
docs
):
for
i
,
doc
in
zip
(
range
(
args
.
num_examples
),
docs
)
if
args
.
num_examples
>
0
else
enumerate
(
docs
):
f
.
write
(
EXAMPLE_DIVIDER
.
format
(
i
=
i
))
f
.
write
(
EXAMPLE_DIVIDER
.
format
(
i
=
i
))
ctx
=
task
.
fewshot_context
(
ctx
,
_
=
task
.
fewshot_context
(
doc
=
doc
,
doc
=
doc
,
num_fewshot
=
args
.
num_fewshot
,
num_fewshot
=
args
.
num_fewshot
,
rnd
=
rnd
,
rnd
=
rnd
,
...
...
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