Repetition

Zach Whalen
University of Mary Washington

Computational text generation is having a moment right now, with large-language models at the forefront of what many people may have in mind when thinking about computer-generated text. A major shortcoming of these approaches—including ChatGPT, Bard, and similar systems—is their opacity. It is difficult, and probably impossible, to explain the origins of any specific textual prediction generated by these systems, so writers working with these systems have to think carefully about the ethical implications of any text produced. The assignment or exercise below is, in contrast to the AI language models currently in vogue, minimalist and fully transparent in its operations. Students working with this beginner-level programming exercise in repetition can, in spite of the nominal simplicity of the prompt, nevertheless produce computational literary works that surprise and delight. This can be an opportunity for students to learn how other poets have used repetition in their work, and by asking students to explain or defend their choices, the activity can open a discussion about the ethical decision-making involved in the data curated for LLM training.


Learning Goals: 

  • Learn about the poetics of repetition and how it has been used in other contexts including conceptual writing and computational literature.
  • Gain experience applying a fundamental programming concept -- iteration with a for loop—to accomplish a specific task
  • Understand their own creative ideas in the ethical and social context of prior art 

Original Assignment Context: Elective digital studies course

Materials Needed: Basic instructor and student programming experience preferred: 

  • For courses focusing on Python, Google Colaboratory Notebooks provide a convenient and accessible platform. The random module may be a useful addition.
  • For courses focused on JavaScript, p5.js provides a useful suite of functions (including random()) and a convenient, accessible, web-based editor. The Bindery.js library provides a relatively straightforward means for presenting generated text in the format of a printable book.

Time Frame: ~2-3 class sessions


Introduction

“Repetition” is an in-class exercise, a sort of “Hello World” for programming computational literature and a warm-up for more complicated text generation to come later. In Creative Coding classes where an assignment is built around NaNoGenMo (National Novel Generation Month), this exercise serves as a gentle introduction that is, like NaNoGenMo itself, deceptively minimalist in its criteria. NaNoGenMo challenges participants to write code that will generate a novel of at least 50,000 words, and this exercise simplifies that challenge by asking students to write code that will generate the same word or phrase 50,000 times. 

“Repetition” serves several purposes. More experienced students may enjoy finding different methods for creating a string with the same word an arbitrary number of times or adding features like punctuation to imply sentence structure. But for beginners, this is a good introduction to the concept of iteration with a for loop, as Figure 1 demonstrates in Python.

book = '';

for i in range(50000):

book += 'BLINK ';

print(book)

Figure 1: An example code snippet that fulfills this exercise using Python. (I call this one Broken Turn Signal.)

 

For any student—novice or expert—the true challenge remains the same: given the freedom to repeat any word or phrase, what word or phrase will make an interesting choice? More importantly, are there words or phrases that would be harmful? If so, how can poets avoid those problems, and what should they do when the aesthetic goals of the work and the imperative of ethical practices are in tension?

In some implementations of this exercise, I have also provided a working, precomposed template that uses the repetition code to create a text string that is then formatted into a nicely-arranged PDF document. Because the code necessary to format the bookish PDF involves additional libraries and contexts (HTML and CSS), providing the template allowed my students to separate the task of composition from the friction and time-sink of implementation. True, there are significant design and organizational options framing the materiality of the final book, but these are decisions and adjustments that can be addressed and individualized later. To go from nothing to a completed book in so little time can be an important confidence booster for students, and it is debatable (and a debate worth having in class or in small groups) whether the more complex options like randomized punctuation will improve the work. That depends more on the poetic objectives of the piece and less on the nuts and bolts of implementing the code for those variations. 

For inspiration, or to provide context for students skeptical of the poetic merits of their exercise, it has been helpful to share examples of prior art demonstrating the poetics of repetition and the different meanings it can suggest. This background can include more familiar works like Edgar Allan Poe’s “The Bells,” a relatively short poem in which the eponymous instrument is named 62 times. Or it could be helpful to contrast Aram Saroyan’s “Crickets” with the typographically similar “Soldier” by Emmett Williams, highlighting the differences of meaning that a single word can make. Marcella Durand’s “Pastoral” introduces an eco-poetic application of repetition by creating a sense of figure and ground within the poem that calls attention to anthropocentric features of a natural landscape. 

