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

**URL:** <https://discuss.huggingface.co/t/tensorflow-export-how-to-export-a-fine-tuned-gpt2-model-to-a-tensorflow-model-file/3207>\
**Category:** Beginners\
**Created:** [January 14, 2021, 11:25pm UTC](https://discuss.huggingface.co/t/tensorflow-export-how-to-export-a-fine-tuned-gpt2-model-to-a-tensorflow-model-file/3207 "2021-01-14T23:25:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![farazk86](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/farazk86/32/922_2.png) [@farazk86](https://discuss.huggingface.co/u/farazk86)\
**Post date:** [January 14, 2021, 11:25pm UTC](https://discuss.huggingface.co/t/tensorflow-export-how-to-export-a-fine-tuned-gpt2-model-to-a-tensorflow-model-file/3207/1 "2021-01-14T23:25:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sgugger](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/sgugger/32/2291_2.png) [@sgugger](https://discuss.huggingface.co/u/sgugger)\
**Post date:** [January 15, 2021, 2:20pm UTC](https://discuss.huggingface.co/t/tensorflow-export-how-to-export-a-fine-tuned-gpt2-model-to-a-tensorflow-model-file/3207/2 "2021-01-15T14:20:23Z")

</div>

You can check [this part of the docs](https://huggingface.co/transformers/model_sharing.html#make-your-model-work-on-all-frameworks) that shows how to reload a model trained with PyTorch into TensorFlow (and vice versa).
