Types of model deployment
There are various ways to deploy ML models into production; however, there is no generic way to do it. This section will walk you through popular ways to deploy ML models.
Batch predictions
This is the simplest method. Here, the ML model is trained on static data to make predictions, which are saved in the database, such as MS-SQL, and can be integrated into existing applications or accessed by the business intelligence team
Generally, ML model artifacts are used for making predictions as it saves time. Model artifact needs to be updated on new data for better predictions
This method is well-suited for small organizations and beginners. You can schedule the cron job to make predictions after certain time intervals.
Pros
- Affordable
- Less complex
- Easy to implement
Cons
- Moderate latency
- Not suitable for ML-centric organizations
Web service/REST API
Web service/REST API is the popular method for deploying models. Unlike batch predictions, it does not process a bunch of records; it processes a single record at a time. In near real-time, it takes the parameters from users or existing applications and makes predictions
It can take inputs as well as return the outputs in JSON format. JSON is a popular and compatible format that makes it easy for software or website developers to integrate it into existing applications.
When an event gets triggered, REST API passes the input parameters to the ML model and returns the predictions.
Pros
- Easy to integrate
- Flexible
- Economical (pay-as-you-go plan)
- Near real-time predictions
Cons
- Scalability issues
- Prone to security threats
Mobile and edge devices
When there are situations such as actions/ decisions that need to be taken immediately or there is no internet connectivity, the ML model needs to be deployed on these devices
Edge devices include sensors, smartwatches, and cameras installed on robots
This type of deployment is different from the preceding methods. In this, input data may not go to remote servers for making predictions
This type of deployment is different from the preceding methods. In this, input data may not go to remote servers for making predictions. There are cloud service providers, such as Microsoft Azure, that offer the required infrastructure for this. Tiny Machine Learning (TinyML) is another such alternative capable of performing on-device sensor data analytics at an extremely low power
ML models deployed on mobile devices are useful. Developing ML-based android / IOS applications, such as voice assistant or camera image-based attendance, are use cases of ML models deployed on mobiles.
Pros
- Low power requirement
- Cost-effective
- Smaller sizes
Cons
- Limited hardware resource
- A complex and tedious process
Real time
- Here, analysis is to be done on streaming data. In this approach, the user passes input data for prediction and expects (near) real-time prediction. This is quite a challenging approach compared to the ones you studied previously.
- You can decrease the latency of the predictions by small-sized models, caching predictions, No-SQL databases, and so on.
Pros
- Very low to no latency
- Can work with streaming data
Cons
- Complex architecture requirements
- Computationally expensive