[Tensorflow Export] How to export a fine tuned GPT2 model to a tensorflow model file?

Sorry if this is a silly question, but I cant seem to find any proper solution to this.

I am using transformers==2.8.0 and have fine-tuned a gpt2 model with my own dataset. I know that during training it creates checkpoints in pytorch and that can be used for text generation, but I want to save/load model in tensorflow.

I know that TFGPT2LMHeadModel exists and that it can be used, but I havent found an example online doing this.

Can someone help me please? How can I export a fine-tuned model into tensorflow, so that I can then generate text using that model?

Thanks

You can check this part of the docs that shows how to reload a model trained with PyTorch into TensorFlow (and vice versa).

1 Like