| 56 | |
| 57 | |
| 58 | class TextPromptDataset(Dataset): |
| 59 | def __init__(self, dataset_path, split="test"): |
| 60 | self.file_path = os.path.join(dataset_path, f"{split}.txt") |
| 61 | if not os.path.exists(self.file_path): |
| 62 | raise FileNotFoundError(f"Dataset file not found at {self.file_path}") |
| 63 | with open(self.file_path, "r") as f: |
| 64 | self.prompts = [line.strip() for line in f.readlines()] |
| 65 | |
| 66 | def __len__(self): |
| 67 | return len(self.prompts) |
| 68 | |
| 69 | def __getitem__(self, idx): |
| 70 | return {"prompt": self.prompts[idx], "metadata": {}, "original_index": idx} |
| 71 | |
| 72 | |
| 73 | class GenevalPromptDataset(Dataset): |