Skip to content

Commit

Permalink
Fix fewshot_config sampler constructor error
Browse files Browse the repository at this point in the history
  • Loading branch information
pufanyi committed Mar 27, 2024
1 parent 2571960 commit 5dca4e1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lmms_eval/api/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,12 @@ def __init__(self, model_name) -> None: # TODO no super() call here
if self.config.task == "flickr30k_test":
pass # TODO: for test, will delete later
if self.config.fewshot_config is not None:
random_seed = self.config.fewshot_config.get("random_seed", 1234)
sampler_function = samplers.get_sampler(self.config.fewshot_config.get("sampler", "default") if self.config.fewshot_config else "default")
self.sampler = sampler_function(list(self.fewshot_docs()), self, rnd=random.Random(random_seed))
try:
random_seed = self.config.fewshot_config.get("random_seed", 1234)
sampler_constructor = samplers.get_sampler(self.config.fewshot_config.get("sampler", "default") if self.config.fewshot_config else "default")
self.sampler = sampler_constructor(list(self.fewshot_docs()), self, rnd=random.Random(random_seed))
except Exception as e:
eval_logger.error(f"Error in fewshot_config: {e}")

if self.has_test_docs():
self.task_docs = self.test_docs()
Expand Down

0 comments on commit 5dca4e1

Please sign in to comment.