Like i asked.Can we request more than 1 element. Like microsoft translator api.
Microsoft Translator api request :The array can have at most 25 elements.
[
{
“Text”: “I would really like to drive your car around the block a few times.”
},
{
“Text”:“Tried something new.”
}
]
Yes. Just pass an array of strings instead of a string to the q
parameter:
curl -X POST https://<server>/translate -H 'Content-Type: application/json' -d '{"q": ["hello","world"],"source": "auto","target": "es","format": "text"}'
1 Like
Is there any limit for that ?
Unless you set a --batch-limit
parameter, no, but you will be limited by your hardware.
2 Likes
If I pass array of string, will it improve performance? And by how I will be limited by hardware? What should I change in my hardware to improve performance? And by how much?
CTranslate2, the Transformer inference engine used by LibreTranslate, takes a batch of sentences to translate and is able to run the translations in parallel and improve performance. CTranslate2 is called by Argos Tranlslate here:
Argos Translate only processes a single translation at a time but splits the source text on line breaks and sentence boundaries and translates the sentences in parallel batches.
LibreTranslate normally runs with a webserver with multiple parallel processes and threads running multiple instances of Argos Translate in parallel. So if you make multiple requests to a LibreTranslate API in rapid succession you can probably utalize all of the cores of the processor you’re running LibreTranslate on.
In my experience LibreTranslate runs best on modern Intel and AMD CPUs (not GPUs) with 16+ cores.
Thank You.
If I made multiple requests to LibreTranslate, utilization of RAM is increasing as per request. And translation speeds down. What is the solution for that?