MCPcopy Create free account
hub / github.com/ContextualAI/HALOs / get_flat_data

Method get_flat_data

train/dataloader.py:634–656  ·  view source on GitHub ↗

Return a flat list of examples given a list of prompts that index self.full_data. Assumes that there are a list of scores.

(self, prompts)

Source from the content-addressed store, hash-verified

632
633class ScoreDataLoader(UnpairedPreferenceDataLoader):
634 def get_flat_data(self, prompts):
635 """
636 Return a flat list of examples given a list of prompts that index self.full_data.
637 Assumes that there are a list of scores.
638 """
639 flat_data = []
640 prev_status = 'rejected'
641
642 for prompt in prompts:
643 example = self.full_data[prompt]
644
645 if self.max_prompt_count:
646 example.pairs = self.rng.sample(example.pairs, min(self.max_prompt_count, len(example.pairs)))
647
648 # for oasst, lower scores are better, so rank 0 is the best response and rank n is the worst
649 if prev_status == 'rejected':
650 flat_data.append((example, example.generations[np.argmin(example.scores)], 'chosen'))
651 else:
652 flat_data.append((example, example.generations[np.argmax(example.scores)], 'rejected'))
653
654 prev_status = flat_data[-1][-1]
655
656 return flat_data
657
658
659class HalfPrefDataLoader(UnpairedPreferenceDataLoader):

Callers

nothing calls this directly

Calls 1

sampleMethod · 0.80

Tested by

no test coverage detected