A Demo of How NLP Transformer generates texts

Following the last blog, “Natural Language Processing: How AI Components take your business to the next level”, it is time to experience how such an NLP model works in practice.

The pre-trained transformers are among the most powerful NLP models. In this blog, we want to demonstrate a small piece of their problem-solving functions - the text generation. In the next blog, we are going to have a deep dive into the technical details and the associated solutions.

After the pre-trained transformers are hosted behind API gateways, users can harvest the result through the defined APIs and adapt them to special utilities (the Fine-Tuning). In our case, the model responds to the prompt input by the user and delivers the text. It reacts even to very odd topics: for example, “Shakespeare and the Climate Changes”. Please check the following two pieces of text up, that are purely generated by the model without any modification:

Title: What if the characters in Shakespeare's plays were affected by climate change?

In Shakespeare's plays, the characters often experience extreme weather conditions that affect their moods and behavior. But what if the characters were actually affected by climate change?

In a world where the climate is changing, the characters in Shakespeare's plays would have to deal with the consequences of a warmer world. For example, in the play Julius Caesar, the title character is assassinated during a hot summer. In a world affected by climate change, that summer would be even hotter, and Caesar's death would be even more likely.

In Romeo and Juliet, the lovers experience a tragic ending because of the feud between their families. But in a world affected by climate change, the feud could be exacerbated by the fact that the two families are on different sides of the issue. One family could be struggling to adapt to the changes while the other is thriving, and the conflict between them would be even greater.

In The Tempest, the island is threatened by a storm. In a world affected by climate change, that storm could be even more destructive, and the characters would have to deal with the aftermath of the devastation.

Shakespeare's plays are full of drama and conflict, and in a world affected by climate change, those conflicts would be even more intense.

And …

Title: A short poem by william shakespeare about the climate change

"The world is changing, my lord,

The climate shifting, the seasons blending,

The ice melting, the waters rising.

We have brought this on ourselves,

And now we must pay the price.

The world is changing, my lord,

And we must change with it,

Or be swept away."

The following video clip demonstrates how a Python application generates the content by simple interactions with the user and leads step-by-step to the result.

A well-tuned proper model can do more: it can complete your text, it can classify your document, it can generate an icon for your product, it can also write SQL statements for your query. Interested? Contact us or be prepared to have the deep dive into the techniques behind the demo in the next blog.

To further PwC Blogs

To the top