argosopentech / argos-translate

Open-source offline translation library written in Python
https://www.argosopentech.com
MIT License
3.87k stars 282 forks source link

Slow performance ? #174

Closed dingedi closed 3 years ago

dingedi commented 3 years ago

Hello,

I notice something strange, maybe due to a bad configuration on my part, i dont know.

When I use argos-translate (installed with pip) from the command line, it takes about 1.3 seconds to get the translation of a very small sentence.

$ time argos-translate --from-lang en --to-lang fr "Hello, it's a test" $ Bonjour, c'est un test $ argos-translate --from-lang en --to-lang fr "Hello, it's a test" 1,31s user 1,34s system 330% cpu 0,802 total

When I use libretranslate (installed with pip as well) using their api (in local) the translation is done in about 150ms. I'm talking about the first translation and not the ones after caching which are even faster.

Did I configure something wrong or is it a bug?

PJ-Finlay commented 3 years ago

When you run Argos Translate for a single translation the Python interpreter has to load and parse all of the files. For LibreTranslate even if the specific translation isn't cached Argos Translate is already parsed and loaded into memory.

dingedi commented 3 years ago

Ok thanks i was thinking about something like this but i was not sure as i couldn't find anything in the libretranslate code i will look in more detail! Thank you !