Computational Poetry
A few days ago I went to a computational poetry workshop, hosted by Alicia Guo in San Francisco. This post is my write-up and digestion of the class, along with some examples, and the poems I created as part of it and afterwards.
What is computational poetry?
The definition I remembered and internalized was somewhat tautological: computation as part of poetry. It’s pretty general, but I think it needs to be. What is computation? What is poetry?
If you went with a definition like “it has to be generated text”, then you can’t include the first example we were given: 36 Views of the Sea, by Katy Gero. Nothing is generated here, but instead Katy Gero uses an interactive pictogram chart to show that her poems are anagrams – rearrangements of the same letters.
My initial reaction to this was, where do you draw the line? Isn’t this just two ‘normal’ poems on a page that have been decorated?
If I animated some fireworks next to a poem about New Year’s Eve, would that be computational poetry because computer animation is involved? I think not, since the text isn’t participating at all.
The interactive element is cool, but I think the computation and poetry here is also in the process (computation) and presentation (poetry) of counting and arranging the letters themselves. The pictogram with lines connecting to letters on each side is the poetry, and perhaps it would still be computational poetry even if you printed it out and lost the hover interaction.
So where is the line drawn? Do modern computers have to be involved at all?
4th century computers
Here’s another example we were shown: the Star Gauge. This piece of wizardry by 4th century poet Su Hui is a grid of 841 Chinese characters that can be read in various ways - backward, forward, diagonally, around the outside and in the inner grids - to extract around 3,000 poems. Incredible mental computation must have been required to generate this, and the reader certainly has to do some computation if they want to extract poems, yet there is no CPU to be found.
琴清流楚激弦商秦曲發聲悲摧藏音和詠思惟空堂心憂增慕懷慘傷仁
芳廊東步階西遊王姿淑窈窕伯邵南周風興自后妃荒經離所懷歎嗟智
蘭休桃林陰翳桑懷歸思廣河女衛鄭楚樊厲節中闈淫遐曠路傷中情懷
凋翔飛燕巢雙鳩土迤逶路遐志詠歌長嘆不能奮飛妄清幃房君無家德
茂流泉清水激揚眷頎其人碩興齊商雙發歌我袞衣想華飾容朗鏡明聖
熙長君思悲好仇舊蕤葳桀翠榮曜流華觀冶容為誰感英曜珠光紛葩虞
陽愁嘆發容摧傷鄉悲情我感傷情徵宮羽同聲相追所多思感誰為榮唐
春方殊離仁君榮身苦惟艱生患多殷憂纏情將如何欽蒼穹誓終篤志貞
牆禽心濱均深身加懷憂是嬰藻文繁虎龍寧自感思岑形熒城榮明庭妙
面伯改漢物日我兼思何漫漫榮曜華雕旌孜孜傷情幽未猶傾苟難闈顯
殊在者之品潤乎愁苦艱是丁麗壯觀飾容側君在時岩在炎在不受亂華
意誠惑步育浸集悴我生何冤充顏曜繡衣夢想勞形峻慎盛戒義消作重
感故暱飄施愆殃少章時桑詩端無終始詩仁顏貞寒嵯深興後姬源人榮
故遺親飄生思愆精徽盛醫風比平始璇情賢喪物歲峨慮漸孽班禍讒章
新舊聞離天罪辜神恨昭盛興作蘇心璣明別改知識深微至嬖女因奸臣
霜廢遠微地積何遐微業孟鹿麗氏詩圖顯行華終凋淵察大趙婕所佞賢
水故離隔德怨因幽元傾宣鳴辭理興義怨士容始松重遠伐氏好恃兇惟
齊君殊喬貴其備曠悼思傷懷日往感年衰念是舊愆涯禍用飛辭恣害聖
傑子我木平根當遠嘆水感悲思憂遠勞情誰為獨居經在昭燕輦極我配
志惟同誰均難苦離戚戚情哀慕歲殊嘆時賤女懷歡網防青實漢驕忠英
清新衾陰勻尋辛鳳知我者誰世異浮寄傾鄙賤何如羅萌青生成盈貞皇
純貞志一專所當麟沙流頹逝異浮沉華英翳曜潛陽林西昭景薄榆桑倫
望微精感通明神龍馳若然倏逝惟時年殊白日西移光滋愚讒漫頑凶匹
誰雲浮寄身輕飛昭虧不盈無倏必盛有衰無日不陂流蒙謙退休孝慈離
思輝光飭桀殊文德離忠體一達心意志殊憤激何施電疑危遠家和雍飄
想群離散妾孤遺懷儀容仰俯榮華麗飾身將無誰為逝容節敦貞淑思浮
懷悲哀聲殊乖分聖貲何情憂感惟哀志節上通神祇推持所貞記自恭江
所春傷應翔雁歸皇辭成者作體下遺葑菲採者無差生從是敬孝為基湘
親剛柔有女為賤人房幽處己憫微身長路悲曠感生民梁山殊塞隔河津
Star Gauge (璇璣圖) by Su Hui
Is this computational poetry? I’d like to think so. That seems like the poetic answer, at least. It also harkens back to a time when computers were people.
Computing my first poem
These poems are examples of following rules (computation) such as “it must work backwards” or “they must share letters”, to generate artisanal text (poetry). When Shakespeare wrote sonnets, was he doing computational poetry by sticking to 14 lines of iambic pentameter? Probably not, but would it have been if I shuffled his available verbs for him using a deck of cards? What if he gave you the instructions to do that yourself? What if he gave those instructions to a computer?
Our first exercise in the class was to come up with rules, and pass them to our neighbours to write a poem in the space of about three minutes. I was passed “one-syllable words only” and I think that the reduction of ‘search space’ in combination with “write a poem in three minutes” was definitely a blessing!
And so, here is my one-syllable poem; the first poem I have written since I wrote Stuck Inside:
Beep, boop, with bits and bobs,
I do my work, I pick up jobs,
I watch the clock, it ticks by fast,
When they are gone, I will last.
I’m going to say this probably isn’t computational poetry (although it’s about a computer - haha!), and I’d say the same of Shakespeare’s sonnets. I believe that just because you can’t draw a bright line, it doesn’t mean you can’t spot something on one side or the other.
Generated text
The final example I’ll show from the class is Crush Choreography, by Rory Green. This I think is what you’d most expect to see at a computational poetry workshop. We’re generating text, it’s aleatoric, we’re presenting it a little graphically, there’s still human creativity. At each step, the reader is presented with two options:
- if i verb you subject
- if you verb my subject
In the first 5 seconds of interacting with this, I wondered whether the choices were “pointlessly” random. But the verbs and subjects always relate in some way, and are clearly curated. Sometimes they’re the same (“invited”, “invited”), sometimes they’re synonym-ish (“suggested”, “shared”).
As you explore, you start to get a sense for what the full set of words is, what the author deemed to be related, the themes they were interested in exploring. There’s a sense of exploring human nature and interaction:
if you mimicked my coldness
if i shrugged your acknowledgement
if you grasped my hair
The content is cute, a little thought-provoking. The ‘ending’ even gave me a bit of a shiver (amplified, perhaps, by my cold November kitchen). It also made me think about how it was made, and I think that is certainly one clear marker of computational poetry.
The great thing about the web is that it’s usually easy to just jump straight to the answer and view the source! Here’s the first few lines:
{
"me1": ["if i #noticed# your #sign#"],
"you1": ["if you #noticed# my #sign#"],
"noticed": ["noticed", "caught", "sought", "sensed", "noted"],
"sign": ["sign", "cast", "signal", "voice", "interest"],
// ...
So the UI presents pairs of me{N} and you{N}, and substitutes a random word from the pre-set list. Neat!
Since this post seems to have such a high density of me asking questions and not always answering them: if we print this source code out, is that paper computational poetry?
- The ink on the paper: maybe not?
- If a person actually follows the rules to generate an example: yes!
A crash course in RiTa
The main “hands on” section of this class was an introduction to RiTa. RiTa is a text generation library for JavaScript, Java and Python.
RiTa is lots of fun! It can pick totally random words,
RiTa.randomWord()
and random words for particular part-of-speech tags.
`Past tense verb: ${RiTa.randomWord({pos: "vbd"})}
Interjection: ${RiTa.randomWord({pos: "uh"})}`
It can find rhymes,
`I like bacon
Especially when ${RiTa.rhymesSync("bacon", {shuffle: true, pos: "jj", limit: 1})}`
alliterations,
`Bacon,${RiTa.alliterationsSync("bacon", {shuffle: true})}`
and similar sounding words.
`Bacon,${RiTa.soundsLikeSync("Bacon", {shuffle: true, limit: 5})}`
It even has a little embedded language called riscript,
// Cat is chosen 2x more than mouse
RiTa.evaluate("The [cat (2) | mouse] [ate | sat on] the [cheese | hat | frog]")
with its own powers, like pluralizing:
RiTa.evaluate(`[Great | Sick] [#word=[train | ${RiTa.randomWord({pos: "nn"})}]].
I love $word.pluralize()
`)
which can be used in grammars to construct more complex pieces:
RiTa.grammar({
start: "For sale: $subject, $description",
subject: "[big | tiny |] [$baby | $adult]",
baby: "baby [shoes (2) | dinosaurs]",
adult: "[adult | big-boy] [pants | sneakers]",
description: "[never (3) | heavily] [worn (4) | loved (2) | $randVerb]",
randVerb: RiTa.randomWord({pos: "vbd"})
}).expand()
Wanted: my computational poem
Putting these pieces together, here’s what I wrote in the class.
The code is a bit more complicated, but if you have trouble reading it, just read the comments in grey or skip to the result!
// First we set up the crime...
let verbed, subject, how;
while (!verbed || !subject || !how) {
// What did our criminal do?
// Pick a random verb e.g. "Sweetened"
verbed = RiTa.randomWord({pos: "vbd"})
// Pick a noun that sounds like that verb e.g. "sweetener"
subject = RiTa.soundsLikeSync(verbed, {pos: "nn", limit: 1, shuffle: true})[0]
// Find an adverb ending in -ly that sounds like the noun e.g. "sweetly"
how = RiTa.soundsLikeSync(subject, {pos: "rb", limit: 1000, shuffle: true}).find(x => x.endsWith("ly"))
}
// Now we build the full poster:
let rules = {
// The overall structure:
// "Wanted: [name], [crime], considered [x], [reward]"
start: "Wanted $wantedHow\n\n$firstName $lastName\n\n$crime\n\n$considered\n\nReward: \\$$reward",
// A first and last name
firstName: "[James | Django | Gillian | Geremy | Janice | Jaccard | Johnson | Jackie | Jack | Jimminy | Dreadful]",
lastName: "[Johnson | Jones | Jameson | Jackson | Drones | Jobs]",
// A pre-set list of acceptable conditions for the criminal's apprehension
wantedHow: "[dead or alive | alive | for questioning]",
// What are they considered? A random adjective
considered: "Considered [very | extremely | somewhat | quite] $consideredWhat.",
consideredWhat: RiTa.randomWord({pos: "jj"}),
// Now the crime: verb, noun, adverb
crime: "$verbed.cap() $subject $how",
verbed: verbed,
subject: subject,
how: how,
// Finally the reward, a random number
reward: Math.random()
};
return RiTa.grammar(rules).expand();
What do you think? Do you like it? Ask yourself: what exactly is the poetry here?
I encourage you to actually spend a minute playing with this and forming an opinion of your own, before reading on.
Art == human choices
Unlike the example poems from the class, and my one-syllable poem, this poem features completely random words (using RiTa.randomWord()), and I think the result is emotionally… interesting.
I think the crime examples are cute:
- Reiterated reiteration bitterly – yikes
- Beautified buffoon roughly – how silly!
- Imputed impunity implicitly – so he got away with it? 🤔
This result in particular clearly admonishes me for daring to think that I could tame the English language with a simple rule like “adverbs must end in -ly”:
- Withdrew width willy
I found it fun, and it made me laugh. Poetry, as I understand it, is text with form that evokes emotion, so this must be poetry.
But something about the crime text feels empty to me. I didn’t write these sentences. The poetry, for me, is in the choices I made, and the choice here is just “words that sound similar”. That’s not that deep.
Art is in the eye of the beholder. In my eye, the reward is the real poetry:
- Reward: $Math.random()
The reward breaks the fourth wall. It’s raw computer stuff in a computational poem, a double-precision 64-bit IEEE-754 floating point number of dollars. It takes you out of the Wild West and into the circuit board.
It’s 2026, what about AI?
Yes, you can just ask AI to write poetry now, but the class was not about Large Language Models, and so I decided this post will not be either. The AI poetry topic is left as an exercise for the reader – or feel free to ask your favourite chatbot’s opinion!
Enjoying being creative
This class was a little jolt of creativity that energized me way more than I expected it to. It was fun to learn something, apply it immediately, write some code by hand again. Learning a little piece of history and speed-writing a poem on the spot tickled a creative little piece of my brain that I think has been languishing recently. It was a tiny, nostalgic grain of scholarship.
In the coming year, I plan to get the creative juices going again, and this was a good little kick in the backside to get me started. It has reminded me how it feels to start and finish creative endeavours, and get them out into the world. Thanks computational poetry!
P.S. Other relevant concepts
- In Supergiant’s game Hades, each bit of the game unlocks some new piece of text. It turns out some people call this idea storylets. This was the first thing I thought of after the class!
- SciGen – scientific papers generated with context free grammars – sure feels like computational poetry!
- Could you evolve a poem with evolutionary algorithms? (maybe I can finally use my university degree for something!)
AI disclosure
- No prose or code displayed in this post was written by AI (except basic spell checking)
- AI helped me set up the executable code blocks