Skip to content

Commit 1f6d472

Browse files
authored
Allowing a single prompt to use several formats for one eval (#398)
1 parent 3e9526d commit 1f6d472

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/lighteval/tasks/lighteval_task.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,13 @@ def _get_docs_from_split(self, splits: list[str], few_shots=False) -> list[Doc]:
289289

290290
docs = []
291291
for split in splits:
292-
for item in self.dataset[split]:
292+
for ix, item in enumerate(self.dataset[split]):
293293
# Some tasks formatting is applied differently when the document is used for fewshot examples
294294
# vs when it's used for the actual prompt. That's why we store whether we are currently using the
295295
# doc for a fewshot sample (few_shots=True) or not, which then leads to the creation of a different Doc.
296296
item["__few_shots"] = few_shots
297+
# Some tasks require to know which is the current item index in order to apply a different prompt template
298+
item["__index"] = ix
297299
cur_docs = self.formatter(item, self.name)
298300
if cur_docs is None:
299301
continue

0 commit comments

Comments
 (0)