Using ChatGPT 3.5 Turbo for translating xml

Hello everyone! Does anybody uses ChatGPT as a translation service? Recently I tried to use ChatGPT 3.5 Turbo for translation of xml data, like this:

<par>Sentence 1</par> 
<par>Sentence 2</par> 
<par>Sentence 3</par> 
<par>Sentence 4</par>
<par>Sentence 5</par> 
<par>Sentence 6</par> 

It translates okay, however the problem is - it sometimes merges output sentences together, which results in wrong amount of output tags, which is important.
The more sentences, the more likely it will fail.

My prompt is:

You are a highly skilled AI translator. You specialize in translating youtube videos scripts. Translate the following content into {lang}. Also, make sure to keep original .xml tags.

Question is: is it possible to somehow use ChatGPT as a reliable translation service for a such task, or better look elsewhere? (for example to purchase Deepl subscription - according to their docs, they can work with html and xml, however I didn’t test it)

if ChatGPT 3.5 Turbo can be reliably used for a such task, what is the best practice?

Welcome to the forum!

If you have access to Code Interpreter you can use that to verify the XML.

What do you mean by suggesting to use Code Interpreter to verify the XML? Can you please elaborate?
I verify output by counting amount of input xml tags and output xml tags, if not equal, I raise an exception.

Seriously, if it does not make sense as I noted then you will probably not understand if I explain it. :slightly_frowning_face:

1 Like

I never used Code Interpreter before. Can you at least give some hints of what you suggest?

When it first came out it took me a while to really get what it is about. It has a really bad name for what it does. Watch some videos, read some blogs, play with it for other things then after several good hours of using it for other things, you will be able to answer this question yourself.

Seriously if you think ChatGPT is great with Code Interpreter it is much more useful but you have to learn what it can do, not just from someone giving you a quick answer. :slightly_smiling_face:

Maybe someone else will see this and give you the quick answer but I think they are not helping you if they do that.


I tried it and it actually took me less time to get what you seek then it took me to write the replies here.

Just to confirm this is what I used


1 Like

Hi @peter.smetanka92

Welcome to the OpenAI community.

Rather than sending xml, you can parse it on your end and convert it to a json stringified array and send it for translation.

Once you receive the response you can parse it back to json array and repopulate the responses into the original xml.

For the batching part you can get started here: Batching with ChatCompletion Endpoint


Does GPT translate the json stringified array in the full context of the sentence?
Normally in another language sentence parts can be shuffled because of grammar rules and so on…

Welcome to the forum, @leensmits.

Yes, in my opinion, it does better than every non-human translation service available. However, performance may vary depending on the language.

What language are you trying it with?

1 Like

Not a particular language pair. But I was worried that if you break up a sentence, and glue the sentence back, you fall into the concatenation trap.

In context of this post, we’re dealing with multiple whole sentences, being processed in batch. I can’t understand the purpose of breaking up the sentence.

Hey Peter I’m also trying to work on extracting some information of an XML file. What has worked for you?

I’ve tried it on couple of examples and it is doing just fine. Can you share examples where it fails?