Pular para o conteúdo principal

KieML: Running your Machine Learning models in the cloud

Nowadays Artificial Intelligence is every day on the news. Actually not only in the news, almost every month we have some impressive scientific paper related to deep learning or machine learning as you can follow in Two Minutes Papers youtube channel. Consequently we many libraries and products based on AI, and as I Java programmer I highlight DeepLearning4J, Weka, Tensorflow, OpenNLP, Apache Mahout.

We can say that AI is already the new electricity for big tech companies, but what about your company or about your customers? How can Machine Learning or AI improve their business and how will you achieve that?

If you check the list of solutions I provided above you will notice that we may chose a library for a solution, but it does not fit well to solve other problems. For example, perhaps training a neural network to classify some customer feedback may not be the best solution, so you decided to use OpenNLP instead DeepLearning4J.

Another problem is dynamically update your machine learning model or pre-trained neural network in production. Let's say currently your model deployed in production has a precision of 87%  and your AI specialists make it better with a precision of 88%. How you can make your model available for all productions systems that use it now? What about if you decide to change the provider from, let's say, from opennlp to deeplearning4j?

We've working on a project called KieML to provide a solution for these problems.

 KieML


KieML is a project built on top of Kie API and is used on JBoss projects such as Drools, Optaplanner,  and jBPM. Using KieML you can package your models in a JAR (also called kJAR), along with a kmodule.xml  descriptor and models-descriptor.xml.

models-descriptor.xml

Notice the models-descriptor.xml should point to the model binary and possible labels. You can also provide specific parameters for your provider.
The kmodule.xml can also describe possible drools resources, but for KieML you can keep it with the following content:


         xmlns="http://www.drools.org/xsd/kmodule">


Once the JAR is saved on the maven repository then you can use the API to load it:

Input input = new Input();
// load a file or use a text input
Result result = KieMLContainer.newContainer(GAV)
                           .getService()
                           .predict("yourModelId", input);
System.out.println(result.getPredictions());

KieML server

Since we are using Kie API we can extend Kie Server so you can easily manage your models using JMS or REST API.
kie-server-ml-flow.png


If you want to know more about extending Kie Server you can follow these great Maciej's serie of articles. KieML has also a client extension so that you can remotely call Kie Server using Java:

KieServicesConfiguration configuration = KieServicesFactory
.newRestConfiguration(" http://localhost:8080/rest/server", "kieserver", "kieserver1!");
KieServicesClient client = KieServicesFactory.newKieServicesClient(configuration);
Input input = new Input("some input");
KieServerMLClient mlClient = client.getServicesClient(KieServerMLClient.class);
System.out.println(mlClient.getModelList(CONTAINER_ID).getResult());
System.out.println(mlClient.getModel(CONTAINER_ID, "my model").getResult());

New models JARs can be places in a maven repository that you can manually copy to the production server maven repository (no maven installation is required, just the repository) or use a centralized nexus repository to push the new JARs. Using the KieScanner feature we can keep a published container updated with the latest version of a kjar.

Finally to make KieML available in the cloud you can build a Wildfly Swarm JAR and then deploy it on Openshift, Amazon EC2 or any other service that simply allow Java execution. You can read more about running Kie Server on Widlfly Swarm in this Maciej's post.

Kie Server is also easily managed from Drools/jBPM (or BPM Suite and BRMS) web console when it is used in managed mode and you can manage as many server as you want and put it behind a load balancer because KieML should work in a stateless way. Finally you may check the Kie Server documentation to learn more about its great REST/JMS and its Java client API.

If you want to try it now you just need maven and Java 8 because the source and instructions to build and run it locally are in my github. The project is in constant development and still on its early stages, every contribution, suggestion and comment is welcome!

I hope Kie team won't be mad because I took the "KIE" name for this project 0_0

Comentários

Postagens mais visitadas deste blog

Simplest JavaFX ComboBox autocomplete

Based on this Brazilian community post , I've created a sample Combobox auto complete. What it basically does is: When user type with the combobox selected, it will work on a temporary string to store the typed text; Each key typed leads to the combobox to be showed and updated If backspace is type, we update the filter Each key typed shows the combo box items, when the combobox is hidden, the filter is cleaned and the tooltip is hidden:   The class code and a sample application is below. I also added the source to my personal github , sent me PR to improve it and there are a lot of things to improve, like space and accents support.

Dancing lights with Arduino - The idea

I have been having fun with Arduino these days! In this article I am going to show how did I use an electret mic with Arduino to create a Dancing Lights circuit. Dancing Lights   I used to be an eletronician before starting the IT college. I had my own electronics maintenance office to fix television, radios, etc. In my free time I used to create electronic projects to sell and I made a few "reais" selling a version of Dancing lights, but it was too limited: it simply animated lamps using a relay in the output of a 4017 CMOS IC. The circuit was a decimal counter  controlled by a 555. 4017 decimal counter. Source in the image When I met Arduino a few years ago, I was skeptical because I said: I can do this with IC, why should I use a microcontroller. I thought that Arduino was for kids. But now my pride is gone and I am having a lot of fun with Arduino :-) The implementation of Dancing Lights with Arduino uses an electret mic to capture the sound and light leds...

Creating custom Work Item Handler in BPM Suite/jBPM 6

Hi all! In this post I am going to share my experience creating a work item handler for BPM Suite 6.0.3 (which is very similar to jbpm as explained in a previous post ). The Hello World Work Item Handler Let's create a really simple WorkItemHandler just to print "Hello World" in the console. Of course you can implement more feature and make it receive parameters, access database, web services, etc. But in this post we will keep it simple. Really simple. First thing to do is to create a maven project for my WorkItemHandler. Here's the pom.xml of my Maven project: Notice that we are importing jbpm dependency so we can find the java interface that is used to create work item handlers. Now we can start coding. Let's create a class name HelloWorkItemHandler in package org.jugvale.jbpm, here is the simple code: Now we can build our project and go to BPM Suite to configure it so we can use this workitem. Registering the WorkItemHandler UPDATE...