mirror of
https://github.com/ml-explore/mlx-examples.git
synced 2025-08-28 00:30:09 +08:00
Fix iteration over HF dataset collection
This commit is contained in:
parent
78c33e5037
commit
a4a86ad898
@ -90,7 +90,8 @@ class CompletionsDatasetCollection:
|
||||
self.collection = data
|
||||
|
||||
def __getitem__(self, idx: int):
|
||||
item = next(self.collection)
|
||||
iteration = iter(self.collection)
|
||||
item = next(iteration)
|
||||
|
||||
curr_idx = idx
|
||||
|
||||
@ -100,7 +101,7 @@ class CompletionsDatasetCollection:
|
||||
return item[curr_idx]
|
||||
else:
|
||||
curr_idx -= len(item)
|
||||
item = next(self.collection)
|
||||
item = next(iteration)
|
||||
except StopIteration:
|
||||
raise IndexError(idx)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user