This post was written with the help of our Engineering Intern, Matan Broner.
One of the primary reasons Fiddler’s Model Performance Monitoring (MPM) Platform is loved and trusted by customers is because of its versatile integration that simply plugs in and starts producing insights. In this post, we discuss how Fiddler uses ONNX to support various model frameworks and versions, seamlessly.
Fiddler’s MPM Platform provides robust machine learning model monitoring for companies of all sizes. In fact, the platform addresses the four major challenges of current machine learning operations:
- Transparency: Many businesses struggle to maximize the benefit of ML models because they cannot explain or open up black box models.
- Drift: ML models are unique because they continue to work regardless of the shift, or drift, in the data which can cost millions of dollars if not handled appropriately (as we saw during the recent pandemic).
- Bias: Due to the lack of awareness, process, and tooling, some businesses unknowingly, or knowingly, use biased datasets that do not offer fair opportunities to all customers or end-users.
- Compliance: More industries are seeing additional regulations and compliance requirements on ML models to ensure responsible use.
As we continue our customer growth, we encountered more diverse model frameworks and versions. And to complicate things further, this problem was rampant inside individual organizations. Due to the lack of a centralized discipline, different teams inside an organization were using different model frameworks and versions that were ideal for their individual use case. As a result, when it was time to scale and establish a centralized model monitoring solution, their options were limited. This is where Fiddler comes in. Fiddler’s mission is to empower every organization to build trust and reliability in AI. In order to do so, our platform provides simple integration for any organization to plug their data and models in and get immediate actionable insights.
Fiddler is a pluggable platform that works with any model framework and data source. However, AI/ML models have framework compatibility issues. For example, a sales team might use a ScikitLearn model to predict the likelihood of a deal to close, while a marketing team might use a Tensorflow model to predict customer segments. As you can see, things can get complicated fast for a platform to handle or support all packages. This is where ONNX comes in. Regardless of the framework - Tensorflow, PyTorch, or ScikitLearn, ONNX serves as a middle ground between Fiddler’s MPM platform and its customers by converting and creating a uniform model type for the Fiddler platform to ingest. As a result, Fiddler users can easily plug in their models to Fiddler’s platform and enjoy all the robust features. On the Fiddler side, it accelerates our backend to ingest the model and provide a seamless user experience in monitoring services and AI explainability functionality.
How does Fiddler work with ONNX?
We will go over an example we created using our Quickstart that builds a ScikitLearn model. Following the steps, we will load all the libraries, connect with the Fiddler client, and upload the baseline dataset. Before we register our model, we need a few extra steps, starting with creating a basic sklearn pipeline. We will also train a gradient boosting model.
Once the model is trained, we will use the skl2onnx package to convert the data types first.
And convert the model to ONNX.
The way Fiddler’s MPM platform is able to interface with an ingested model is via a package.py. At a high level, Fiddler gets a handle to the model object via get_model() method and calls predict() with a dataframe as input. In this case, as the model is ONNX serialized, the model is loaded into the onnxruntime, and when the user wants to explain a specific prediction using Fiddler, the data is input to the model handle from package.py. The incoming pandas dataframe is transformed into the format expected by the user as a part of the predict() and then the inference is run via the run() and the output is piped back to Fiddler for the rest of the workflows. With this simple modification, the prediction pipeline is created in the backend, and a user won’t see any difference in our UI. Everything will be very smooth and easily controllable.
A quick sanity check with our validator would also come in handy.
With everything checked, the final step is to upload the model and predictions to the project.
At this point, the backend work is done. Now the dataset, model, and predictions will all be visible on our platform, ready for users to analyze predictions and get explanations using our All-purpose Explainable AI technology. In fact, a user will see no difference between the ONNX and ScikiLearn models on our platform. It will be a seamless, simple, and easy experience.
Next Steps for Fiddler + ONNX
As demonstrated, Fiddler’s MPM is a flexible platform that can work with any model framework and version by utilizing ONNX. We plan to build automating the model conversions, with support for more model types, so it becomes a much easier integration for users.