huggingface / optimum

🚀 Accelerate training and inference of 🤗 Transformers and 🤗 Diffusers with easy to use hardware optimization tools
https://huggingface.co/docs/optimum/main/
Apache License 2.0
2.55k stars 458 forks source link

NameError: name '_SENTENCE_TRANSFORMERS_TASKS_TO_MODEL_LOADERS' is not defined #1997

Open purejomo opened 2 months ago

purejomo commented 2 months ago

System Info

python 3.10.14
torch 2.4.0+cu121
optimum  1.21.4  
onnx                      1.16.2  
onnxruntime               1.19.0    
transformers              4.43.4  

optimum-cli export onnx --model distilbert/distilbert-base-uncased-distilled-squad distilbert_base_uncased_squad_onnx/

when I try to do simple example above, this error happened.

.../optimum/exporters/tasks.py", line 268, in TasksManager
"sentence_transformers": get_model_loaders_to_tasks(_SENTENCE_TRANSFORMERS_TASKS_TO_MODEL_LOADERS),
NameError: name '_SENTENCE_TRANSFORMERS_TASKS_TO_MODEL_LOADERS' is not defined

In "task.py" file, I touhgt _SENTENCE_TRANSFORMERS_TASKS_TO_MODEL_LOADERS is defined already.

image image

Who can help?

@philschmid @michaelbenayoun @JingyaHuang, @echarlaix

Information

Tasks

Reproduction (minimal, reproducible, runnable)

python 3.10.14 torch 2.4.0+cu121 optimum 1.21.4
onnx 1.16.2
onnxruntime 1.19.0
transformers 4.43.4

Expected behavior

error should be figured out. I'm trying to convert hf-llama model to onnx for graph optimization

echarlaix commented 2 months ago

Hi @purejomo,

I was unfortunately not able to reproduce the error you're describing. Yes _SENTENCE_TRANSFORMERS_TASKS_TO_MODEL_LOADERS is defined in https://github.com/huggingface/optimum/blob/v1.21.4/optimum/exporters/tasks.py#L201-L204, could it be that in your case is_torch_available https://github.com/huggingface/optimum/blob/v1.21.4/optimum/exporters/tasks.py#L156 returns False?