| #!/usr/bin/env python3 | |
| """Extract a seeded-random 400-task subset of HellaSwag matching GPTQModel's selection.""" | |
| import random | |
| import sys | |
| from pathlib import Path | |
| SEED = 1 | |
| N_SAMPLES = 400 | |
| LINES_PER_TASK = 6 | |
| def main(): | |
| root = Path(__file__).resolve().parent.parent | |
| full_path = root / "hellaswag_val_full.txt" | |
| out_path = root / "hellaswag_val_400.txt" | |
| lines = full_path.read_text().splitlines() | |
| n_tasks = len(lines) // LINES_PER_TASK | |
| indices = list(range(n_tasks)) | |
| rng = random.Random(SEED) | |
| rng.shuffle(indices) | |
| selected = indices[:N_SAMPLES] | |
| with open(out_path, "w") as f: | |
| for idx in selected: | |
| start = idx * LINES_PER_TASK | |
| for line in lines[start:start + LINES_PER_TASK]: | |
| f.write(line + "\n") | |
| print(f"Wrote {N_SAMPLES} tasks to {out_path}") | |
| if __name__ == "__main__": | |
| main() | |