Feature request
TRL already documents the expected dataset type for each trainer in docs/source/dataset_formats.md, but that information is not exposed programmatically.
Today, downstream wrappers and validation layers have to hardcode trainer-name checks like if trainer_class is GRPOTrainer or maintain their own registry to figure out whether a trainer expects prompt-only, preference, prompt-completion, etc.
A small metadata API on trainer classes would solve this cleanly:
from trl import GRPOTrainer
GRPOTrainer.dataset_types == ("prompt-only",)
For trainers that support more than one type:
from trl import SFTTrainer
SFTTrainer.dataset_types == ("language-modeling", "prompt-completion")
Motivation
This would let wrappers, CLIs, and downstream libraries:
- validate datasets before trainer construction
- choose preprocessing paths without hardcoded class checks
- stay aligned with the dataset-type table already maintained in the docs
Why now
There seems to be recurring user and maintainer effort around trainer-specific dataset semantics and chat-template behavior, for example:
Those issues are not asking for this exact API, but they do show that trainer dataset semantics matter in practice and are currently discovered indirectly through docs or implementation details.
Proposed shape
Add a class attribute on trainers:
class _BaseTrainer(Trainer):
dataset_types: tuple[str, ...] = ()
Then set it on the trainers already covered by the dataset-format table.
This would be metadata only, with no behavior change.
Feature request
TRL already documents the expected dataset type for each trainer in
docs/source/dataset_formats.md, but that information is not exposed programmatically.Today, downstream wrappers and validation layers have to hardcode trainer-name checks like
if trainer_class is GRPOTraineror maintain their own registry to figure out whether a trainer expectsprompt-only,preference,prompt-completion, etc.A small metadata API on trainer classes would solve this cleanly:
For trainers that support more than one type:
Motivation
This would let wrappers, CLIs, and downstream libraries:
Why now
There seems to be recurring user and maintainer effort around trainer-specific dataset semantics and chat-template behavior, for example:
apply_chat_templatebehaviour for multimodal dataset between SFT and GRPO #3915SFTTrainerinGRPOTrainer#3919Those issues are not asking for this exact API, but they do show that trainer dataset semantics matter in practice and are currently discovered indirectly through docs or implementation details.
Proposed shape
Add a class attribute on trainers:
Then set it on the trainers already covered by the dataset-format table.
This would be metadata only, with no behavior change.