Deploying Machine Learning Models in Production: Beyond the Thrill

Deeraj Manjaray
3 min readDec 27, 2023

--

Flight Monitoring Operational Performance

Deploying a machine learning model in production is a crucial step, but it doesn’t end there. Just like a pilot needs to monitor instruments for a successful flight, data and machine learning engineers need to track key metrics to ensure their models thrive in production. These metrics act as your radar, guiding you towards peak performance and avoiding crashes.

Monitoring Operational Performance

Here is the big deal, Data Engineers and Machine Learning Engineers must vigilantly look at the categories such as stability and reliability, operations, monitoring, etc. Many metrics are vital signs of your model’s health.

In this blog, We will talk about monitoring fuel efficiency i.e., resource utilization, Graphical Processing Unit (GPU), and memory usage is one of them. Then, latency — how quickly the model processes inputs and generates output. Both come under the category of Performance.

Let’s explore two critical metrics in Performance of a Model:

  1. Latency: How quickly your model processes inputs and generates outputs. Ideally, this should be minimal, especially for real-time applications like recommendation engines.
  2. Model Size: This directly impacts deployment feasibility. Larger models might require more storage and computing power, making them costly and less scalable.

Model Compression Methods:

To address the challenges associated with large model sizes and high latency, several model compression techniques can be implemented. These methods serve to enhance latency and size metrics without causing a substantial compromise in accuracy:

Pruning: This method is mostly used in tree-based and Neural Network algorithms. In tree-based ones, we prune leaves or branches from decision trees. In Neural Networks, we remove nodes and synapses (weights) while trying to retain ML performance metrics.

In both cases, the output is a reduction in the number of Model Parameters and model size.

Explaining weight and Neuron pruning

Knowledge Distillation: This type of compression is achieved by:

  • Training an original large model which is called the Teacher model.
  • Training a smaller model to mimic the Teacher model by transferring knowledge from it, this model is called the Student model.
  • Knowledge in this context can be extracted from the outputs, internal hidden state (feature representations), or a combination of both.
  • We then use the “Student” model in production.
Knowledge Distillation

Quantization: A most commonly used method that doesn’t have much to do with Machine Learning. This approach uses fewer bits to represent model parameters.

  • You can apply quantization techniques both during the training and after the model has been already trained.
  • In regular Neural Networks what is quantized are Model Weights, Biases, and Activation Functions.
  • Most usual quantization is from float to integer (32 bits to 8 bits).
Quantization

Remember: While these methods reduce size, they can also impact accuracy. Always evaluate the trade-off and careful evaluation is crucial before deployment.

Conclusion:

Deploying machine learning models in production is a multifaceted challenge. Balancing resource utilization, latency, and model size requires a thoughtful approach. By leveraging compression methods, engineers can optimize models for operational performance without compromising accuracy. As the field evolves, staying attuned to advancements in deployment strategies will be key to navigating the ever-changing landscape of machine learning in production.

Thank you for taking the time to read! Your feedback is most welcome!

Hope this helps! Feel free to let me know if this post was useful. 😃

Hungry for AI? Bite-sized brilliance awaits! ⚡

🔔 Follow Me: LinkedIn | GitHub | Twitter

Buy me a coffee:

--

--

Deeraj Manjaray

Machine Learning Engineer focused on building technology that helps people around us in easy ways. Follow : in.linkedin.com/in/deeraj-manjaray