Unverified Commit cf6a8321 authored by Lintang Sutawika's avatar Lintang Sutawika Committed by GitHub
Browse files

fixed fewshot loading for multiple input tasks (#1255)

parent 28ec7fa9
...@@ -787,16 +787,19 @@ class ConfigurableTask(Task): ...@@ -787,16 +787,19 @@ class ConfigurableTask(Task):
) )
example = self.doc_to_text(doc) example = self.doc_to_text(doc)
if isinstance(example, str): if self.multiple_input:
return labeled_examples + example return labeled_examples
elif isinstance(example, list): else:
return [labeled_examples + ex for ex in example] if isinstance(example, str):
elif isinstance(example, int): return labeled_examples + example
if self.config.doc_to_choice is not None: elif isinstance(example, list):
choices = self.doc_to_choice(doc) return [labeled_examples + ex for ex in example]
return labeled_examples + choices[example] elif isinstance(example, int):
else: if self.config.doc_to_choice is not None:
return labeled_examples + str(example) choices = self.doc_to_choice(doc)
return labeled_examples + choices[example]
else:
return labeled_examples + str(example)
def apply_filters(self): def apply_filters(self):
if hasattr(self, "_filters"): if hasattr(self, "_filters"):
...@@ -952,7 +955,9 @@ class ConfigurableTask(Task): ...@@ -952,7 +955,9 @@ class ConfigurableTask(Task):
if self.multiple_input: if self.multiple_input:
# If there are multiple inputs, choices are placed in the ctx # If there are multiple inputs, choices are placed in the ctx
cont = self.doc_to_target(doc) 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: else:
# Otherwise they are placed in the continuation # Otherwise they are placed in the continuation
arguments = [(ctx, f"{target_delimiter}{cont}") for cont in choices] arguments = [(ctx, f"{target_delimiter}{cont}") for cont in choices]
......
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