Computational literature, the focal point for this unit in my class, also abounds with precedent, especially previous entries to NaNoGenMo like Crow Storm (2014), which repeats the avian utterance, “caw”, Buffalo (2013), the anxiety-simulating Election 2020 (2020), or the persistent, percussive precipitation of A Rainy Day (2018). Each of these has unique contexts and purposes, so an in-class reading of these existing works—especially reading them outloud—reveals more complex uses of repetition and variation than one might expect. In Crow Storm, one might recognize morbidflight’s reference to a League of Legends action, or one might simply be reminded of the kind of outdoors moment when a cacophony of cawing suddenly draws attention. Buffalo by Johana Strand plays out the linguistic quirk whereby the word, “Buffalo,” repeated a certain number of times is a grammatically complete sentence. And in Election 2020, Leonardo Flores employs randomness to simulate the experience of bouncing anxiously between news sources awaiting the outcome of the 2020 US Elections.

Examples of prior work by students can also be encouraging while providing further inspiration. One student’s generated book titled Ur Mom started as a joke about the eponymous playground insult but ended up creating a simulation of living in a house with a toddler. Another student used the repetition formula to create a work conveying her stressed-out state of mind at that point in the semester.

 

Figure 2: Excerpts from Ur Mom by Addy Reeher (shared with permission) and Today’s Thoughts by Abigail Williams (shared with permission).

 

The key thread in all these examples is the alignment of intention with an ethos of accountability toward the process, characteristics which stand in contrast to text generated through AI language models like ChatGPT. Few as they may be, each grammatical, semantic, and typographic feature of a poem or book constituted through repeating words or phrases can be traced to a deliberate choice by the poet/programmer. Large-language models (LLMs), by virtue of their size and operation, obfuscate the textual sources that they are paraphrasing from when generating output. While there are ethical, pedagogical applications of these models, as other entries in this collection demonstrate, the literary, ideological position of LLM-generated text remains largely untested. Rote repetition, even with randomized variations, may appeal to admittedly esoteric aesthetic interest, but the concept expressed is, generally speaking, quite clear. In a course that includes various methods of text generation, that sense of clarity can provide an entry point for critiquing LLMs or it can help orient and motivate more complex programmatic textual operations in later projects.

Goals and Learning Outcomes

By completing this exercise, students will

  • Learn about the poetics of repetition and how it has been used in other contexts including conceptual writing and computational literature.
  • Gain experience applying a fundamental programming concept—iteration with a for loop—to accomplish a specific task
  • Understand the aesthetic and ethical stakes involved in selecting language for a generative program

Materials Needed

This exercise will likely work best where students have already experienced some programming and will be doing more programming as the course progresses. Writing code that repeats an arbitrary string of text is language-agnostic, so it can be adapted to many different platforms and languages.

  • For courses focusing on Python, Google Colaboratory Notebooks provide a convenient and accessible platform. The random module may be a useful addition.
  • For courses focused on JavaScript, p5.js provides a useful suite of functions (including random()) and a convenient, accessible, web-based editor. The Bindery.js library provides a relatively straightforward means for presenting generated text in the format of a printable book.

The Assignment

Repetition (CC-NA)

Brief

In this exercise, you will program a computer to write a book. In accordance with the requirements of NaNoGenMo (National Novel Generation Month) your book should contain at least 50,000 words, and ideally it should be printable as a PDF document and formatted so that it looks like a conventional book. We will explore more complex methods of text-generation, but for now, a single word (or phrase) repeated an arbitrary number of times will suffice.

Getting Started

Create a new sketch in your p5js.org account, and copy the following lines into the setup() function.

let book = '';
for (let i = 0; i < 50000; i++){
book += "WORD ";
}
console.log(book);

On the third line, change the word, “WORD” to something else -- anything you can think of -- and run the code. Your book will print in the JavaScript console at the bottom-left of the p5js editor. 

What word did you choose? Why? Discuss and compare words with people nearby.

Background

Poets and writers have long used repetition (with and without the aid of computers) to accomplish various meanings. Read 2 or more of the following examples—read them out loud if possible—and discuss with your neighbors how repeated words or phrases in those examples drives the work toward its poetic, ideational, or satirical objectives. (Or anything else that you think it accomplishes.)

Taking it Further

Now that you’ve completed a computer-generated book, what will your next book be? What features are missing to make it feel more like a book? Would varying the word or adding randomized punctuation marks contribute to your book’s meaning, or would it be a distraction?

Build off of the example you started, or use this starter project implementing layout with Bindery.js to build on your first book or make a new one. Share the results with your neighbors, and be prepared to explain your choices and your interpretation of the meaning behind your book.