Successfully reported this slideshow.
Your SlideShare is downloading. ×

Flink Forward Berlin 2017: Boris Lublinsky, Stavros Kontopoulos - Introducing Flink ML

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad

Check these out next

1 of 22 Ad

Flink Forward Berlin 2017: Boris Lublinsky, Stavros Kontopoulos - Introducing Flink ML

The Machine Learning (ML) library for Flink is a new effort to bring scalable ML tools to the Flink community in order to make Flink a premier platform for ML. This effort covers a wide area of ML related activities including data analysis, model training and model serving. In this talk we will cover approaches to using Flink for model serving. We will present a framework and actual code for serving and updating models in real time. Although presented examples cover only two model types - Tensorflow and PMML, the framework is applicable for any type of externalizable models. We will also show how this implementation fits into overall ML learning implementation and demonstrate integration with SparkML and Tensorflow/Keras and specifically show how models can be exported from these systems. This initial implementation can be further enhanced to support additional model representations, for example PFA and introduction of model serving specific semantics into Flink framework.

The Machine Learning (ML) library for Flink is a new effort to bring scalable ML tools to the Flink community in order to make Flink a premier platform for ML. This effort covers a wide area of ML related activities including data analysis, model training and model serving. In this talk we will cover approaches to using Flink for model serving. We will present a framework and actual code for serving and updating models in real time. Although presented examples cover only two model types - Tensorflow and PMML, the framework is applicable for any type of externalizable models. We will also show how this implementation fits into overall ML learning implementation and demonstrate integration with SparkML and Tensorflow/Keras and specifically show how models can be exported from these systems. This initial implementation can be further enhanced to support additional model representations, for example PFA and introduction of model serving specific semantics into Flink framework.

Advertisement
Advertisement

More Related Content

Slideshows for you (20)

Similar to Flink Forward Berlin 2017: Boris Lublinsky, Stavros Kontopoulos - Introducing Flink ML (20)

Advertisement

More from Flink Forward (20)

Recently uploaded (20)

Advertisement

Flink Forward Berlin 2017: Boris Lublinsky, Stavros Kontopoulos - Introducing Flink ML

  1. 1. Introducing FlinkML Boris Lublinsky Stavros Kontopoulos Lightbend
  2. 2. Talk’s agenda • Machine learning • Models • What are building? • Results and next steps
  3. 3. How people see ML
  4. 4. Reality
  5. 5. What is the Model? 5 A model is a function transforming inputs to outputs - y = f(x),for example: Linear regression: y = ac + a1*x1 + … + an*xn Neural network: Such a definition of the model allows for an easy implementation of model’s composition. From the implementation point of view it is just function composition
  6. 6. Model learning pipeline UC Berkeley AMPLab introduced machine learning pipelines as a graph defining the complete chain of data transformation. A single pipeline can encapsulate more then one predictive model. From a serving point of view its still a single pipeline.
  7. 7. Models proliferation Data Scientist Software engineer
  8. 8. Model standardization
  9. 9. Model lifecycle considerations • Models tend to change • Update frequencies vary greatly - from hourly to quarterly/yearly • Model version tracking • Model release practices • Model update process
  10. 10. Customer SLA • Response time - time to calculate prediction • Throughput - predictions per second • Support for running multiple models • Model update - how quickly and easily can the model be updated • Uptime/reliability
  11. 11. Model Governance Models should be: • governed by the company’s policies and procedures, laws and regulations and organization’s goals • be transparent, explainable, traceable and interpretable for auditors and regulators. • have approval and release process. • have reason code for explanation of decision. • be versioned. Reasoning for introduction of new version should be clearly specified. • searchable across company
  12. 12. What are we building We want to build a streaming system allowing to update models without interruption of execution (dynamically controlled stream).
  13. 13. Exporting Model Different ML packages have different export capabilities. We used the following: • For Spark ML export to PMML - https://github.com/ jpmml/jpmml-sparkml • For Tensorflow: • Normal graph export • Saved model format
  14. 14. Flink Low Level Join • Create a state object for one input (or both) • Update the state upon receiving elements from its input • Upon receiving elements from the other input, probe the state and produce the joined result
  15. 15. Model representation On the wire syntax = "proto3"; // Description of the trained model. message ModelDescriptor { // Model name string name = 1; // Human readable description. string description = 2; // Data type for which this model is applied. string dataType = 3; // Model type enum ModelType { TENSORFLOW = 0; TENSORFLOWSAVED = 2; PMML = 2; }; ModelType modeltype = 4; oneof MessageContent { // Byte array containing the model bytes data = 5; string location = 6; } } 15 Internal trait Model { def score(input : AnyVal) : AnyVal def cleanup() : Unit def toBytes() : Array[Byte] def getType : Long } trait ModelFactoryl { def create(input : ModelDescriptor) : Model def restore(bytes : Array[Byte]) : Model }
  16. 16. Key based join Flink’s CoProcessFunction allows key-based merge of 2 streams. When using this API, data is key-partitioned across multiple Flink executors. Records from both streams are routed (based on key) to the appropriate executor that is responsible for the actual processing.
  17. 17. Partition based join Flink’s RichCoFlatMapFunction allows merging of 2 streams in parallel (based on parralelization parameter). When using this API, on the partitioned stream, data from different partitions is processed by dedicated Flink executor.
  18. 18. Monitoring case class ModelToServeStats( name: String, // Model name description: String, // Model descriptor modelType: ModelDescriptor.ModelType, // Model type since : Long, // Start time of model usage var usage : Long = 0, // Number of servings var duration : Double = .0, // Time spent on serving var min : Long = Long.MaxValue, // Min serving time var max : Long = Long.MinValue // Max serving time ) Model monitoring should provide information about usage, behavior, performance and lifecycle of the deployed models
  19. 19. Queryable state Queryable state (interactive queries) is an approach, which allows to get more from streaming than just the processing of data. This feature allows to treat the stream processing layer as a lightweight embedded database and, more concretely, to directly query the current state of a stream processing application, without needing to materialize that state to external databases or external storage first.
  20. 20. Where are we now? • Proposed solution does not require modification of Flink proper. It rather represents a framework build leveraging Flink capabilities. Although extension of the queryable state will be helpful • Flink improvement proposal (Flip23) - model serving is close to completion - https://docs.google.com/document/ d/1ON_t9S28_2LJ91Fks2yFw0RYyeZvIvndu8oGRPsPuk8). • Fully functioning prototype of solution supporting PMML and Tensorflow is currently in the FlinkML Git repo (https:// github.com/FlinkML)
  21. 21. Next steps • Complete Flip23 document • Integrate Flink Tensorflow and Flink PMML implementations to provide PMML and Tensorflow specific model implementations - work in progress • Look at bringing in additional model implementations • Look at model governance and management implementation
  22. 22. Thank you Any Questions?

×