Commit 597bf747 authored by jon-tow's avatar jon-tow
Browse files

Add `"\n###\n"` example separator

parent 567e24c9
...@@ -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)
......
...@@ -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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment