简体   繁体   English

在 apache flink 中嵌入现有的 ML 模型

[英]Embedd existing ML model in apache flink

we are training machine learning models offline and persist them in python pickle-files.我们正在离线训练机器学习模型并将它们保存在 python pickle 文件中。

We were wondering about the best way to embedd those pickeled-models into a stream (eg sensorInputStream > PredictionJob > OutputStream.我们想知道将这些pickeled 模型嵌入到流中的最佳方式(例如sensorInputStream > PredictionJob > OutputStream。

Apache Flink ML seems to be the right choice to train a model with stream-data but not to reference an existing model. Apache Flink ML 似乎是使用流数据训练模型但不引用现有模型的正确选择。

Thanks for you response.谢谢你的回应。

Kind Regards Lomungo亲切的问候洛蒙戈

There are two possible solutions depending on the model You are using:根据您使用的型号,有两种可能的解决方案:

  1. Possibly the simples idea is to create external service that will call the model and return the results and then simply call the service with AsyncFunction可能最简单的想法是创建外部服务,该服务将调用模型并返回结果,然后简单地使用AsyncFunction调用该服务
  2. Use some library, again depending on Your model to load the pre-trained model inside a ProcessFunction 's open method.使用一些库,再次根据您的模型在ProcessFunctionopen方法中加载预训练模型。 And then simply calling the model for each data that arrived.然后简单地为每个到达的数据调用模型。

The second solution has two disadvantages, first You need to have the Java version of the specific library available and the other is that You need to somehow externalize the metadata of the model if You want to be able to update it over time.第二种解决方案有两个缺点,首先您需要有特定库的 Java 版本可用,另一个是如果您希望能够随着时间的推移更新它,您需要以某种方式外部化模型的元数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM