Open fxmarty opened 2 years ago
Thanks for creating this detailed issue @fxmarty!
One challenge with unifying the "features" used in the ONNX export and the tasks defined in the pipeline()
function is that one can have past key values that need to be differentiated, e.g. these two features are different:
causal-lm
causal-lm-with-past
Having said that, I agree that it would be nice if one could reuse the same task taxonomy from the transformers.pipeline()
function, so maybe some light refactoring can capture the majority of tasks.
cc @michaelbenayoun who knows more of the history behind the ONNX "features" names
Yes, I think the original feature names were chosen by looking at the classes names (BertForSequenceClassification
, etc). I think @fxmarty's first suggestion could work and is easy to implement.
Currently, transformers'
FeaturesManager._TASKS_TO_AUTOMODELS
to handle strings passed to load models. Notably, this is used in theORTQuantizer.from_pretrained()
method (where here, for example,feature="sequence-classification"
):https://github.com/huggingface/optimum/blob/5653a16727fc99b627d45827485b2ac0ace4c66f/optimum/onnxruntime/quantization.py#L102
In the meanwhile, pipeline abstraction for text classification expects
pipeline(..., task="text-classification")
. Hence it could be troublesome for users to pass both"text-classification"
and"sequence-classification"
.A handy workflow could be the following:
which currently raises
KeyError: "Unknown task: text-classification
forORTQuantizer.from_pretrained()
.Right now we need to pass something like
and provide the
feature
toORTQuantizer
, which is troublesome.Possible solutions are:
"text-classification" --> "sequence-classification"
,"audio-classification" --> "sequence-classification"
)transformers.onnx.FeaturesManager
to use real tasks and not "sequence-classification"ForTextClassification
,ForAudioClassification
classes just inheriting fromForSequenceClassification
and modifytransformers.onnx.FeaturesManager
accordingly@lewtun