Upload fusion.py with huggingface_hub
Browse files3 unmodified lines45677891078 unmodified lines8990919293949595969798991001013 unmodified lines
from .dataclass import NonPositionalFieldfrom .operator import SourceOperator, StreamSourcefrom .random_utils import get_randomfrom .random_utils import new_random_generatorfrom .stream import MultiStream, Stream
78 unmodified lines weights = copy.deepcopy(self.weights) iterators = [iter(origin()[split]) for origin in self.origins] total_examples = 0 random_generator = new_random_generator(sub_seed="weighted_fusion_" + split) while ( self.max_total_examples is None or total_examples <= self.max_total_examples ) and len(iterators) > 0: iterator = get_random().choices(population=iterators, weights=weights)[0] iterator = random_generator.choices(population=iterators, weights=weights)[ 0 ] try: yield next(iterator) total_examples += 1fusion.py+5-2