| mport os |
| import json |
| from datasets import DatasetInfo, GeneratorBasedBuilder, SplitGenerator, Split |
|
|
| class AReaLBoba2RLCode(GeneratorBasedBuilder): |
| VERSION = "1.0.0" |
|
|
| def _info(self): |
| return DatasetInfo( |
| description="AReaL-boba-2-RL-Code dataset (only train split)", |
| features={ |
| "input": {"dtype": "string", "id": None}, |
| "output": {"dtype": "string", "id": None}, |
| }, |
| supervised_keys=None, |
| ) |
|
|
| def _split_generators(self, dl_manager): |
| data_dir = dl_manager.download_and_extract(self.config.data_dir or ".") |
| train_path = os.path.join(data_dir, "train", "train.jsonl") |
|
|
| return [ |
| SplitGenerator( |
| name=Split.TRAIN, |
| gen_kwargs={"filepath": train_path}, |
| ), |
| ] |
|
|
| def _generate_examples(self, filepath): |
| with open(filepath, encoding="utf-8") as f: |
| for idx, line in enumerate(f): |
| if not line.strip(): |
| continue |
| data = json.loads(line) |
| yield idx, { |
| "input": data.get("input", ""), |
| "output": data.get("output", ""), |
| } |
|
|