Creating a 10-Step Model Chain Without The Pain 

May 4, 2021

In our previous post “Working Smarter with Machine Learning Model Chains”, we dug into how you can work smarter and more efficiently with machine learning (ML) using model chaining.

As a reminder: model chaining is the process of linking modular, independent ML models together to create an automated, continuous ML workflow. This includes model stacks, for example, where the results of multiple sub-learners are combined by the last step into a final result. The chains can be simple, linear chains or can include multiple steps combined in a DAG (directed acyclic graph). The ability to do model chaining allows you to mix and match your models to build different processing pipelines fit for any context — without breaking or changing the rest of your workflow. 

In short, the ability to re-use specific models leads to better performance, fewer computing resources, and countless hours saved on maintenance efforts. 

But as you know, the model chaining process is infamous for its complexity and high resource demand. In this follow-up post, we’ll explain how you can streamline model chaining from day one, and show you an example of how Wallaroo makes it unbelievably simple to pipeline your models with just a few lines of code.

Design principles for model chaining

Much of the complexity of model chaining can be avoided from the get-go. If you’re building something for single-use, then it’s only going to be used once. So, here are a few guidelines that will save you a lot of time, resources, and maintenance down the line. 

Consider how models can be used later: When building a model for a specific use case, think ahead to how you might reuse it in other use cases. This means avoiding problem-specific constraints on the inputs and outputs of your model so you can simply plug it into different contexts.

Keep them documented and searchable: If the point is to reuse your models, then make sure they’re well-documented and stored in a searchable catalog. Knowing where your models are, what they do, and what their limitations are will make it infinitely easier to find the models you need when you need them. 

Think API-first: The standard approach of downloading and setting up specific environments for each of your models is time-consuming and resource-heavy. On the other hand, using an API endpoint means developers can simply add a one-line API call to their application. This cuts the need to fiddle around with servers and environment setup and makes scaling seamless.

Creating a 10-step model chain with Wallaroo

Model chaining doesn’t have to live up to its tedious and expensive reputation. With an enterprise ML platform like Wallaroo, you can cut the complexity from the implementation and fully leverage the benefits of model chaining — at a vastly lower cost. 

To give you a better idea of how Wallaroo helps you simplify model chaining, take the following example:

In this scenario, we’re creating a ten-step model chain that runs its input through the lstm_0, lstm_1, and lstm_2 models after preprocessing. The result of the Long Short Term Memory (LSTM) inferences are then run through the predict_1 and predict_2 models. These are averaged and the result is swiftly returned to the caller. Here’s the code that makes this all happen:

Figure 1: Code for our 10-step model chain

With Wallaroo you can create model chains with just a few lines of code in a configuration file. All you need to do is specify Wallaroo what you want the chain to do — and then let the platform handle all the plumbing. No pain. All gain.  

Ready to work smarter with machine learning and harness the power of model chains? Get in touch to get started.