Retrain and translate "at the same time"

We are a translation company that uses nmt for several years. Is it possible to use opennmt-tf to serve translation and at “the same time” retrain the model with the feedback of our translators.


We don’t provide a workflow for that out of the box but it should be technically possible with some work:

  1. Get the last training checkpoint
  2. Invoke the training API to continue on new data
  3. Export a new model for inference
  4. If using TensorFlow Serving, it can automatically load the latest version of a model

Hi Guillaume,

Thank you for your answer. The strategy you recommend implies that the model will be reloaded after each new train (and in our case, this will happen quite often, each time a translator will valid a segment in the cat tool ) Is it possible to load a unique model in memory and then train or translate with it? We are a team of 5 developers and we 've already adapted opennmt-py to do something similar, but for many reasons, we prefer the opennmt-tf version and we would like to do it with this version

Ok, so you want to dynamically switch between training and inference using the same model. In TensorFlow, this would mean defining a graph that can be used for both training and inference. This is possible but currently requires to:

  • update some graph code in OpenNMT-tf to allow reading the execution mode (training or inference) at runtime and not only at graph build time
  • have a custom code to orchestrate training and inference

If you already have a working solution in OpenNMT-py, also consider that TensorFlow 2.0 is expected to be released in the coming months. The way to achieve that will generally be different and easier than it currently is. If you want to get started with this version, check out this OpenNMT-tf branch (and its documentation).

Hi Guillaume,

Thanks for your answer. We will wait for the tensorflow2 version!