Karim Fayed
Karim Fayed

Reputation: 69

PEGASUS From pytorch to tensorflow

I have fine-tuned PEGASUS model for abstractive summarization using this script which uses huggingface. The output model is in pytorch.

Is there a way to transorm it into tensorflow model so I can use it in a javascript backend?

Upvotes: 0

Views: 427

Answers (1)

dennlinger
dennlinger

Reputation: 11488

There are several ways in which you can potentially achieve a conversion, some of which might not even need Tensorflow at all.

Firstly, the way that does what you intend to do: PEGASUS seems to be completely based on the BartForConditionalGeneration model, according to the transformer implementation notes. This is important, because there exists a script to convert PyTorch checkpoints to TF2 checkpoints. While this script does not explicitly allow you to convert a PEGASUS model, it does have options available for BART. Running it with the respective parameters should give you the desired output.

Alternatively, you can potentially achieve the same by exporting the model into the ONNX format, which also has JS deployment options. Specific details for how to convert a Huggingface model to ONNX can be found here.

Upvotes: 1

Related Questions