View on GitHub
"```python\nfrom modal_training_gym.common.dataset import HuggingFaceDataset\n```\n\nDataset backed by a HuggingFace `datasets` repo.\n\nSubclass and set `hf_repo` plus column mappings. When\n`input_column` and `output_column` are set, `prepare()` wraps\neach row into a prompt-only chat message list plus a separate label\nfield: `{\"messages\": [{\"role\": \"user\", ...}], <label_key>: ...}`.\nA leading `{\"role\": \"system\", ...}` message is included when\n`system_prompt` is set. No assistant turn is emitted — the target\nfrom `output_column` is stored under `label_key`.\n\n**Inherits from:** `DatasetConfig`\n\n## Fields\n\n| Field | Type | Default | Description |\n|-------|------|---------|-------------|\n| `dataset_id` | `str` | `\"\"` | |\n| `input_key` | `str` | `\"\"` | |\n| `label_key` | `str` | `\"label\"` | |\n| `apply_chat_template` | `bool` | `True` | |\n| `always_prepare` | `bool` | `False` | |\n| `writes_eval_paths` | `bool` | `True` | |\n| `hf_repo` | `str` | `\"\"` | |\n| `hf_split` | `str` | `\"train\"` | |\n| `hf_config` | `str \\| None` | `None` | |\n| `output_format` | `str` | `\"parquet\"` | |\n| `input_column` | `str` | `\"\"` | |\n| `output_column` | `str` | `\"\"` | |\n| `system_prompt` | `str` | `\"\"` | |\n| `prompt_template` | `str` | `\"{input}\"` | |\n| `n_rows` | `int` | `0` | |\n\n## Methods\n\n### `load(self, split: \"Literal['all', 'train', 'eval']\" = 'all') -> 'Any'`\n\nLoad raw examples, optionally filtered by split.\n\n### `prepare(self, path: 'str', eval_paths: 'dict[str, str] | None' = None) -> 'None'`\n\nMaterialize training data to `path` (and eval splits to `eval_paths`).\n\n### `to_pandas(self, *, formatted: 'bool' = False)`\n\n### `validate_prepared(self, path: 'str') -> 'None'`\n\nSniff what `prepare()` wrote and confirm the columns the framework will index.\n\n## Related Tutorials\n\n- [DAPO on math with Qwen3-4B](/tutorials/rl/005_dapo/)\n- [Sweep hyperparameters across runs with TrainingGroup](/tutorials/rl/007_param_sweep/)\n\n**Source:** [`modal_training_gym/common/dataset.py`](https://github.com/modal-projects/training-gym/blob/main/modal_training_gym/common/dataset.py)\n"
HuggingFaceDataset
Dataset backed by a HuggingFace datasets repo.
from modal_training_gym.common.dataset import HuggingFaceDatasetDataset backed by a HuggingFace datasets repo.
Subclass and set hf_repo plus column mappings. When
input_column and output_column are set, prepare() wraps
each row into a prompt-only chat message list plus a separate label
field: {"messages": [{"role": "user", ...}], <label_key>: ...}.
A leading {"role": "system", ...} message is included when
system_prompt is set. No assistant turn is emitted — the target
from output_column is stored under label_key.
Inherits from: DatasetConfig
Fields
Section titled “Fields”| Field | Type | Default | Description |
|---|---|---|---|
dataset_id | str | "" | |
input_key | str | "" | |
label_key | str | "label" | |
apply_chat_template | bool | True | |
always_prepare | bool | False | |
writes_eval_paths | bool | True | |
hf_repo | str | "" | |
hf_split | str | "train" | |
hf_config | str | None | None | |
output_format | str | "parquet" | |
input_column | str | "" | |
output_column | str | "" | |
system_prompt | str | "" | |
prompt_template | str | "{input}" | |
n_rows | int | 0 |
Methods
Section titled “Methods”load(self, split: "Literal['all', 'train', 'eval']" = 'all') -> 'Any'
Section titled “load(self, split: "Literal['all', 'train', 'eval']" = 'all') -> 'Any'”Load raw examples, optionally filtered by split.
prepare(self, path: 'str', eval_paths: 'dict[str, str] | None' = None) -> 'None'
Section titled “prepare(self, path: 'str', eval_paths: 'dict[str, str] | None' = None) -> 'None'”Materialize training data to path (and eval splits to eval_paths).
to_pandas(self, *, formatted: 'bool' = False)
Section titled “to_pandas(self, *, formatted: 'bool' = False)”validate_prepared(self, path: 'str') -> 'None'
Section titled “validate_prepared(self, path: 'str') -> 'None'”Sniff what prepare() wrote and confirm the columns the framework will index.