Currently we have a model that we are going to use for our API using Tensorflow Serving. Therefore we need to transform the current API input data into the features. As the creation of the model and the usage of the model are performed in two different repos, and I don't want to have the transformations in two different repos (to keep them the same for both repos), I was reading about Tensorflow Transform to be able to use 1 function to processed both the training data and the serving data. However, I find it hard to understand how it would work in production. When I save the model, can I include saving the preprocessing function? Or where can I "host" this preprocessing function?
So to be clear, I have a model that preprocesses the training data. And I want to use the same function for the serving data.
Anything running in TensorFlow Serving is just a TensorFlow graph, whether that's the model itself or your preprocessing steps. All you'd need to do to fold the two together is to connect the two graphs by substituting the output of the preprocessing step as the input to the model, assuming that's compatible.
For example, suppose your model were something really simple like this, that takes an arbitrary length input and computes its L2 norm:
And then we had a data preparation function that we wanted to apply that doubled the original input before computing the L2 norm by adding it to itself:
You could preprocess and do the "prediction" (such as it is in this toy example) in one TensorFlow Serving deployment by doing something like this:
This is not especially useful, and probably a lot less complicated than what you're doing. Hopefully it gets the idea across!