ONNX model created with Optimum is not compatible with Transformers.js
Using the currently latest version of Optimum, 1.18.0, I was able to convertsentence-transformers/all-MiniLM-L6-v2into an ONNX model:optimum-cli export onnx --task sentence-similarity --optimize O2 -m sentence-transformers/all-MiniLM-L6-v2 $(pwd)/models/all-MiniLM-L6-v2/onnxWhen trying to use the resulting model with the currently latest version of Transformers.js, 2.16.1, I get this error message:Error: Failed to load model with error: /onnxruntime_src/onnxruntime/core/graph/model_load_utils.h:46 void onnxruntime::model_load_utils::ValidateOpsetForDomain(const std::unordered_map<std::basic_string<char>, int>&, const onnxruntime::logging::Logger&, bool, const string&, int) ONNX Runtime only *guarantees* support for models stamped with official released onnx opset versions. Opset 4 is under development and support for this is limited. The operator schemas and or other functionality may change before next ONNX release and in this case ONNX Runtime will not guarantee backward compatibility. Current official support for domain ai.onnx.ml is till opset 3optimum-cli export onnxsupports an--opsetargument, but that seems to only control the opset for theai.onnxdomain, not theai.onnx.mldomain. When I inspect my onnx model using Netron, I see thatai.onnx.mlis indeed v4, which the error message complains is greater than the max. 3. Looking atonnx/docs/Versioning.md at main · onnx/onnx · GitHub, the lastonnxversion to not support version 4 forai.onnx.mlwas 1.14.1. I’m not sure if the versioning between onnx and onnxruntime-node is in sync, but Transformers.js uses onnxruntime-node 1.14, which is over a year old.Basically, my conclusion is that Transformers.js lags far behind Optimum when it comes to the ONNX support and that they are therefore not compatible. It seems strange that that would be the case though, not least because one of the first things stated onTransformers.jsis“Transformers.js uses ONNX Runtime to run models in the browser. The best part about it, is that you can easily convert your pretrained PyTorch, TensorFlow, or JAX models to ONNX usingOptimum.”So maybe I’m missing something. How can I convert a model to ONNX and use it with Transformer.js?