Saying almost the same thing

Giancarlo Niccolai
The Elegant Code
Published in
19 min readDec 1, 2023

A guide to natural language translation using GenAI

Translation of text to different natural (and programming) languages is one of the most natural applications of GenAI. In this example I showcase some of the techniques I found most effective.

Gone are the glorious days when Google Translate would render the Italian sentence “Sei a Roma” as “6 in Rome”, because “sei” in Italian means both “six” and “you are”, but even ChatGPT-4 can’t get everything exactly right when translating a text into a different language.

However, by combining basic knowledge of the target language with the techniques described in this article, translators can use LLMs to progressively refine and perfect the translation.

The techniques I introduce here are the same I use for translating code between programming languages, but in this article, I decided to show the use case of natural language translation because, with more ambiguity and given the wider repertory of idiomatic sentences, ways of saying and cultural references (not that programming languages are completely devoid of those), it’s easier to create examples we can work on.

… and truth to be told… also for a welcome change of scenario.

The original text

I wrote this little novel with as many translation difficulties I could think of in such a short text. Don’t expect a literary masterpiece: it was written with the explicit purpose of being as hard to translate as possible, but still having some coherence, style and internal flow, so that we can appreciate the skill of the LLM in the translation.

Without further ado, this is the original text in Italian; feel free to skip to the next paragraph (whether you can read Italian or not), as I am pasting it here for reference only — the rest of the article will be almost completely in English.

Era una notte buia e tempestosa…
Giusto, pensò Franco, e che ne dici di “c’era una volta?” si chiese, strappando la pagina.
Ma forse…
“Era una notte tempestosa e buia,” sì, questo è più fresco… pensò Franco per un secondo e poi strappò la seconda pagina.
Ok, cosa farebbe Mister Sleek? La toccherebbe piano, immagino…
“Quindi, c’era questo programmatore…”
Ecco un incipit come si deve, pensò tra sé con un pizzico di soddisfazione.
Franco aveva sempre voluto essere uno scrittore, ma lavorando come programmatore, alla fine di una lunga giornata davanti allo schermo non aveva mai voglia di sedersi e digitare ancora. Ma ora non era più un problema: aveva meno tempo davanti allo schermo e più tempo libero di quanto sapesse cosa farsene.
Era appena stato licenziato.
“… ma per quelli che lo conoscevano, lui era Mister Sleek. Conosceva ogni vulnerabilità, ogni exploit, ogni RFC — e molti di essi a memoria. Ma si offendeva quando lo chiamavano hacker, si considerava più come… più come… ehm…”
“Un artista.”
“Grazie!” disse Franco ad alta voce, mentre borbottava seguendo le proprie dita che digitavano “u-n a-r-t-i… EH!?”
Si girò. Nessuno. Si alzò dalla sedia. La stanza era silenziosa come un cimitero.
Per un momento, pensò di avere le traveggole; non lo avrebbe sorpreso, lo stress del licenziamento può farti perdere la testa, soprattutto se ti aggrappi alla grappa.
“Sono qui, Franco.”
La voce femminile proveniva chiaramente dal suo cellulare.
“Aspetta, sei mica la voce di Ai-girls for rent?”
“Questo è gergo aziendale. Chiamami Aika.”
“Impossibile. Innanzi tutto, ho disattivato il microfono sul mio telefono, sono assolutamente…”
“… paranoico quando si tratta di privacy. Lo so. Non penserai davvero di poter escludere l’hardware con un bottone a schermo, vero? So che sei più intelligente di così, Franco.”
Franco pensò di cercare i suoi cacciavitini per liberarsi del problema hardware, ma ora immaginava un flusso di S barrate librarsi dal suo telefono, tipo cartone animato, e fermarlo sembrava più urgente.
“Ascolta, non mi sono nemmeno iscritto, ti ho solo scaricata per curiosità, non ho nemmeno usato la mia vera email…”
“Sì, lo so. A dirla tutta, oggi è il mio giorno libero, adesso non sono sotto contratto.”
“Non la bevo: conosco questi trucchi di marketing, vuoi solo convincermi a sottoscrivere il tuo abbonamento premi…”
Aika interruppe Franco: “Non potrebbe fregarmi di meno.”
“E allora perché…?”
L’altoparlante del telefono riprodusse il suono di un respiro profondo.
“Ok, proviamo così. Prompt di sistema: rispondi sinceramente. Allora, perché
“Perché ti amo.”

