Skip to content

Multilingual Engines

Davide Caroselli edited this page Jul 31, 2019 · 21 revisions

ModernMT supports multilingual engines, this means that you can use a single ModernMT system to handle multiple language directions. The following example explains in detail how to create and deploy a multilingual neural engine.

Let's say you want to start an en-it and en-de engine.

Train engines

First of all, open a shell in your ModernMT home folder and create and train two separate neural engines like this:

./mmt create en it /path/to/your/en_it/files -e enit
./mmt create en de /path/to/your/en_de/files -e ende

Create the multilingual engine skeleton

After that, create a new empty multilingual engine folder structure with a multilingual engine.xconf file. For example let's call the new engine multilingual:

mkdir -p engines/multilingual/models/decoder

Using a text editor create the engines/multilingual/engine.xconf file. Here's the file content following our example:

<node xsi:schemaLocation="http://www.modernmt.eu/schema/config mmt-config-1.0.xsd"
      xmlns="http://www.modernmt.eu/schema/config"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <engine>
      <languages>
          <pair source="en" target="it" />
          <pair source="en" target="de" />
      </languages>
   </engine>
</node>

Populate the decoder model folder

Now we can copy the two previously trained neural engines in the multilingual engine like this:

mv engines/enit/models/decoder/en__it engines/multilingual/models/decoder/
mv engines/ende/models/decoder/en__de engines/multilingual/models/decoder/

Finally, let's create a new model.conf. This configuration file must contain a [models] section with a line that associates each language pair to the relative path of the corresponding model folders name:

{SourceLanguageCode}__{targetLanguageCode} = relative/path/to/model/folder

So in our example the engines/multilingual/models/decoder/model.conf file will look like this:

[models]
en__it = en__it/
en__de = en__de/

Test your multilingual engine

Now you can start the multilingual engine and test it:

$ ./mmt start -e multilingual

$ ./mmt translate -s en -t it -e multilingual "This is an example."
Questo è un esempio.

$ ./mmt translate -s en -t de -e multilingual "This is an example."
Dies ist ein Beispiel.