Download python_lora_dataset_builder/pipeline/source_loader.py from api-relay/sadASDasd: direct link, hf CLI and curl.
- Browser
- Download file 897 Bytes
-
https://huggingface.co/datasets/api-relay/sadASDasd/resolve/main/python_lora_dataset_builder/pipeline/source_loader.py
- Command line
-
hf download hf://datasets/api-relay/sadASDasd/python_lora_dataset_builder/pipeline/source_loader.py
-
curl -L -o source_loader.py https://huggingface.co/datasets/api-relay/sadASDasd/resolve/main/python_lora_dataset_builder/pipeline/source_loader.py
897 Bytes
| from __future__ import annotations | |
| from datasets import load_dataset | |
| def stream_hf_dataset(name: str, split: str = "train"): | |
| """Stream records so the first test does not download the full dataset.""" | |
| return load_dataset(name, split=split, streaming=True) | |
| def normalize_source_row(row: dict, source_name: str, row_index: int, | |
| instruction_field: str = "instruction", | |
| input_field: str = "input", | |
| output_field: str = "output") -> dict: | |
| return { | |
| "record_id": f"{source_name.replace('/', '__')}__{row_index:08d}", | |
| "source": {"dataset": source_name, "row": row_index}, | |
| "instruction": str(row.get(instruction_field, "") or "").strip(), | |
| "input": str(row.get(input_field, "") or "").strip(), | |
| "output": str(row.get(output_field, "") or "").strip(), | |
| "raw_row": row, | |
| } | |