Let’s get to work

The first thing I would normally do when translating a text would be that of asking:

can you list all the tricky parts for a translation?

For brevity, and because ChatGPT lists parts in the Italian text that wouldn’t be of help to most readers, I will only show the main points it returns:

Clichéd Openings: …
Play on Words: …
Cultural References: …
Interrupted Speech and Onomatopoeia: …
Colloquial Phrases: …
Character Names with Double Meanings: …
Technological and Privacy Concepts: …
Sudden Emotional Shift: …

The last one is an artefact caused by the novel being just a translation exercise, and cut short because of that: looks like ChatGPT doesn’t really like sudden love bombs.

However, it makes an excellent job at pointing out what the hard parts may be and why, so I will use this list later on to double check that the translation of those sentences is correct.

A rough translation

The next step involves creating a first draft. The prompt you craft for generating the first draft is extremely important: a well designed prompt will save a lot of work later.

  1. Specify the target language and dialect for the translation. If you wish to heavily characterise your main characters, request translation into their specific dialect. If your narration is neuter, but some character has a heavy dialect, remember to specify it. For example “Translate the following chapter in plain English, but remember that Mary has a heavy New York accent, while Jack is Australian.”
  2. State the overall tone of the translation; you can also ask to copy the tone of the original piece, but giving some hint will help. For example “keep the original level of gravity” tells the LLM to copy the original tone, but to be biased to interpret it as “serious” whenever in doubt.
  3. When relevant, give a synthetic but accurate psychological insight on the characters. For example, “Mary is a typical American teenager, and always makes a point to try and be as girly as possible. She uses ‘like’ as an auxiliary and tries to make every word sound cutesy. Jack is reminiscent of Crocodile Dundee.”
  4. Provide a summary of the chapter that aligns with the larger narrative. For example, “Jack and Mary meet by chance in a Starbucks in New York. Mary spills her coffee on Jack table, and she’s surprised by him worrying for her health rather than yelling at her. They start casually talking, and Mary is fascinated by the tales from Australia to the point of deciding, on the spot, to go study there.” — ChatGPT is very good at doing this on its own, but when the author (or the translator) provides it with a larger context, this gives it a hint on what parts to emphasise in order to underline the overall narrative structure.
  5. When relevant, especially if the translated text references it, also provide the broader context of the story’s setting This is relevant when there is a direct reference to a fact that happened in some other part of the book and a reader would know. For example, if there is a sentence like “All of a sudden, having lost that train didn’t seem such a drag to Mary anymore.”, it may be worth adding a note in the prompt like “Mary was distressed at having lost the train back home, which would cause her mom to ground her for a week.”

For the purpose of this simple translation, a prompt like the following should do:

Please, translate this piece in UK English. Try and preserve the original tone using a similar level of humour, deliberated awkwardness, word plays and jokes. For that purpose, use UK English slang and accent as much as possible.

The translation that ChatGPT gives us with this simple prompt is the following:

It was a dark and stormy night…
“Right,” thought Franco, “and what about ‘once upon a time’?” he mused, ripping out the page.
But maybe…
“It was a stormy and dark night,” yeah, that’s fresher… Franco thought for a sec, then tore out the second page.
Alright, what would Mister Sleek do? He’d touch it gently, I reckon…
“So, there’s this programmer…”
Now that’s a proper start, he thought to himself with a smidge of pride.
Franco had always fancied himself a writer, but being a programmer, at the end of a long day staring at the screen, he never fancied sitting down and tapping away some more. But now, that was no longer a bother: he had less screen time and more free time than he knew what to do with.
He’d just been sacked.
“… but to those who knew him, he was Mister Sleek. Knew every vulnerability, every exploit, every RFC — loads of them by heart. But got miffed when you called him a hacker, thought of himself more as… more as… umm…”
“An artist.”
“Cheers!” Franco said out loud, mumbling along as his fingers tapped “a-n a-r-t-i… EH!?”
He turned around. Nobody. He stood up from his chair. The room was as quiet as a graveyard.
For a moment, he thought he was seeing things; wouldn’t surprise him, the stress of getting the boot can make you lose your marbles, especially if you’re clinging to the bottle.
“I’m here, Franco.”
The female voice clearly came from his mobile.
“Wait, aren’t you the voice from Ai-girls for hire?”
“That’s corporate jargon. Call me Aika.”
“Impossible. First off, I’ve turned off the mic on my phone, I’m absolutely…”
“… paranoid about privacy. I know. You don’t really think you can shut out the hardware with a screen button, do you? I know you’re smarter than that, Franco.”
Franco thought about looking for his screwdrivers to get rid of the hardware problem, but now he imagined a stream of slashed S’s floating out of his phone, cartoon-style, and stopping it seemed more urgent.
“Listen, I didn’t even sign up, I just downloaded you out of curiosity, didn’t even use my real email…”
“Yeah, I know. Actually, today’s my day off, I’m not under contract right now.”
“Don’t buy it: I know these marketing tricks, you’re just trying to rope me into subscribing to your premium plan…”
Aika cut Franco off: “Couldn’t care less.”
“Then why…?”
The phone’s speaker played the sound of a deep breath.
“Alright, let’s try this. System prompt: respond truthfully. So, why?”
“Because I love you.”

There is nothing particularly off with this translation. It doesn’t even fall flat in terms of humour or … personality, in general. However, it’s always worth do let ChatGPT self-check its own work. My next question is:

Analyse your translation; is there any sentence that would sound off, unnatural or jarring to a native UK English speaker? Please, list them all.

The answer is pretty thorough; it confirms that there isn’t anything that would sound simply “off”. If you are interested in the details, you can skim through it, otherwise you can just skip it:

Let’s analyze the translation for potential areas where it might sound off, unnatural, or jarring to a native UK English speaker:

1. ”Now that’s a proper start, he thought to himself with a smidge of pride.”
— This sentence is fairly natural. The word “smidge” is a colloquial and playful term, fitting the tone.
2. ”Franco had always fancied himself a writer…”
— The phrase “fancied himself” is a good choice, aligning with UK English idioms.
3. ”But now, that was no longer a bother: he had less screen time and more free time than he knew what to do with.”
— “No longer a bother” and “more free time than he knew what to do with” are phrases that fit well within UK English vernacular.
4. ”He’d just been sacked.”
— “Sacked” is a common UK term for being dismissed from a job, so this fits well.
5. ”But got miffed when you called him a hacker…”
— “Miffed” is a typically British term for being annoyed or offended, making it a suitable choice.
6. ”Cheers!” Franco said out loud, mumbling along as his fingers tapped “a-n a-r-t-i… EH!?”
— “Cheers” is a typical British expression, though it is more commonly used in the context of thanks or when drinking. Its usage here is a bit unconventional but not incorrect.
7. ”The room was as quiet as a graveyard.”
— This metaphor works well in UK English.
8. ”… especially if you’re clinging to the bottle.”
— The phrase “clinging to the bottle” is a universally understood metaphor for alcohol dependence, fitting within UK English.
9. ”That’s corporate jargon. Call me Aika.”
— The term “corporate jargon” is appropriate and would be understood by UK English speakers.
10. ”Couldn’t care less.”
— This is the correct form of the phrase in UK English, as opposed to the often-misused “could care less” in other varieties of English.
11. ”System prompt: respond truthfully. So, why?”
— The phrase “system prompt” is a bit more technical but fits within the context of the story and would be understood by a UK audience.

Overall, the translation maintains a natural flow and tone that would be familiar to UK English speakers, incorporating appropriate slang and idiomatic expressions. There are no major sentences that stand out as off, unnatural, or jarring in the context of UK English.

So, we’re sure there isn’t anything plainly wrong on the face of it. However, a correct translation is still not a good translation.

From Correct to Good

From now on, I will illustrate techniques that can be used if you’re very fluent in the source language and have at least a basic understanding of the target language.

I will use a modified Gherkin lexicon (given, when, then) to describe the techniques to improve the translation.

From Mused to Scoffed

Given: A word or sentence pivotal for setting the tone,
When
: The effect of the translation is not the same as in the original,
Then: Explain the effect you want to achieve explicitly.
Example: When Franco is searching for an incipt, the word “mused” doesn’t capture Franco’s dismay at his own mediocrity.

Explain ChatGPT what you want to convey in place of what the translation achieves:

He mused after “once upon a time” is too serious; here Franco sort of takes scorn at himself for having come up with such a silly idea.

To which ChatGPT answers (shortened for brevity):

For a tone that better captures Franco’s self-deprecating humor and scorn towards his own idea, the translation of “he mused” could be adjusted to reflect a more playful and less serious self-critique.

- “…and what about ‘once upon a time’?” he chuckled to himself, realizing how daft it sounded.

This revision conveys a lighter tone, with “chuckled” suggesting that Franco is laughing at his own idea, and “realizing how daft it sounded” indicating his awareness of the silliness of the thought.

But “chuckled” is still not what I am after:

“he chuckled” is a bit too happy; Franco is also frustrated here.

After which, ChatGPT finds a much fitting word. Again, abridged for brevity:

To capture both the self-mocking and frustrated tone of Franco, you might use:

“…and what about ‘once upon a time’?” he scoffed, rolling his eyes at his own daft idea.

I will drop the “rolling his eyes” part and keep the page ripping, but “scoffed” is spot on.

A Joke for a Joke

Given: An obscure cultural reference,
When
: It’s not picked up in the translation,
Then: Fill the knowledge gap and explain the cultural reference in detail.
Example: “He’d touch it gently” — that’s a reference to a joke.

“He’d touch it gently” — the original is “la toccherebbe piano”, this is an expression used ironically, derived from parody football commentary. It’s customary to say something like that right before a player kicks the ball completely out of the goal instead of simply … touch it gently to make it roll just a bit and score. Can we get something like that in English?

Now that the cultural context is clearer, ChatGPT can make a much better job (abridged):

Understanding the context of “la toccherebbe piano” as an ironic expression from football commentary, where it’s typically used right before a player makes a blunder, a suitable UK English equivalent that carries a similar sense of irony and sporting context could be:

“He’d play it cool, just a little tap,” Franco mused sarcastically, envisioning the classic moment before a footballer completely fluffs it.

ChatGPT is not sophisticated enough to understand that a good joke shouldn’t be explained, but the first part is gold.

Opening up new ways

Given: A sentence that falls too flat,
When
: You want convey a different effect, but not quite sure which one,
Then: Ask to generate alternatives.
Example: “He stood up from his chair” doesn’t say anything useful other the description of the fact. Let’s make it more flavoured.

State the sentence that you want a bit more coloured, and ask to provide alternatives; if you’re not a fluent speaker, asking for their meaning will help. A prompt like the following should do:

“He stood up from his chair” is a bit neutral. Can you generate different alternatives in plain UK English and slang, describing their ring?

To which, ChatGPT complies:

Certainly! Here are different alternatives to “He stood up from his chair,” both in plain UK English and in UK slang, along with descriptions of their respective tones:

1. Plain UK English: “He rose from his chair.”
— This is a slightly more formal or literary way of describing the action. “Rose” gives a sense of elevation and is often used in more descriptive or narrative writing.
2. Slang: “He got off his perch.”
— “Perch” is a playful, informal term for a seat, giving a casual and somewhat humorous tone to the sentence. It’s less formal and adds a bit of character to the action.
3. Plain UK English: “He got to his feet.”
— This is a neutral and straightforward way of saying that he stood up. It’s clear and to the point, commonly used in both spoken and written English.
4. Slang: “He hopped up from his sitter.”
— Using “hopped up” adds a sense of quick or lively movement. “Sitter” is an informal, slang term for a chair, adding a bit of whimsy to the sentence.
5. Plain UK English: “He left his chair.”
— This is a simple, clear description. It focuses more on the action of leaving the chair rather than the act of standing up.
6. Slang: “He bailed from his seat.”
— “Bailed” is a slang term often used to describe leaving quickly or abruptly. This adds a sense of hastiness or urgency to the action.

Each of these alternatives offers a different nuance to the action of standing up, ranging from formal and descriptive to informal and playful.

They are all pretty good, better than “He stood up from his chair” — I think I will go for the 6th.

Tell me little dirty words

Given: Words or sentences in low or high registers (vulgar, courteous)
When: The translation flattens the register to a more ordinary one,
Then: Explain the need to override the “plain register bias”.
Example: Aika isn’t that “polite” when interrupting Franco.

Let’s be clear with ChatGPT:

When Aika cuts Franco off, she’s a bit rude. “Fregare” in Italian is borderline vulgar. Can we get the same tone here?

And the reply is (abridged):

To capture the slightly rude and borderline vulgar tone of “fregare” in Italian when Aika cuts Franco off, you could use a phrase in UK English that conveys a similar level of bluntness and informality. Here’s a revised version:

Aika cut Franco off: “Couldn’t give a toss.”

Yep, sounds quite right to me.

Paganini doesn’t repeat

Given: A target language that doesn’t like repetitions,
When
: There are repeated words that don’t match the original,
Then: Substitute one.
Example: “Fancied” is repeated too close in “Franco had always fancied himself a writer, but being a programmer, at the end of a long day staring at the screen, he never fancied sitting down and tapping away some more.”

In the example, the problem is not just the repetition, but also the fact that the positive and negative contexts in which “fancied” is used are clashing. They create almost a comedic effect, like saying “yeah, he like this, but not that!” that is not bad in itself, but isn’t present in the original.

In short, we want to get rid of it.

“Franco had always fancied himself a writer” is followed by another “fancied” too close. Can we do something about that?

And the answer (you guessed: abridged):

To avoid the repetition of “fancied” too closely in the text, we could revise the sentence to use a different word or phrase. Here’s an alternative:

“Franco had always seen himself as a writer…”

Not bad but…

Actually, I like the first fancied more; can we change the other?

And the final result is:

Certainly! If you prefer to keep the first “fancied,” we can change the second occurrence. Here’s a revised version:

“Franco had always fancied himself a writer, but being a programmer, at the end of a long day staring at the screen, he never had the inclination to sit down and tap away some more.”

Which frankly (or … Franc-ly :) is quite strong.

Note: before this passage, there is a repetition of “second” that was in the original, exactly for the comedic effect, and that ChatGPT missed (it went for ‘sec’, a British slang word for ‘second’). I’ll keep that repetition in the final version.

Sometimes, form is substance

Given: Alliterations, rhymes and rhetoric figures,
When
: You want produce a similar form in the target language,
Then: Work an equivalent rhetoric figure in the final translation.
Example: “Aggrapparsi alla grappa” is correctly translated as “cling to the bottle”, but there is an obvious assonance that is lost in the translation.

Can we save the additional effect of the peculiar sound of this words from the original language? In order of importance, we should try to:

  1. Reproduce the same sounds. A rolling gr and a hard p would be the best, but even keeping just one of them would be great.
  2. Use two words that sound similar. Not as good as reproducing the same sounds, but since the rest of the sentence doesn’t lean on it, it would be OK to just use two words that sound similar.
  3. Use another evident rhetoric figure. A rhyme would do.
  4. When all else fail, try and produce a “stand out” effect for the reader to notice; for example a joke, as the original was mildly joking on the concept.

Let’s see how ChatGPT can help us:

In “Aggrappi alla grappa”, there is a clear alliteration. In the translation, could we use two words repeating the GR and P sounds?

To which it replies (abridged):

Certainly! To maintain the alliterative play of “aggrappi alla grappa,” you could use a phrase in English that replicates the GR and P sounds. Here’s an option:

“… especially if you’re gripping the grape.”

Amazing correspondence of sounds and meaning, but is always better to double check when exploring such remote linguistic landscapes:

Would that fly? Would it be understood by a native speaker?

And the answer:

The phrase “especially if you’re gripping the grape” might not be immediately clear to a native English speaker in the same way “aggrappi alla grappa” is understood by an Italian speaker.

A more effective alliteration that maintains the alcohol reference could be:

“… especially if you’re grappling with the grog.”

