huggingface / exporters

Export Hugging Face models to Core ML and TensorFlow Lite
Apache License 2.0
622 stars 46 forks source link

Error when transforming Roberta models #59

Closed Bathilde closed 1 year ago

Bathilde commented 1 year ago

Hello, I'm currently encountering an issue while transforming models using Roberta.

Roberta is a text classification model to evaluate emotions or if the content is hateful. So it is supposed to be a very simple text classification model.

I tried to use the exporter with the following models:

First I was using the web tool to transform directly the model, and I could only select the option "text-generation". When trying directly from the python tool, the following error is returned:

Traceback (most recent call last):
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/******/Documents/projects/Tests/exporters/src/exporters/coreml/__main__.py", line 178, in <module>
    main()
  File "/Users/******/Documents/projects/Tests/exporters/src/exporters/coreml/__main__.py", line 141, in main
    model_kind, model_coreml_config = FeaturesManager.check_supported_model_or_raise(model, feature=args.feature)
  File "/Users/******/Documents/projects/Tests/exporters/src/exporters/coreml/features.py", line 498, in check_supported_model_or_raise
    raise ValueError(
ValueError: roberta doesn't support feature text-classification. Supported values are: {'text-generation': functools.partial(<bound method CoreMLConfig.from_model_config of <class 'exporters.coreml.models.RobertaCoreMLConfig'>>, task='text-generation'), 'text-generation-with-past': functools.partial(<bound method CoreMLConfig.with_past of <class 'exporters.coreml.models.RobertaCoreMLConfig'>>, task='text-generation')}

If I understand correctly, all models are supposed to be trained and directly available to use. Am I missing a step or a configuration to make them work ?

Thank you.

Bathilde commented 1 year ago

I would like to apologies, I did not see the list of compatible models while reading the Readme. Since the Roberta model is for now indicated as "unknown" integration, my goal is to test them and try the integration on XCode directly. If the solution is working, I will open a pull request.

Thank you for all the work you did on that project.

pcuenca commented 1 year ago

Hi @Bathilde! No worries! Please, do let us know how it goes :)