Return a flat list of examples given a list of prompts.
(self, prompts)
| 693 | Dataloader for losses that do require pairwise preferences (e.g., DPO). |
| 694 | """ |
| 695 | def get_flat_data(self, prompts): |
| 696 | """ |
| 697 | Return a flat list of examples given a list of prompts. |
| 698 | """ |
| 699 | flat_data = [] |
| 700 | |
| 701 | for prompt in prompts: |
| 702 | example = self.full_data[prompt] |
| 703 | |
| 704 | if self.max_prompt_count: |
| 705 | example.pairs = self.rng.sample(example.pairs, min(self.max_prompt_count, len(example.pairs))) |
| 706 | |
| 707 | for pair in example.pairs: |
| 708 | flat_data.append((example, pair)) |
| 709 | |
| 710 | return flat_data |
| 711 | |
| 712 | def __iter__(self): |
| 713 | epoch_idx = 0 |