Principle:Eric mitchell Direct preference optimization Dataset Registration
| Knowledge Sources | |
|---|---|
| Domains | Data_Engineering, Software_Engineering, Extensibility |
| Last Updated | 2026-02-08 02:00 GMT |
Overview
A dispatcher pattern that routes dataset names to their corresponding loader functions and validates that the loaded data conforms to the canonical format.
Description
Dataset registration is the mechanism by which named datasets are mapped to their loader functions. The get_dataset function acts as a simple if/elif dispatcher that:
- Accepts a dataset name string
- Calls the corresponding loader function (get_hh, get_shp, get_se, or a custom loader)
- Validates the returned data has exactly the required keys: {responses, pairs, sft_target}
- Returns the validated data
To add a new dataset, users add a new elif branch to the dispatcher and implement a corresponding loader function following the canonical format.
Usage
Use this principle when integrating a new preference dataset into the training pipeline. After implementing a loader function following the canonical format, register it in get_dataset.
Theoretical Basis
The dispatcher pattern provides a simple extensibility mechanism. The assertion-based validation at the integration point ensures that all datasets conform to the required contract, catching format errors early before they propagate to the training loop.
Pseudo-code:
# Abstract dispatcher (NOT actual implementation)
def get_dataset(name):
if name == 'hh': data = get_hh()
elif name == 'shp': data = get_shp()
elif name == 'xyz': data = get_xyz() # new dataset
else: raise ValueError()
assert keys == {'responses', 'pairs', 'sft_target'}
return data