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, }