← Back to list

Tips for faster translation using Argos-Translate Python

About Argos Translate

Has · 2023-01-20 19:00 · 5 claps · 0.9 min read
#python #translate #argos-translate #machine-learning #deployment
Open on Medium ↗
Wiki topics: ML · Machine Learning LNG · Linguistics & Language EDU · Education & Learning

Tips for faster translation using Argos-Translate Python

[embed]

About Argos Translate

Argos Translate is an offline language translator that uses TensorFlow for translations and can be used as either a Python library, command-line, or GUI application.

Installation

Simply run the following command in your environment

pip install argostranslate

Usage

A typical first run code like this:

[embed]

This API is simple and it automatically downloads the necessary files for translation. However, it’s impractical to use it in this form in a web service or a public application because this API is too redundant and takes a lot of time.

Faster Translation in a Loop

[embed]

Explanation

Line 1–3 : import necessary packages, it can be simplified.

Line 5–6: Selects translation languages. In arrow representation this would be en->es or English → Spanish

Line 8: Get a list of installed languages. These languages are installed using the code given in the earlier section. In this case I installed only these two languages so I am unpacking them int vars.

Line 9: Load the translation model in memory.

Line 12: Since everything is saved in memory already, if this line is used in for loop it would not take as much time as earlier code.

So Why is it faster?

Well, when using the argostranslate.translate.translate the module first performs a few filters and not to mention it reloads the language model on every call so it is inefficient.

Thank you.

[embed]


메타데이터
post_id
3197cd2a296b
slug
tips-for-faster-translation-using-argos-translate-python-3197cd2a296b
url
https://medium.com/@hasisyed/tips-for-faster-translation-using-argos-translate-python-3197cd2a296b
canonical_url
https://medium.com/@hasisyed/tips-for-faster-translation-using-argos-translate-python-3197cd2a296b
author_url
https://medium.com/@hasisyed
status
ok
fetched_at
2026-06-21 07:44:09