What makes deployment hard?
One of the challenges of deployment is concenpt and data drift. Loosely, it means what if your data changes after your system has already been deployed?
Example: detecting scratches on smartphone manufacturing. You’ve trained the model on images with a certain lighting conditions but when deployed the images you receive have a different lighting condition (probably because the lighting in the factory changes).
Example: Speech recognition
It is important to recognize if the data has changed and if you need to update your learning algorithm as a result.
Data changes:
Concept drift: if the desired mapping changes.
- Example: before COVID-19 perhaps for a given user, a lot of surprising online purchases should have flagged that account for fraud. But after COVID started, maybe those same purchases would not have really been any cause for alaram.
- Example: Let’s say is the size of a house and is the home price. If because of inflation (or changes in the market), houses become more expensive over time, then the same size house will end up having higher price.
So, in concept drift refers to when from the mapping changes (i.e. the definition of what is given changes), whereas data drift refers to when the input data distribution, , changes (i.e. the distribution of changes). In example above, data drift would be that people start building houses in different sizes.
Note: When you deploy a ML system, one of the important tasks is to make sure you are able to detect and manages any changes to the data.
Let’s say you want to deploy a prediction service which receives and returns prediction . You have a lot of design choices as to how to implement this piece of software.
Here’s a checklist of questions to help you make appropriate decisions:
Note: Advantages of edge deployment vs cloud deployment
Note: One of the things you see when you’re building ML systems is that the practices for the very deployments will be quite different compared to when you’re updating or maintaining a system that has already been deployed. Deployment is not about getting to the finish line. First deployment is maybe just half of the way. The other half starts after your first deployment with tasks like feeding the data back and keep updating the model, or monitoring and managing possible concept or data drift cases.
Note: A full cycle of a ML project is an iterative process where during the later stage we might go back to an earlier stage.
Two key ideas and recurring themes here are:
People are inspecting smartphone for scratches. Now, you want to automate some of this work with a learning algorithm.
Note: When you have people initially doing a task, one common deployment pattern is shadow mode deployment:
The purpose of shadow mode deployment is that it allows you to gather data of how the learning algorithm is performing and how it compares to the human judgement. You can use that maybe to allow the ML take some real decisions in the future.
When you’re ready to let a ML system start making real decisions, a common deployment pattern is canary deployment.
In canary deployment:
Canary deployment allows to spot problems, hopefully, early on before there are maybe overly large consequences to a system.
Blue refers to the old version of your software and green is the new version. In blue green deployment, you have an old service (blue), you spin up a new service (green), and you’d have the router suddenly switch the traffic from the old one to the new one.
The advantage of this deployment method is that there’s an easy way to enable rollback. If something goes wrong, you can just very quickly have the router send the traffic back to the older system (assuming that you’ve kept the older version).
One of most useful frameworks on how to deploy a system is to think about deployment not as a 0, 1 i.e. either deploy or not deploy, but instead to design a system thinking about what is the appropriate degree of automation.
Example: in visual inspection of smartphones, here’s a range of automation you could have: