wanton7
Can someone give ideas how could I create optimal batches for Azure AI translator calls?
Limits are max 50000 characters max per batch and max 1000 strings per batch. Then there can be x amount destination languages that multiplies characters per language. So string with 100 characters will take space of 200 characters example if you use two destination languages. If you have one string with length 50000 you can only have destination language. These destination languages are defined per batch. So example if I had 6 destination languages I could split them to two batches of 3 languages each and so on.
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Kia ora,
We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Hello,
I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter).
The diffic...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
ICal is a library for interacting with iCalendar data. It parses iCalendars into typed Elixir structs via ICal.from_ics, and can prepare ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #phoenix_html
- #elixirconf-us
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
dimitarvp
What exactly are you asking? If you have a string of 50_000 characters and need 2 languages, that maybe your code should split it in two and then call the API, or what?
wanton7
How to make optimal batches with limit of 50000 characters/letters and 1000 strings per batch.
Making it optimal with one language wouldn’t be that bad but as there can be multiple languages and if you add another language it will multiple every string length added to the batch. Then because you have 50000 character limit you can’t example put 30000 long string into a batch with two languages because that will go over 50000 total character limit per batch as that one string is counted 60000 length string.
In some situations we have over 10 destination languages but how many destination languages depends on situation and can be pretty much anything from 1 to 20.
I tried to think how I could make optimal batches but my brain started to hurt badly so came here to ask help
Edit:
So example if I have 10 destination languages, 2500 strings and those string can be any length under 50000. How do I create optimal batches meaning minimum amount of API calls out of those when limit is 50000 total characters/letters and 1000 strings where every strings length (characters) count is multiplied with number of destination languages used per API call (batch).
dimitarvp
Yep, I get that, but what’s still missing in your question is how would you do it manually?
Would you:
Maybe I am misunderstanding you but it looks like trivial division would do the trick?
Or are you saying that e.g. if you have 2 x 5_000 length strings then you can still batch some other strings inside the same request?
wanton7
String can’t be splitted because they go AI translator. I mean if you split a string how it’s translated would change. I’m saying that if example had 5_000 length string I could translate it to 10 languages in one request. But one API call can only have specific destination languages so you can’t define destination languages per string.
So example if I have a string and 10 destination languages I can either use single API call with that string and set use all those 10 destination language to translate that string to 10 languages or I could do 10 API calls with single destination language. Example if string would have length of 25_000 I could only use two destination languages for one API call because with two languages that would be counted as 50_000 characters long that is the API total character limit.
Yes I can batch multiple strings into same request up to 1000 with any length but in total they can have up 50_000 characters. But every new destination language you add it will multiply length of all strings against that 50_000 limit. So with one language every string length is counted normally against 50_000 if you have two then every string length is doubled against that 50_000 and if you have three then every string length is tripled against that 50_000 limit.
dimitarvp
So maybe this?
Included:
requests_for_multiple_texts);benchmarkfunction (make a small new Elixir project and just includebencheein it, or useMix.installin a single.exsfile ) and you’ll see for yourself which of both is faster. SPOILERS: it’s the one usingEnum.reduce. I could probably make an even faster one but wasn’t in the mood to make one that uses only pure recursion and nothing else;The output might be slightly cryptic, so explaining it:
You get a list of tuples: first element is the text key (or the text itself), the second one is a list of lists of tuples.
The list of tuples represent a single request which might have e.g. same text with 5 languages. Each text here is represented by its length, not the key / text itself. Got tired and didn’t want to bloat the functions further with one more piece of data.
The list that encompasses that list of tuples is the list of requests that must be made for this single text to get fully translated.
Not sure if the code is good but it gets the job done. With the demo data above the result is:
…which means:
"text 1"gets to do 2 requests: one with 3 languages and one with 1 language;"text 2"gets to do 1 request with 2 languages;"text 3"gets to do 2 requests: one with 5 languages and one with 1 language.wanton7
Thank you!