I’m toying around with ML-models for the past weeks and while the learning-curve is steep and the hardware requirements high, I found a bunch of things which work well offline and are ready to use with some Python.

What I found pretty useful are the Helsinki NLP translation models, which are ready-to-use offline on your machine. What you need is:

  • The Python transformers-module from Hugginface,
  • The actual models.

Without being to verbose, the easiest way just to get started is by running pip install transformers, and fire up a Python shell.

In my very simple examples I will set up and download two translation pipelines; one for translating German to English, and another one for the other direction.

from transformers import pipeline
translator_de_en = pipeline("translation", model="Helsinki-NLP/opus-mt-de-en")
translator_en_de = pipeline("translation", model="Helsinki-NLP/opus-mt-en-de")

When setting up the pipelines for the first time, it will download the models from the Huggingface repository, but that’s about it and ready to use.

Examples:

translator_de_en("Installtion und Einrichten der Übesetzungs Pipelines ist recht einfach, und die Benutzung ebenso.")
[{'translation_text': 'Installing and setting up the practice pipelines is quite simple, and the use as well.'}]
translator_en_de("In my very simple examples I will set up and download two translation pipelines; one for translating German to English, and another one for the other direction.")
[{'translation_text': 'In meinen sehr einfachen Beispielen werde ich zwei Übersetzungspipelines einrichten und herunterladen, eine für die Übersetzung von Deutsch ins Englische und eine für die andere Richtung.'}]

There, you have it. Have fun!