AI creates plays: How did STACC make robots to write, and act plays inspired by Chekhov?

AI creates plays: How did STACC make robots to write, and act plays inspired by Chekhov?

Did you know that robots aren’t just made for scrubbing the floors and other types of dirty work? They can be used to do lots of other exciting things, like theatre. To break the cult of robots scrubbing floors and mowing lawns, MEDIT researcher Liina Keevallik took it upon herself to do something particularly cultural and beautiful with robots – robot theatre.

Robot theatre aims to teach robots to create complete plays. This starts with writing the script, but the robots also do the directing and performing. This somewhat extravagant venture is dedicated to the robots themselves. MEDIT researcher Liina Keevallik is the mastermind, the soul, and the brain behind the Robot Theatre project.

Why theatre by robots? Liina gives two main reasons:

  • Robots were NOT DESIGNED to be floor cleaners or for other types of “dirty work”, although they have found many uses in these areas.
  • The word “robot” will turn 100 years old in 2021, and this is something to celebrate.

In fact, the word “robot” was first used by the Czech writer Karel Čapek in his 1921 play. Since then, however, the role of artificial intelligence in the spoken word theatre has remained relatively non-existent. With the Robot Theatre project, we are trying to fill this gap.

The Robot Theatre project brings together researchers, students, and artists from various walks of life. The project leader, Liina Keevallik, has worked as an artist in various Estonian theatres as well as freelance, and she has a PhD from the Estonian Academy of Arts and the University of Paris.

The students from Tallinn University involved in the project state their goal as follows:

‘To create an independent and logical work, we want to understand the logic and the volume of the play we need to teach the machine to write. As there is little and tentative theatrical collaboration with AI in Estonia, we hope to provide valuable experience and teaching material for the future. In that way, the enthusiasts will have more domestic examples to draw upon. Broadly, the aim of this endeavor is to understand the potential of using AI in the creative process.’

Students from Tallinn University

The focus of STACC’s data scientists has been to create an Artificial Intelligence that can generate a play text suitable for staging.

How can machines be made to think and act more creatively?

The biggest and most ambitious goal of the Robot Theatre project is to get machines to think and act creatively. As already mentioned, the idea of using artificial intelligence in the performing arts has been floated before, but at least in the case of spoken theatre, no outstanding results have been achieved. However, we do have active competitors – namely in the birthplace of the word ‘robot’, the Czech Republic. Their project is called THEaiTRE (www.theaitre.com), and it also aimed to create a play written by artificial intelligence. A clip of their experiment can be seen here:

Watching both, this film, and the excerpt from the Czech theatre production, it becomes clear that the script is absurd, and it only has merit thanks to the actors’ efforts with emotions. The text and the dialogue exist, but there is a lack of logical structure to make the work a coherent whole.

Our goal is to aim even higher – to generate an AI text that makes sense. Not by taking away the machine’s creativity and forcing it to imitate human creation, but to find a balance between abstraction, logic, and absurdity. Chekhov’s plays, which look at human nature as if through a microscope, make a major contribution towards this goal.

Artificial intelligence that can write a play

STACC’s data scientists were tasked with the development of artificial intelligence that can write a new play based on an existing Anton Chekhov piece. “Generating a grammatically correct text is no longer a problem for today’s large language models. Nevertheless, the task was challenging: how to convince AI to generate a play with a reasonable content, structure, characters and storyline by using texts from only six plays?” commented STACC’s data scientist Dage Särg. “Luckily, we had a team of dozen enthusiastic students who were willing to annotate the data to make the learning process for the soon to be created AI run more smoothly,” added STACC’s data engineer Karl-Oskar Masing. Thus, several long discussions helped to set and annotate the structure, events, and themes of the play, as well as the emotions.

“To generate the Chekhovian text, we used OpenAI’s freely available GPT-2 language model, which we fine-tuned with our own Chekhov plays. This resulted in a text generator, who we named John. We could then teach it in different ways the structure and other elements of the play, by using a trial-and-error approach,” commented Särg.
“To generate a complete play, we developed a multi-step process using a trial-and-error method. First, we trained a recurrent artificial neural networks-based model on the labelled plays. Based on the sequences of labelled units, the model learned to generate new Chekhovian sequences – how themes and emotions alternate in a performance,” added Särg. In this way, a ‘structure’ or backbone of the play emerged, part of which might look like the following:

A_HAPPY_EVENT
DECLARING_LOVE
THE_PAST
THE_FUTURE
NATURE
GETTING_BAD_NEWS
SADNESS
SHOOTING_AT_SOMEONE
HURTING_SOMEONE
IRRITATION
ANGER
DEPARTURE_FOREVER

Structuring and text generation

The next step was to generate a text corresponding to the structural elements. By using the sentences marked by the students as corresponding elements in Chekhov’s plays as ‘seeds’, the language model was asked to generate a corresponding text.

In addition to structure and text, a play also needs characters. “In order to generate these names, we trained a character-based model on the names of Chekhov’s characters. This resulted in a number of great new characters – Allekin, Meripanna, Kuzenbie, Chacha and Macha Soff, Serstioff and Lobe An,” comments Särg.

According to Särg, one of the most difficult steps was to connect the generated text with the characters and to divide the text logically between the characters. For this, we trained models again – the first one to teach the AI John how to switch between characters, and the second one to thematically distribute text fragments between characters. Finally, it was necessary to generate remixes of the text distributed between the characters – spoken word theatre is not just monotonously reading the text, it is more than that. To do this, we fine-tuned the GPT-2 language model with remarks from Chekhov’s plays, which allowed us to generate Chekhovian remixes of the text.

“The whole process of developing this logic took place over a period of more than a year and. For me at least, it gave a whole new depth to Chekhov’s works and to the theatre in general. Even though I’m quite active theatergoer, I have never delved into the ‘other side of the theatre – the creative and staging process. It was very exciting to work with experts in the field to decipher the problems and then, in turn, use my own specialized skills to get artificial intelligence to solve them,” said Särg.

A program that uses artificial intelligence methods to create complete plays

The work of STACC’s data scientists has resulted in a program that uses artificial intelligence methods to create complete plays. An excerpt from the text of the play looks like this:
[ BOREDOM]
ALLEKIN…
{She kisses his hands}
MERIPANNA: I have been sitting here all night thinking of an idea. I have no other business here.
*
{Laughing through her tears}
MERIPANNA: I had this book with me. I read it often.
{Looks through the book}
ALLEKIN :  [ LOVE_TOPIC ]  Tell me, do you love anybody?
{Joyfully, through her tears}
FEDONI: I have only one wish: that everybody should please me.
{Stretches himself}
THABOLIND VAKAN :  [ THE_MEANING_OF_LIFE ]  Scientifically speaking, no theatre is possible.
{Softly, through his tears}
MERIPANNA: It’s a pity. Your stepmother is a great actress, and I’m a concert pianist.
{She embraces his knees}
ALLEKIN: A concert pianist!
{Stops her ears.}
MERIPANNA: Yes, the hobby has paid off.
{Stops her ears.}
FEDONI :  [ MONEY ]  Come, have a drink and supper, we can go to bed early.  Here they are again.
{Exciting himself}
ALLEKIN: The water is really cold.
{Shakes her fist.}
MERIPANNA: I should be cold, too, if it was not for the long sleeves and the long pants.  I want to dance, darling.
[ HAPPINESS ]
{Still following her}
The participants, including the robots, have already rehearsed staging and performing the play. A rehearsal took place in December at the VITA blackbox, excerpts of which can be seen on Artificial Chekhov’s Facebook page, for example, a play-through of the first scene.

In summary

The nature of the undertaken task makes the assessment of the results particularly complex. In the case of text generation tasks, it is very difficult to quantify whether the result is “right” or “wrong”. For example, in machine translation, this is attempted by assessing the similarity of the output of the machine translator to that of the human translator. However, a similar approach cannot be used for a creative text. On the one hand, we want to generate a new Chekhov play. On the other, the closest possible resemblance to an existing play is by no means the goal. We want to create something new, something that will offer the human audience an experience. Therefore, the evaluation is also qualitative and based on everyone’s own intuition – as always with culture.

In any case, it has been a very interesting process for all parties involved, allowing people from different walks of life to look at areas that are completely alien to them and to try to find solutions together to interdisciplinary problems. Liina Keevallik has described the co-operation with STACC’s data scientists as follows: “In the field of art, it’s not often that you get the chance to work with professional IT people. It is an extremely enriching experience. Moreover, STACC’s Karl-Oskar Masing and Dage Särg are exceptionally enthusiastic and creative partners. I am looking forward to the first stage performance of our joint AI offspring.”

We expect the same. If you’re interested in a data science or machine learning project, or would like to collaborate with us, please feel free to get in touch: https://stacc.ee/contact-us/

Credit: Adi Bulboacă