-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ONNX conversion #181
Comments
I went through most of the sklearn-onnx docs (which I often found confusing) and have to say this looks to be more difficult than I initially expected. There seem to be many missing pieces, pitfalls, specific adjustments that have to be made to models and pipelines, many of which are not trivially automated. As an example, if I understand correctly, the onnx runtime doesn't support sparse matrices yet (https://onnx.ai/sklearn-onnx/auto_tutorial/plot_usparse_xgboost.html#tfidf-and-sparse-matrices), so most of text classification/regression will only work with small data, since converting to dense would be too expensive otherwise. And as soon as users have custom estimators, automatic conversion is basically impossible. Maybe we can first start with supporting inference of ONNX models but require users to do the conversion themselves? What would be the main benefits of ONNX anyway? Is it for efficiency or for security? |
We can start with a utility which tries to convert models, and it might fail on any complex case, and then improve that over time. I suspect a good part of that might later end up in the I don't think we have to worry about using onnx in inference time much yet, the value here is more about people not having to load pickles rather than us not doing that. We're also not really focusing on the performance of the inference API ATM, so thta's not an issue yet. People might like if for efficiency or security, but they like it. |
Despite whether Now let's imagine the following use-case:
Here it's a question to my understanding of Also, introducing the model Intermediate Representation (IR) from scratch in |
Your app would most likely not break because sklearn rarely makes backwards incompatible changes. However, sklearn doesn't go so far as to guarantee it will never do that, which is why you would generally get a warning if you load an sklearn model using a different sklearn version. To give a hypothetical example, in version 1.2.0, sklearn could add a new attribute Coming to the second part of your question, the main objective of the skops persistence format is to present a secure alternative to pickle for the sklearn ecosystem. If this is not clear from our docs, please let us know and we can clarify. Regarding the specific comparison to ONNX, the goals are quite different. For skops, we have:
For ONNX, we have:
There are more differences of course, this is just from the top of my head. |
Many thanks for clarifying the borders! Indeed then, users can use both |
We should have convenience methods to convert scikit-learn fitted models to ONNX, and have easy ways to check if a model can be converted to ONNX.
The https://github.com/onnx/sklearn-onnx project as well as https://github.com/sdpython/mlprodict/ are where we can start to see how to implement these features.
Once this is in place, we can think of ways to automatically do the conversion, if possible, on the hub side.
The text was updated successfully, but these errors were encountered: