Skip to content

Commit d09e03d

Browse files
Fallback to super impl in fewshot_context for Unitxt tasks (#3023)
Signed-off-by: kiersten-stokes <[email protected]>
1 parent 147e9d6 commit d09e03d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lm_eval/tasks/unitxt/task.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def should_decontaminate(self):
105105
return False
106106

107107
def doc_to_target(self, doc):
108-
doc["target"]
108+
return doc["target"]
109109

110110
def get_arguments(self, doc, ctx):
111111
return (ctx, {"until": ["\n"]})
@@ -120,8 +120,7 @@ def fewshot_context(
120120
chat_template: Optional[Callable] = None,
121121
gen_prefix: Optional[str] = None,
122122
) -> str:
123-
source = self.doc_to_text(doc)
124-
if isinstance(source, list):
123+
if isinstance(self.doc_to_text(doc), list):
125124
if apply_chat_template:
126125
formated_source = chat_template(self.doc_to_text(doc))
127126
return formated_source
@@ -130,7 +129,15 @@ def fewshot_context(
130129
"Got chat template format from Unitxt, but apply_chat_template is false. Add '--apply_chat_template' to command line."
131130
)
132131
else:
133-
return source
132+
return super().fewshot_context(
133+
doc=doc,
134+
num_fewshot=num_fewshot,
135+
system_instruction=system_instruction,
136+
apply_chat_template=apply_chat_template,
137+
fewshot_as_multiturn=fewshot_as_multiturn,
138+
chat_template=chat_template,
139+
gen_prefix=gen_prefix,
140+
)
134141

135142
def construct_requests(self, doc, ctx, **kwargs):
136143
"""Uses RequestFactory to construct Requests and returns an iterable of

0 commit comments

Comments
 (0)