How to auto detect the source language using the OpenNMT Server


I have a server running :

I have a translator which translates using python code:

The server here assumes to be always English. The target is always German. Even if I give german language as a source input it returns german again.

How to make the server auto detect the source languages ?
How to decide the target language at runtime ?

Thank You,


The model you are serving was only trained on English to German data so it can only translate from English to German.

To achieve what you are asking, you should first train models for other language pairs and then have a external system (non available in OpenNMT) that auto-detects the language and invokes the correct model.


There are two things I want to confirm:

  1. Training the model could be done using the steps in the below link: Am I right?

  2. What does it mean by external systems (non available in OpenNMT) to auto detect the
    input languages ? Please give me some hints regarding this external system.

Thank You,


A system you should develop by yourself. No additional guidance will be provided here.