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)
| 632 | |
| 633 | class 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 | |
| 659 | class HalfPrefDataLoader(UnpairedPreferenceDataLoader): |