huggingface / setfit

Efficient few-shot learning with Sentence Transformers
https://hf.co/docs/setfit
Apache License 2.0
2.24k stars 222 forks source link

Opset Issue while exporting to onnx #560

Open avinish1 opened 1 month ago

avinish1 commented 1 month ago

UnsupportedOperatorError: Exporting the operator 'aten::scaled_dot_product_attention' to ONNX opset version 12 is not supported. Support for this operator was added in version 14, try exporting with this version.

The following code is used

from setfit import SetFitModel
model = SetFitModel._from_pretrained("setfit_model/")

from setfit.exporters.onnx import export_onnx
output_path = "model.onnx"
export_onnx(model.model_body,
            model.model_head,
            opset=12,
            output_path=output_path)

Env:

torch = 2.4.1
setfit = 1.1.0
transformers = 4.45.1
onnxruntime = 1.19.2
onnx = 1.16.2

while trying to use opset version 14,

I get this error

UnsupportedOperatorError: Exporting the operator 'aten::scaled_dot_product_attention' to ONNX opset version 13 is not supported. Support for this operator was added in version 14, try exporting with this version.