GPT -2-based Human-in-the-loop Theatre Play Script Generation (2022)

Abstract: We experiment with adapting generative language models for the generation of long coherent narratives in the form of theatre plays. Since fully automatic generation of whole plays is not currently feasible, we created an interactive tool that allows a human user to steer the generation somewhat while minimizing intervention. We pursue two approaches to long-text generation: a flat generation with summarization of context, and a hierarchical text-to-text two-stage approach, where a synopsis is generated first and then used to condition generation of the final script. Our preliminary results and discussions with theatre professionals show improvements over vanilla language model generation, but also identify important limitations of our approach.

## introduction natural language generation (nlg) is currently dominated by large pre-trained language models, such as @xcite . the models show especially strong performance in generating short to medium length in-domain texts, such as news stories, which fit into the window size of the model (e.g. 512 or 1,024 subword tokens). successfully handling significantly larger and/or out-of-domain documents is a matter of ongoing research @xcite @xcite . in the theaitre project, we focus on generating theatre play scripts. this task combines the challenges of narrative generation @xcite and dialogue generation @xcite , and could be seen either as generating dialogues with a very large context, or as generating a narrative in the form of a dialogue. additional challenges include the complex structure of the theatre scripts (including setting descriptions, dialogue lines with character names, and stage directions), their very * archival wnu submission. large length, their pseudo-multi-author nature (as lines pertaining to different characters use different styles and represent different standpoints), or the low availability of large in-domain datasets. we investigate the capabilities of current nlg approaches on this task. specifically, we use and adapt current large pre-trained neural language models and employ other relevant natural language processing (nlp) techniques to adjust the existing approaches and tools to the theatrical script domain. our aim is to produce a mostly automatically generated play, with minimal human-in-the-loop interventions, and have the generated play rehearsed and staged by a theatre. we build upon our previous work @xcite , where we produced a generated play by using vanilla gpt-2 and generated individual, loosely connected scenes, but now aim at full play generation. in order to do so, we explore a two-phase hierarchical text-to-text approach, where a synopsis is generated first and then used as a basis for subsequent generation of scenes. we compare this method to a flat generation approach with summarization, which is similar to our previous work @xcite . we use models finetuned on in-domain theatre or movie scripts to better fit the domain, and we allow minimal but precise human intervention using a custom-built web-based interface: regenerating a line, choosing the next character to speak, deleting or inserting a generated or a human-written line into the script. all human interventions are recorded. a simplified demo version of the tool used for the generation is freely available online. 1 we include preliminary intrinsic evaluation and discuss qualitative feedback given by the theatre professionals. our results support finetuning and more precise human intervention; however, the two-stage hierarchical approach shows difficulties following the pre-generated synopsis. ## related work our approach is inspired by the work of @xcite and @xcite , who propose a hierarchical system for story generation. a similar idea has been explored by @xcite , who generate a story conditioned on a given outline. @xcite approach long text generation by generating domain-specific words first and then iteratively refining it until whole sentences are formed. unlike these works, we generate scripts rather than stories, i.e. not prose but dialogues, which are also longer than typical stories. for dialogue generation, @xcite 's work is close to our baseline flat approach (section 3) in that they generate long dialogues by using summarization. a few works also investigate human-machine interaction during text generation, with different aims from ours: roemmele (2021) investigates how automatically generated texts can inspire human writing. @xcite use the amount of required human post-editing as a story quality metric. a number of language generation tools is available online, both free and paid, typically based on gpt-2 and gpt-3 language models @xcite , sometimes trained or fine-tuned for a specific domain or task. prominent examples include news generators such as grover foot_1 by @xcite or news you can't use foot_2 by @xcite , the text adventure game ai dungeon, foot_3 the code completion tools github copilot foot_4 or deep tabnine, foot_5 and chatbots such as ai|writer or project december. 7 however, to the best of our knowledge, no generation tool has been released specifically for theatre scripts. there have been several other projects using automatically generated scripts, including beyond the fence, a musical based on suggestions from several automated tools @xcite , sunspring, a short sci-fi movie with an lstm-generated script @xcite , lifestyle of the richard and family, a theatre play written with the help of a next word suggestion tool @xcite , or the performances of the improbotics group who improvise on stage with real-time gpt-3-generated lines @xcite . however, the domain # scripts avg. # lines avg. # sentences movies 1,067 783 2,537 tv shows 6,057 314 902 theatre 5,517 530 1,529 all 12,641 446 1,310 ## flat generation with summarization the flat generation variant is based on our previous approach @xcite of using a standard generative model but employing extractive text summarization to deal with the limited window (1,024 tokens for gpt-2) so that longer scripts can be generated without the loss of the global context. instead of using a vanilla gpt-2 model as in our previous work, we finetune our models on a large collection of ca. 12k theatre and movie scripts. the domains and volumes of data can be found in the operation of flat generation looks as follows: the user inputs a scene setting, character names and their first lines, from which we construct the input prompt in the following format: scene setting. character name: character line. ## two-phase hierarchical generation our second, newly developed approach is a twophase text-to-text hierarchical generation approach: (1) a synopsis is generated from a user-supplied play title, (2) the play dialogue is generated, conditioned on the title and a part of the synopsis. both phases use specific models finetuned on our indomain datasets. the input for the first phase is the title of the play, from which the synopsis of the play is generated (figure 3 , section 4.1). at each step, the user has the option of continuing generation, regenerating or deleting lines (roughly corresponding to sentences). once the user is satisfied with the generated synopsis (or the generation ends by the model generating the endoftext token), the synopsis is used as input for the second phase. in the second phase, shown in figure 4 , the play script is generated from the synopsis (see sec-a notebook full of ideas was stolen from an unbuttoned backpack by a mailman in a blue vest. a man named tom, a man in a trench coat, arrives to deliver the notebook. tom tries to leave, but is interrupted by the arrival of his mailman brother, jerry, in his mail truck. jerry offers to take tom to his house, but tom is determined to deliver the notebook. as tom drives through the cornfield, he accidentally stops at a house, which he mistakenly assumes is inhabited by the owner, a widowed woman named marjorie. she tells him she is waiting for tom to come home, and she and tom go into the house together. jerry arrives and finds tom's truck with the notebook, having accidentally left it in the truck while searching for jerry, and is surprised and angry to find marjorie there. figure 3 : an example for hierarchical generation 1st phase: title to synopsis (input title shown above the dividing line, the play follows below). tion 4.2). the user is now provided with a set of options similar to the flat approach: at each step choosing between generating a character line (and potentially also choosing which character should speak the line) or moving on to the next part of the generated synopsis. ## discussion and limitations generating theatre play scripts is a complex task presenting many interesting challenges, many of which we have not yet been able to satisfactorily address, as we are continually being informed by theatre professionals. the main weakness of all our approaches is the inability to differentiate between individual characters to ensure their lines are cohesive while being distinct from other characters in the play. the theatre professionals consider it difficult to portray characters missing a consistent personality and motives behind the lines. while our past as well as ongoing experiments, employing natural language inference, line masking, and character pseudonymization, have shown promising results, they only seem to constitute partial superficial remedies for a deep and complex issue. in the future, we intend to approach the problem by adapting and employing current nlg personalization techniques @xcite . another serious problem, identified by the theatre professionals while working with our hierarchical setup, is the fact that the script generation often strays away from the synopsis. so far, we have been only operating with flat textual representations of script parts in the hierarchical setup, aligning parts of the script to parts of its synopsis. while we believe the currently available data leave us no other option, a more adequate approach should probably operate with theatrological abstractions over the script, such as the notion of dramatic situations of @xcite ; we have performed some small-scale annotations of 50 play scripts in this respect, but our exploratory experiments on the resulting dataset showed that we would require a much larger dataset to be able to employ current machine learning techniques, which is beyond our budget. unfortunately, corpora of theatrical texts, even unannotated ones, are virtually non-existent, and while we managed to acquire a modest dataset, copyright and licensing issues limit us from releasing most of it. the use of extractive summarization and hierarchical generation allows us to generate mediumlength texts (one or several scenes), but a fulllength script is still somewhat out of our reach. we believe further improvements could be brought by employing abstractive summarization @xcite , specifically trained for theatre play scripts. ## conclusion we created an interactive tool for human-in-theloop generation of theatre play scripts, with the aim of producing a stageable play with minimal human intervention. we pursue two different approaches, both based on finetuned gpt-2 models -flat generation with extractive summarization to maintain coherence, and a hierarchical two-stage approach, which first generates a textual synopsis and then generates individual scenes, conditioning on chunks of the synopsis. we release an online demo of our tool for interactive generation of the-atre play scripts. we are able to improve upon previous approaches using vanilla models, but our models still are not able to generate consistent personality or follow the synopsis accurately without human intervention. a demo of our interactive tool and its source codes are available online. 13 in future work, we plan to incorporate natural language inference checks @xcite or experiment with dialogue act semantic representations @xcite in order to increase coherence. to improve character consistency, we plan to follow percharacter personalization approaches @xcite .