Using decoder only part of pretrained MarianMT (Encoder-Decoder Translation model)


I’m trying to use the decoder only half of a pretrained MariantMT model. I could use the following to get the model loss for training the decoder only half while using my own encoder outputs:
output = self.model(input_ids=None, encoder_outputs=(encoded_sequence,), labels=targets, output_attentions=False, return_dict=True)

This gives me the loss and logits. But I’m not sure how to integrate the generate function into this. Can someone please help me with the same?

Also curious about this