machine learning in production
TRANSCRIPT
![Page 1: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/1.jpg)
RunningMachine Learning Applications
In Production
Sam BESSALAH@samklr
![Page 2: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/2.jpg)
![Page 3: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/3.jpg)
![Page 4: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/4.jpg)
![Page 5: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/5.jpg)
Might Works well for KAGGLE!
![Page 6: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/6.jpg)
Might Works well for KAGGLE!But Kaggle isn’t real world Machine
learning!
![Page 7: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/7.jpg)
![Page 8: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/8.jpg)
In Real Life
- Trade off : Accuracy vs Interpretability cs Speed vs Infrastructure contraints
- Interpretability and Speed often beats accuracy
- Most of the time Kaggle is a feature engineering contest
- Contest oriented vs Real Product Impact
![Page 9: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/9.jpg)
But in real life … Things are less obvious
Data Engineers
Data Pipeline
Data Scientists / ML Engineers
APP
Applications Developers
![Page 10: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/10.jpg)
But in real life … Things are less obvious
Data Engineers
Data Pipeline
Data Scientists / ML Engineers
APP
Applications Developers
Innovation is often (wrongly ?) thought to be here ...
![Page 11: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/11.jpg)
http://www.slideshare.net/jssm1th/an-architecture-for-agile-machine-learning-in-realtime-applications
![Page 12: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/12.jpg)
![Page 13: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/13.jpg)
@josh_wills
![Page 14: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/14.jpg)
josh_wills
![Page 15: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/15.jpg)
![Page 16: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/16.jpg)
Production Requirements :
- Flexibility and agility
- Scalability and Performance
- Enable Real time decision making, sometimes at huge QPS at subseconds pace.
- Security
![Page 17: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/17.jpg)
![Page 18: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/18.jpg)
josh_wills
![Page 19: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/19.jpg)
![Page 20: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/20.jpg)
Machine Learning as a Software Problem
- Most ML developement patterns lead to software design anti patterns
- Dependencies in code, creeps through Models dependencies in Data
- Wasteful use of data, since most ml model selection require multiple version of data. Hence the instability of data, and of prediction services
- Breaks system isolation, leading to un-maintainable stacks
![Page 21: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/21.jpg)
In Production, Machine Learning is a Software and System Problem.
Treat it accordingly !!!!
![Page 22: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/22.jpg)
![Page 23: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/23.jpg)
![Page 24: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/24.jpg)
![Page 25: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/25.jpg)
Deployment / Model Serving
![Page 26: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/26.jpg)
Deployment / Model ServingThe Missing Part in ML
![Page 27: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/27.jpg)
- Model Serving is often ignored or left out to Back End Engineers to implement at their own liking.
- More often it involves serving an API or a Service to do the Predict function. But that not often enough.
- Software scaling can become problematic to the accuracy of the model.
- How many models are you serving?
- Are you running something else ?
- Are you updating your model in real time?
![Page 28: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/28.jpg)
Example : AirBnb
![Page 29: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/29.jpg)
![Page 30: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/30.jpg)
- Trained Models are stored in PMML files
- They serve their models via Openscoring
- They do most of the experiments in a different pipeline.
![Page 31: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/31.jpg)
![Page 32: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/32.jpg)
PMML ?
![Page 33: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/33.jpg)
![Page 34: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/34.jpg)
PMML?
- Might be the solution for some (most ?) cases
- Support many models, but lacks support for many others
- Fails to capture the evolution of your modeling process … Transformations, re encoding, etc .
- Better suited for exporting models to other systems, rather than being served to machine learning products with real user facing.
- And … XML ?? Really????
![Page 35: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/35.jpg)
![Page 36: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/36.jpg)
![Page 37: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/37.jpg)
Model Versioning - Packaging
- You usually don’t serve only one model. But a lot more. Especially when running experiments.
- You should vie to package your model in versionned way.
- Git is awesome, but not appropriate for live model serving
- Build a model repository or a model index
- I usually use fast KV store or advanced data stores to save my models
- Build a service to manage your models (Model Manager) responsible for evaluating and updating your model.
![Page 38: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/38.jpg)
![Page 39: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/39.jpg)
![Page 40: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/40.jpg)
TensorFlow Serving
![Page 41: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/41.jpg)
![Page 42: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/42.jpg)
![Page 43: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/43.jpg)
Serialization
- Remember PMML ?
- In Big Data, data has schema and proper evolution?
- Why not models ?
- Lots to choose from : Protobuf, Avro
- Use binary schema to represent and version your models
![Page 44: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/44.jpg)
Evaluation
- Business metrics often differ from core model metrics : Trade off between long term metrics and short term metrics.
- Hyperparameters
- A/B Testing - Multi Armed Bandits Problem
![Page 45: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/45.jpg)
Hyper Parameters
Netflix
![Page 46: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/46.jpg)
![Page 47: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/47.jpg)
![Page 48: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/48.jpg)
A/B Testing - Multi-armed Bandit
![Page 49: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/49.jpg)
A/B Testing - Multi-armed Bandit
Dataiku
![Page 50: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/50.jpg)
Experiments
![Page 51: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/51.jpg)
![Page 52: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/52.jpg)
Reproducibility
- How to keep track of data used for training ?
- Are notebooks enough?
- Junpyter Notebooks, Spark Notebooks, Zeppelin, etc ….
- Need for an end to end solution. Not perfect, but a workable one.
![Page 53: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/53.jpg)
I forgot many things
- Monitoring
- Pipeline tuning (one model is often fed to another one)
- RPC over REST for fast model serving ?
- How to deal with heterogeneous systems ?
- Do you really have to distribute your processing?
- Is more data better than smartly tuned algorithms?
![Page 54: Machine Learning In Production](https://reader033.vdocument.in/reader033/viewer/2022051706/58f9a918760da3da068b6af1/html5/thumbnails/54.jpg)