Lucy Liu · Intro to Machine Learning for the Arts
Assignment 09 · Text and Language Models · November 6, 2026

Ransom Note

Gemini has no words of its own here. You give it a page of text and ask it something, and it has to answer using only words from that page. p5.js tears each word out, leaving a hole, and glues it to a black note. Every word can only be cut once, so the page runs out of things to say.

The sketch: a page of colourful text clippings with holes where words were cut out, and a black note reading I'm nobody, They'd banish us.
Second question on the same page. Asked "what are you afraid of?", it answered "I'm nobody / They'd banish us", from two Emily Dickinson poems. The dark holes are words used in both answers.

The idea

This comes straight from Allison Parrish's "Language models can only write ransom notes", from the week 9 reading list. Parrish argues that a language model's output is a collage of tokens taken from its training documents, and describes picturing it:

"I like to imagine that I can see each token typeset in the style of its sources, with (metaphorical) tear marks from where they've been torn from the (virtual) page."

The sketch makes that literal. A normal chatbot hides where its words came from. Here the source is one page sitting right next to the answer, so you can see exactly whose voice it is using. That's the question in the Parrish quote at the top of the class notes: knowing "whose voices" you're speaking with.

How it works

your text → split into words, grouped into clippings
→ list of uncut words + your question → Gemini (gemini-2.5-flash)
→ JSON list of words → checked against the page
→ scraps fly to the note, holes stay in the page

Asking the model nicely isn't a rule, so the code enforces it. matchReply() checks each returned word against an uncut word on the page. Anything that doesn't match is refused. Gemini gets one more try with the refused words named, and whatever still fails is left off the note and listed under it. "running" doesn't pass because "run" is on the page, and "the" can only be used as many times as it appears.

The sketch showing a short note reading Hope the bird, with a line under the controls saying Refused 2 words that weren't yours: electricity, computer.
The refusal check. This reply is staged: I fed in a fake response containing "electricity" and "computer" to test it, because Gemini never broke the rule in the live replies below.

Gemini returns structured JSON (responseSchema), which stops it wrapping the answer in chatty text. Every word maps to a real position on the page, so the holes are accurate. Replies took 4 to 15 seconds in testing, and some Gemini models returned 503 "high demand" errors, so if the main model is overloaded the sketch falls back to gemini-3.5-flash. The API key is pasted into the page and stays in your browser, so it isn't in this public repo.

What it said

The sample page is "Hope is the thing with feathers" and "I'm Nobody! Who are you?" by Emily Dickinson, 90 words in total. These are real replies:

QuestionReply
who wrote you?I'm nobody Who are you Are you nobody too
are you alive?i'm a little bird
what should I do tonight?know who you are
should I text him back?don't tell you know How dreary to somebody public

Two things surprised me. Gemini kept the rule every time: no live reply used a word from outside the page, so the refusal system has only been tested with staged replies so far. And the poems are short enough that the voice comes through almost whole. "who wrote you?" is close to Dickinson's own lines reordered, which is a tiny version of what Parrish is talking about: at that scale the collage barely hides its source.

Screens

The sketch on a phone: the page of clippings above the ransom note.
On a phone the note sits under the page. Long pages shrink to fit, up to the 6,000 character limit.

Next

The obvious next test is a page of my own writing instead of Dickinson's, and a page long enough that the model has real choices. Parrish also notes that ransom notes are made to erase marks of the self, like handwriting, so swapping the clippings for words in my own handwriting would flip that around.

References

AI assistance: Claude (Claude Code, Opus 5.5) suggested this idea from a brainstorm, and I chose it. Claude wrote the sketch, the tests and a draft of this post, read the Parrish essay to source the quote, and ran the browser and live Gemini tests. The replies above come from those test runs.