# Episode 17

**Guest:** Savin Goyal

**Title:** Taming the Long Tail of Industrial ML Applications

**Abstract:** Data Science usage at Netflix goes much beyond our eponymous recommendation systems. It touches almost all aspects of our business - from optimizing content delivery and informing buying decisions to fighting fraud. Our unique culture affords our data scientists extraordinary freedom of choice in ML tools and libraries, all of which results in an ever-expanding set of interesting problem statements and a diverse set of ML approaches to tackle them. Our data scientists, at the same time, are expected to build, deploy, and operate complex ML workloads autonomously without the need to be significantly experienced with systems or data engineering. In this talk, I will discuss some of the challenges involved in improving the development and deployment experience for ML workloads. I will focus on Metaflow, our ML framework, which offers useful abstractions for managing the model’s lifecycle end-to-end, and how a focus on human-centric design positively affects our data scientists' velocity.

#### Data Scientist

* Jupyter notebook, R Studio, or some other IDE&#x20;
* OpenCV, Tensorflow, Pytorch, OpenCV&#x20;
* Deal with data: flow, google cloud storage, S3, local disk&#x20;
  * Keep track of states, data
* Create a workflow out of the work
  * Offload compute into the cloud, hyperparameter optimization, sigopt, slurm
  * Familiar with all these concepts&#x20;
  * Input of the workflow changing overtime
    * Get the latest data and retrain&#x20;
* Orchestrate the workflow (pipeline)
  * Fit into this new paradigm&#x20;
  * Containers (docker etc.)&#x20;
    * Take unit of compute and package that into container&#x20;
* Flask, Shiny, Custom application, Commercial and open source solutions to monitor the service&#x20;
* Result
  * If business stakeholders don't satisfy
  * O/w
    * More progress: more ideas, add more features, how to make sure deploying staging of services?

![](https://2097630930-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MVORxAomcgtzVVUqmws%2F-MW5wI4ystXa4e19CZFU%2F-MW5ylGOKUHi2DbPDiZD%2Fimage.png?alt=media\&token=d61ae832-9c15-4a3e-8beb-8ed82cd926a8)

![](https://2097630930-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MVORxAomcgtzVVUqmws%2F-MW5wI4ystXa4e19CZFU%2F-MW5zK9jdlcVd0atf6Yh%2Fimage.png?alt=media\&token=d8f51113-068e-4dba-b139-771daba5c959)

* Structure your code as a DAG&#x20;
  * A natural way to express ML pipelines&#x20;
  * Many technical benefits follow when you do this&#x20;
  * Start two models A, B; join and decide which is better; end&#x20;
* Start with an ML script&#x20;

![](https://2097630930-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MVORxAomcgtzVVUqmws%2F-MW5wI4ystXa4e19CZFU%2F-MW5zh4l8BoOn4EAI8L6%2Fimage.png?alt=media\&token=dd8d223b-ac59-44cd-a071-def764f3d089)

* With a small bit of refactoring with[ Metaflow  ](https://metaflow.org/)

![](https://2097630930-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MVORxAomcgtzVVUqmws%2F-MW5wI4ystXa4e19CZFU%2F-MW5znVDVh8_y7-ZlRUZ%2Fimage.png?alt=media\&token=d4d70a23-cc0b-400f-b922-a2d1752b5fbd)

* Develop locally like any other script&#x20;
* In each step, anything you store&#x20;

![](https://2097630930-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MVORxAomcgtzVVUqmws%2F-MW5wI4ystXa4e19CZFU%2F-MW6-6_MRc0hWZVmB7mV%2Fimage.png?alt=media\&token=34879d55-2804-482b-a570-87bc5a56ca29)

* Store these data and can be retrieved and inspected&#x20;

![](https://2097630930-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MVORxAomcgtzVVUqmws%2F-MW5wI4ystXa4e19CZFU%2F-MW6-JzS5972Gvij_3Lg%2Fimage.png?alt=media\&token=9c1a5941-3052-4a0c-80c9-24ff0c06400d)

* And is versioned and namespaced&#x20;

![](https://2097630930-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MVORxAomcgtzVVUqmws%2F-MW5wI4ystXa4e19CZFU%2F-MW6-R3Hamgupzu43MeH%2Fimage.png?alt=media\&token=095cb701-ddcf-46b9-9523-486235af6266)

* Can restart from any step&#x20;
  * ? Checkpoint overhead?&#x20;
  * Previous step snapshot by metaflow&#x20;
* Straightforward grid search&#x20;

![](https://2097630930-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MVORxAomcgtzVVUqmws%2F-MW5wI4ystXa4e19CZFU%2F-MW6-iqG7fSEOeAQfm2o%2Fimage.png?alt=media\&token=407ccbd9-18b3-4164-aff9-b55f89584c9f)

* Offload compute to the cloud&#x20;

![](https://2097630930-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MVORxAomcgtzVVUqmws%2F-MW5wI4ystXa4e19CZFU%2F-MW6007rz-J-yVhA37mh%2Fimage.png?alt=media\&token=2286ddd7-f7ee-49bf-be0f-5f27822b9f36)

1. Annotate the step and resources&#x20;
   1. How would user know what compute resources are appropriate?&#x20;

* Specify compute dependencies easily&#x20;

  * Packages and environments, what are the things they want?

* Ready for production? &#x20;
  * Workflow executes asynchronously&#x20;
  * Publish your workflow to workflow orchestrator&#x20;
    * Gap: own programming paradigm, rewrite...&#x20;
    * Good thing: workflow orchestrator executes a DAG&#x20;
      * Allow users to seeminglessly to deploy the prototyping work&#x20;

![](https://2097630930-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MVORxAomcgtzVVUqmws%2F-MW60mWstJQDVcReSeKs%2F-MW61-x3hVlNasqJWUR9%2Fimage.png?alt=media\&token=d19ed702-6d86-4389-ba81-b14f99551d63)

* Ready for integration?&#x20;
  * Web services etc.&#x20;