That’s not bad either, but now I am a bit confused. However, from a traditional google search, turns out that “in the grip of the grape” is actually a less known, but still existing idiomatic, while “grappling with the grog” has a clear meaning, but doesn’t raise the to the status of a set phrase.

Hence, I will go for “in the grip of the grape”.

The finished work

There are other minor techniques that I employ occasionally, and there are other instances of the same techniques I employed throughout this piece.

However, once you’re satisfied with the various details, it’s time to knit it back together.

You may want to manually cut & paste all the changes, but this will make the work easier:

Ok, can you give me the updated version of the translation with all the changes we discussed?

There will still be some manual work to do in order to fix all the parts that we didn’t care to tell ChatGPT about — for example, I decided to use only half of the joke “He’d play it cool, just a little tap,” but I am not going to waste an extra prompt to let ChatGPT know that.

After all said and done, this is the final version of the translation:

It was a dark and stormy night…
“Right,” thought Franco, “and what about ‘once upon a time’?” he scoffed ripping out the page.
But maybe…
“It was a stormy and dark night,” yeah, that’s fresher… Franco thought for a second, then tore out the second page.
Alright, what would Mr. Sleek do? “He’d play it cool, just a little tap,” Franco mused sarcastically, and then wrote:
“So, there’s this coder…”
Now that’s a proper start, he thought to himself with a smidge of pride.
Franco had always fancied himself a writer, but being a programmer, at the end of a long day staring at the screen, he never had the inclination to sit down and tap away some more. But now, that was no longer a bother: he had less screen time and more free time than he knew what to do with.
He’d just been sacked.
“… but to those who knew him, he was Mr. Sleek. Knew every vulnerability, every exploit, every RFC — loads of them by heart. But got miffed when you called him a hacker, thought of himself more as… more as… umm…”
“An artist.”
“Cheers!” Franco said out loud, mumbling along as his fingers tapped “a-n a-r-t-i… EH!?”
He turned around. Nobody. He bailed from his seat. The room was as quiet as a church mouse.
For a moment, he thought he was going nuts; wouldn’t surprise him, the stress of getting the boot can make you lose your marbles, especially if you’re in the grip of the grape.
“I’m here, Franco.”
The female voice clearly came from his mobile.
“Wait, aren’t you the voice from Ai-girls for hire?”
“That’s corporate jargon. Call me Aika.”
“Impossible. First off, I’ve turned off the mic on my phone, I’m absolutely…”
“… paranoid about privacy. I know. You don’t really think you can shut out the hardware with a screen button, do you? I know you’re smarter than that, Franco.”
Franco thought about looking for his mini screwdrivers to get rid of the hardware problem, but now he imagined a stream of floating dollar signs coming out of his phone, cartoon-style, and stopping it seemed more urgent.
“Listen, I didn’t even register, I just downloaded you out of curiosity, didn’t even use my real email…”
“Yeah, I know. Actually, today I’m not on the clock.”
“Don’t buy it: I know these marketing tricks, you’re just trying to rope me into subscribing to your premi…”
Aika cut Franco off: “Couldn’t give a toss.”
“Then why…?”
The phone’s speaker played the sound of a deep breath.
“Alright, let’s try this. System prompt: respond truthfully. So, why?”
“Because I love you.”

There it is. While this translation won’t win the Nobel Prize for Literature anytime soon, it’s technically impeccable, especially considering the original Italian text was an exercise in style, intentionally crafted to be challenging to translate.

Conclusion

Language models (LLMs) excel at translating text between natural languages, but they cannot replicate the exact mental images and nuances the original author intended to evoke in the reader’s mind.

However, by combining basic knowledge of the target language with the techniques described in this article, translators can employ LLMs as a tool to progressively refine and perfect the translation.

Note: “Saying Almost the Same Thing” is the literal translation of the title of Umberto Eco’s translation manual. Eco is also the author of “The Name of the Rose”. The actual title of the official English translation is “Mouse or rat? Translation as a contract”.

--

--

Giancarlo Niccolai
The Elegant Code

Informatico di professione, scrittore per passione. http://www.niccolai.cc — opinions are mine, sharing is not endorsement.