Skip to content

Commit

Permalink
fix post merge
Browse files Browse the repository at this point in the history
  • Loading branch information
clefourrier committed Mar 4, 2024
1 parent fc3177a commit 923af50
Show file tree
Hide file tree
Showing 4 changed files with 1,253 additions and 1,217 deletions.
8 changes: 3 additions & 5 deletions src/lighteval/tasks/lighteval_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ class LightevalTaskConfig:

trust_dataset: bool = None

must_remove_duplicate_docs: bool = None

def as_dict(self):
return {
"name": self.name,
Expand Down Expand Up @@ -351,12 +353,8 @@ def doc_to_target(self, formatted_doc: Doc, few_shot: bool = False) -> str:
Returns:
str: Target of the document, which is the correct answer for a document.
"""
if few_shot:
if formatted_doc.target_for_fewshot_sorting is not None:
return formatted_doc.target_for_fewshot_sorting

# likely we mostly need one example not all
return formatted_doc.get_golds()[0]
return formatted_doc.get_golds(few_shot=few_shot)[0]

# Requests
def get_request_type(self) -> list[RequestType]:
Expand Down
8 changes: 6 additions & 2 deletions src/lighteval/tasks/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,16 @@ class Doc:
num_asked_few_shots: int = -1
num_effective_few_shots: int = -1

def get_golds(self):
def get_golds(self, few_shot: bool = False):
"""Return gold targets extracted from the target dict"""
gold_indices = as_list(self.gold_index)
if few_shot and self.target_for_fewshot_sorting is not None:
choices = self.target_for_fewshot_sorting
else:
choices = self.choices
golds = []
for gold_ix in gold_indices:
local_golds = as_list(self.choices[gold_ix])
local_golds = as_list(choices[gold_ix])
for local_gold in local_golds:
golds.append(local_gold)
return golds
Expand Down
Loading

0 comments on commit 923af50

Please sign in to comment.