Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanHB committed Feb 5, 2024
1 parent 1a5d346 commit 5ca5835
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/lighteval/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from torch.utils.data import Dataset
from torch.utils.data.distributed import DistributedSampler, T_co

from lighteval.logging.hierarchical_logger import hlog_warn
from lighteval.logging.hierarchical_logger import hlog, hlog_warn
from lighteval.tasks.requests import Request


Expand Down Expand Up @@ -194,6 +194,22 @@ def _sorting_criteria(self, x) -> int:
_, gen_length = meta_data[0], meta_data[1]
return -(len(toks) + gen_length)

class GenerativeTaskDatasetBrrr(DynamicBatchDataset):
def _sorting_criteria(self, x) -> int:
"""
Collate function for generating batches.
Args:
x (Any): The input data.
Returns:
Any: The collated data.
"""
toks = x[1][0]
meta_data = x[1][1]
_, gen_length = meta_data[0], meta_data[1]
return -(len(toks) + gen_length)


class GenDistributedSampler(DistributedSampler):
"""A distributed sampler that copy the last element only when drop_last is False so we keep a small padding in the batches
Expand Down

0 comments on commit 5ca5835

Please sign in to comment.