Converting GPT2 to JavaScript?

hey @TristanBehrens, your approach sounds sensible (although i don’t know anything about the TF → TFJS step). to load the pytorch model in tf, you’ll just need to add a from_pt=True argument, e.g.

tf_model = TFDistilBertForSequenceClassification.from_pretrained("path/to/pytorch-model", from_pt=True)

an alternative would be to use onnx as the intermediate representation (see here for the export), but your approach seems simpler :slight_smile: