How to find the path of a model?

I access a specific model with this code:

model = GPT2LMHeadModel.from_pretrained('gpt2-xl')

I would like to export this model to ONNX using the Optimum utility. But this utility requires the model ID on hugging face. Here is the syntax. How do I find the ID? Thanks.

optimum-cli export onnx --model <model ID on hugging face>

Wouldn’t it just be gpt2-xl in this case?

optimum-cli export onnx --model gpt2-xl

That works, but it will use the base model of gpt2-xl. What I want is the model with the language modeling head (GPT2LMHeadModel). Using the name of the language modeling head in the optimum command does not work.

I’ve come up with a bypass. Download the model to my local drive, and then use optimum to point to the model file.

@runski I see, in that case you can specify the task the CLI with the --task arg to make sure it’s the version with the LM head. E.g.,

optimum-cli export onnx --model gpt2-xl --task text-generation

or

optimum-cli export onnx --model gpt2-xl --task text-generation-with-past

There’s also a table here that shows which HF classes the different “tasks” map to with the optimum CLI

It’s not obvious --text generation maps to LMHead. I wish the documentation is clear about it.