Unverified Commit d09e03dd authored by Kiersten Stokes's avatar Kiersten Stokes Committed by GitHub
Browse files

Fallback to super impl in fewshot_context for Unitxt tasks (#3023)


Signed-off-by: default avatarkiersten-stokes <kierstenstokes@gmail.com>
parent 147e9d61
...@@ -105,7 +105,7 @@ class Unitxt(ConfigurableTask): ...@@ -105,7 +105,7 @@ class Unitxt(ConfigurableTask):
return False return False
def doc_to_target(self, doc): def doc_to_target(self, doc):
doc["target"] return doc["target"]
def get_arguments(self, doc, ctx): def get_arguments(self, doc, ctx):
return (ctx, {"until": ["\n"]}) return (ctx, {"until": ["\n"]})
...@@ -120,8 +120,7 @@ class Unitxt(ConfigurableTask): ...@@ -120,8 +120,7 @@ class Unitxt(ConfigurableTask):
chat_template: Optional[Callable] = None, chat_template: Optional[Callable] = None,
gen_prefix: Optional[str] = None, gen_prefix: Optional[str] = None,
) -> str: ) -> str:
source = self.doc_to_text(doc) if isinstance(self.doc_to_text(doc), list):
if isinstance(source, list):
if apply_chat_template: if apply_chat_template:
formated_source = chat_template(self.doc_to_text(doc)) formated_source = chat_template(self.doc_to_text(doc))
return formated_source return formated_source
...@@ -130,7 +129,15 @@ class Unitxt(ConfigurableTask): ...@@ -130,7 +129,15 @@ class Unitxt(ConfigurableTask):
"Got chat template format from Unitxt, but apply_chat_template is false. Add '--apply_chat_template' to command line." "Got chat template format from Unitxt, but apply_chat_template is false. Add '--apply_chat_template' to command line."
) )
else: else:
return source return super().fewshot_context(
doc=doc,
num_fewshot=num_fewshot,
system_instruction=system_instruction,
apply_chat_template=apply_chat_template,
fewshot_as_multiturn=fewshot_as_multiturn,
chat_template=chat_template,
gen_prefix=gen_prefix,
)
def construct_requests(self, doc, ctx, **kwargs): def construct_requests(self, doc, ctx, **kwargs):
"""Uses RequestFactory to construct Requests and returns an iterable of """Uses RequestFactory to construct Requests and returns an iterable of
......
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