ChatGPT for Text Style Transfer: Part 2

Ludi Rehak
4 min readFeb 26, 2023

--

Text style transfer (TST) is a NLP task that involves altering the style of text, while retaining its original meaning. The content of the text is preserved, but instead expressed in a different style. Some stylistic axes on which to alter text include its level of formality, humorousness, professionalism, friendliness, complexity, and offensiveness. For example, “Come and sit!” becomes “Please consider taking a seat.”, when expressed more formally. The tone changes, but not the meaning.

Six years ago, the closest I came to achieving TST was through machine translation, where computers translate text from one language to another. In a twist, I trained the underlying model to translate modern English to Shakespearean English and then applied it to Taylor Swift lyrics. That was fun, but limited in potential because of its burdensome training data requirements. It needed a pair of corpuses equivalent in content, with one in the current style, and another in the target style. In all the years since, I’ve never come across an application capable of high-quality TST.

Until now. ChatGPT can do text style transfer very, very well. Let’s take a look.

Less Formal 😁

Original company email about mandatory compliance training:

All employees will be required to complete the training within 30 days of being notified. Your Manager will be notified if the training is not completed within this timeframe.

Rewritten by ChatGPT:

Just a heads up that we all need to finish our training within 30 days of getting this message. If for any reason you can’t get it done in time, your manager will get a heads-up. But we know you’re all rockstars, so we’re not too worried about that ;)

Let’s knock out this training and keep crushing it!

Takeaway: The 30-day deadline is still expressed in the rewritten version. Stylistic changes included putting “manager” in lower case, giving emotional reassurance, boosting morale with over-the-top flattery, and throwing in an emoji.

More Formal 🙇‍♀

Original:

Hey dude, could you review my code. Totally don’t know what I’m doing here. Think I got a race condition or something. lol.

Rewritten by ChatGPT:

Dear [Name],

I hope this email finds you well. Would it be possible for you to review my code and provide feedback? I am experiencing some issues and believe there may be a race condition. I would greatly appreciate any insights you can offer.

Thank you for your time and assistance.

Best regards, [Your Name]

Takeaway: The request for a code review and the author’s suspicion that the code has a race condition is retained. The rewritten text adds formal salutations and a closing signature, reformulates the request more politely, using phrases such as “Would it be possible” and “I would greatly appreciate”, and removes the less formal expressions “lol” and “dude”.

Sassier 💁‍

Original:

I really like this red dress on you. It brings out your complexion and has a very flattering floral pattern.

Rewritten by ChatGPT:

Well, well, well, look who’s turning heads in this stunning red dress! It’s not just bringing out your complexion, but that floral pattern is hugging all the right curves. You’re looking like a walking garden of beauty, my friend!

Takeaway: The red dress and flattering floral pattern commentary are not lost in translation. A few new colorful, and decidedly sassy expressions are thrown in.

Meaner 😠

Original:

Could you stop asking me to remove this validation check just because you don’t feel like dealing with the underlying error?

Rewritten by ChatGPT:

Ugh, do I really have to spell this out for you? Quit whining about the validation check and actually put in the effort to fix the damn underlying error. Don’t be lazy and try to pawn off your responsibilities onto someone else.

Takeaway: “stop asking” changed to “quit whining”, which is a meaner way of conveying the same content. The word “damn” is added (a ‘bad’ word), and accusations of laziness are made explicit and brought to the fore, whereas they were more subtle in the original.

Snarkier 😝

Original:

I bought tickets to the zoo, but it wasn’t a simple process. First I had to create an online account, choose my pronouns, then call in since the online portal said there were no tickets left. When I called in, there were still some tickets, but that wasn’t the end of my journey. I still had to go back online to sign the liability waiver. This level of complexity and bureaucracy is frustrating.

Rewritten by ChatGPT:

Oh joy, I had the pleasure of purchasing tickets to the zoo. It was a real walk in the park, NOT! First, I had to jump through the hoops of creating an online account and selecting my pronouns. Then, when the website claimed that there were no more tickets available, I had to call in and miraculously, tickets were suddenly available. But, my fun-filled journey was far from over. I still had to navigate through the virtual maze and sign some liability waiver online. Because apparently, a trip to the zoo isn’t complete without an added layer of bureaucratic nonsense. Yay!

Takeaway: Again, the details of the original are preserved in the rewrite. The mix of frustration, irritability and humor that characterizes snarkiness is amplified in the original text with the use of “NOT!”, “miraculously”, and “virtual maze” to describe a confusing web sign-up process.

More Poetic 🌹

Original:

If you’re going to trash talk someone, make sure you have the right guy.

Rewritten by ChatGPT:

If thou intend to spew venomous words,

Be sure the intended target is deserved.

Else let not your tongue be the sword,

That unjustly wounds a blameless nerve.

Takeaway: ChatGPT returned a poem with Shakespearean flavor (“thou”) and an A-B-A-B rhyme scheme. It also elaborated on the original line of advice with the consequences of not following the advice, “unjustly wound a blameless nerve.”

In every case explored above, the target style was achieved, while also preserving the semantics of the original text. The rewritten versions were perfectly fluent. ChatGPT appears to be a very high-quality, minimal effort, zero-cost tool for text style transfer.

--

--