Today, we’re going to talk about a tool that you’re going to love because it allows you to translate anything and everything into your language, all locally. It’s called TranslateLocally, created by the geniuses at Marian and Bergamot, to let you translate any text, from any app, directly on your computer in the blink of an eye 😉
No more sending your personal data to distant servers, risking it ending up in the hands of someone with ill intentions.
It’s available on all respectable platforms: Windows, Linux, Mac, web version, Chrome and Firefox extensions… and even on MS-DOS for the most nostalgic among you (just kidding, though… 😜). And the best part is, you can even add your own translation models.
TranslateLocally uses the combined power of the Marian and Bergamot libraries to perform translation feats worthy of a polyglot C-3PO. It’s all boosted by model quantization on 8 bits, allowing ultra-fast execution, even on a low-end Raspberry Pi. And thanks to a well-thought-out lexical shortlist, the translations are incredibly precise.
For the pros, there’s even a command-line interface available: file translation, on-the-fly model switching, advanced options… Everything is there!
To translate a sentence, it’s super simple:
./translateLocally -m <model> -i <text> -o <output>
Which results in something like this:
echo "Hello, world!" | ./translateLocally -m fr-en-tiny
-m <model>
: Specify the translation model to use (e.g., de-en-tiny for German-English). The list of available models can be obtained withtranslateLocally -l
.-i <text>
: Text to translate (can be a file or a standard input stream).-o <output>
: Output file for the translation (can be a file or a standard output stream).
And if you want to translate an entire file:
./translateLocally -m fr-en-tiny input.txt output.txt
TranslateLocally can also import custom translation models in Marian format. To import a model:
- Place the model in a directory. The directory structure of a TranslateLocally model should look like this:
my-custom-model/
├── config.intgemm8bitalpha.yml
├── model_info.json
├── model.npz
└── vocab.deen.spm
- Open TranslateLocally and go to Edit -> Translator Settings -> Languages -> Import Model.
- Select the directory containing the model you want to import.
And that’s it!
For the curious among you, it can be downloaded from the TranslateLocally GitHub.