Using GRPOTrainer with a custom PyTorch module?

Hello! I was wondering what changes I would need to make to use GRPOTrainer with a custom PyTorch module class.

Currently I have an nn.Module subclass that wraps around an existing Huggingface transformer, except with a custom forward and generate function.

I was wondering though if there were resources on either converting an nn.Module to a transformer to be used with Trainer, or what other functionality I would need to implement as well as changes I’d need to make to my forward and generate methods to work with

1 Like

If you inherit PreTrainedModel, you should have most of the necessary functions. As for Trainer, it seems that you can modify loss functions, gradient-related functions, and so on.