Download DS_generation/search_ex.py from MSkilll/Etra: direct link, hf CLI and curl.
- Browser
- Download file 595 Bytes
-
https://huggingface.co/MSkilll/Etra/resolve/main/DS_generation/search_ex.py
- Command line
-
hf download hf://MSkilll/Etra/DS_generation/search_ex.py
-
curl -L -o search_ex.py https://huggingface.co/MSkilll/Etra/resolve/main/DS_generation/search_ex.py
595 Bytes
| # make_search_data.py | |
| import json, os | |
| from pathlib import Path | |
| from datasets import load_dataset | |
| D = Path("/content") if os.path.exists("/content") else Path(__file__).parent.absolute() | |
| tq = load_dataset("mandarjoshi/trivia_qa", "rc.nocontext", split="train") | |
| tq = tq.shuffle(seed=42).select(range(15000)) | |
| search_ex = [ | |
| {"instruction": ex["question"], "input": "", | |
| "output": f"[SEARCH] {ex['question']}"} | |
| for ex in tq | |
| ] | |
| with open(D / "search_ex.json", "w", encoding="utf-8") as f: | |
| json.dump(search_ex, f) | |
| print(len(search_ex), "->", D / "search_ex.json") |