[Chunky Hat”, crocheted by Joannastar]
A while ago, I tried to train a neural network to generate knitting patterns by showing it a few thousand existing patterns so it could use trial and error to generate new patterns. I called the project SkyKnit, and its new patterns were… well, they were patterns. But they were nothing like the patterns it had been trained on. The test knitters of Ravelry’s adults-only, often-indecorous LSG forum had to do a lot of debugging to turn them into reality and, even debugged, SkyKnit’s patterns were strangely organic, prone to weird branching ribbing and organic-looking holes, turning into irregular shapes or even tentacles.
[Make Caows and Shapcho, knitted by MeganAnn, and Lacy 2047, knitted by michaela112358]
Ever since the SkyKnit project, I’ve wanted to do a version for crochet. Like knitting, crochet has strong ties to mathematics and programming, and in many ways it’s more flexible. A crochet algorithm could potentially create even more exotic shapes than SkyKnit did.
For this project, to be dubbed HAT3000, I decided to make some improvements. I would train it on just crochet hats, which ought to be simple enough and similar enough that a neural net might be able to figure out the general pattern and produce functional designs. The LSG forum crocheters helped me assemble training data of 500 vintage out-of-copyright patterns, plus these kind designers contributed their own patterns to the effort: krisitis-patterns, irishlacenet, SierraPelona, fairyhedgehogg, watrpriestess, RachyNewin, agnosticnun, UnplannedCauli, membril, Moogly, and SuviCrochets.
I used Max Woolf’s gpt-2-simple collab notebook to finetune OpenAI’s GPT-2-355M neural net model. It’s pretrained with a bunch of non-crochet knowledge from the internet (fanfiction, recipes, conspiracy theories), but it does have a much longer memory than SkyKnit does, so will have a better chance of being able to figure out how the rows relate to one another. HAT3000 was set up for success.
My first indication that something was going wrong was when the hats kept exploding into hyperbolic super-surfaces.
A pattern would start modestly enough with what could plausibly be the crown of a hat, but somewhere there would be an instruction that made the next row MUCH bigger than the previous row, and then the next row MUCH bigger than that. The later rows would turn floppy to fit all that length in while still attached to a much smaller row, and then the next rows would have to curl even more. Ruffles would turn to tight ruffles, and then to corals, and then to brains.
Here’s one rather innocently titled “Brim Hat Pattern #1708” which Ravelry user Persipan heroically crocheted all the way through the final row (or at least, halfway through that final row; we haven’t heard from them since, they’re probably okay). By Row 9, there are over 1700 stitches. Row 10 has 3500 stitches, took 9.75 hours to complete, and even that is nothing compared to the edging.
Almost all of HAT3000’s patterns did this, eating yarn, eating sanity, becoming more and more hyperbolic, threatening to collapse into black holes… why, since none of the example hats did this?
A few people explained it to me thus: It looks like it’s really hard for HAT3000 to NOT fill the planet with ruffly brains. Basically, since most hats are built from the center out, HAT3000 only knows how to make each circle bigger than the previous one, adding 1 new stitch for every 2 in the previous row, or, for the faster increases usually used at the center of a hat, as many as 5 or 8 stitches for every 1 in the previous row. That would still be okay if HAT3000 knew how to control its increases. Unfortunately, if it accidentally increases too much in 1 row, that excess increase gets multiplied by the next layer, which in turn gets multiplied again. The tiniest instability turns exponentially into yarn-eating disaster. Meanwhile, HAT3000 thinks it’s doing great because the pattern text itself is still very close match to what a human would do. It has no idea that its hat has exploded.
The worst offender is a pattern called simply “The End…” which by my calculations requires enough yarn to wrap the known universe in a ball of yarn about a billion light years thick.
Some of HAT3000’s patterns did actually produce hats, though they tended to all be tiny (probably because they had fewer rows and therefore fewer opportunities to begin suddenly expanding).
Other patterns produced not hats but strange artifacts, purpose unknown. Here’s the full pattern for one, called “Hang in Wind”:
Hang in Wind: Toss the pieces together. This is the windmill: Windmill in Wind: With a 1 cc ball of yarn, ch 14, join. Do not join, twist yarn to form a knot, or cut yarn.
Other patterns were equally inscrutable.
“New theory: HAT3000 didn’t want us to make hats for ourselves. We’re making hats for neural networks. Which are weird and amorphous and have dimensions and connections that humans cannot comprehend and also don’t really have heads.” - ScarlettTanager
One of the most entertaining aspects of the finetuned HAT3000 was how much of its original broad training it retained. Prompt it with the beginning of a story, and it could still add to the story in more or less the same style as the prompt. Hilariously, its strategy was now to gradually work the topic back toward crochet hats. In the paragraphs below, the prompt I gave HAT3000 is in bold. The AI did the rest.
Harry whirled to face Snape, heart beating hard. “Wh–What will you do?”
Snape’s eyes narrowed slightly and he lowered his wand, then stepped aside. As he approached behind Harry, he knelt down to kiss the front rim of Harry’s green-gloved hat as he pulled her closer. Snape slipped on the silk and reached in carefully, then unbuttoned Harry’s green-gloved hat. He looked Harry in the eyes and stroked her crown lightly before pushing on the seam of the hat to attach it. He finished on the front of Harry’s hat with a snap. With a light flourish he tied an extra strand of fabric, then another twist of silk, then another twist of silk.
HAT3000’s terrible crochet-themed erotica was even sometimes crochetable.
HAT3000 would sometimes turn its story prompts into things that were not crochet patterns exactly, but something strangely akin. Confrontations would turn into tightly choreographed fight scenes, the combatants weaving around and around each other. Villagers would build earthworks, walls, and moats in concentric circles. Recipes would turn into round cakes with dozens of stacked layers. Spaceships and adventuring heroes would follow complex and highly detailed routes. The trained model must have been able to draw some sort of connection between these various domains.
What have I learned from HAT3000? Like SkyKnit, it shows what unexpectedness happens when a neural net trainer, armed with approximately zero knowledge of a particular problem, nevertheless plows ahead and throws a neural net at it anyways. And like its knitting counterpart, HAT3000 owes its entire success to the creativity of human artists who took its often nonsensical patterns, fixed the bugs, and turned them into physical artifacts. I’d like to extend a huge thanks to the knitters and crocheters who sacrificed time, sanity, and yarn to satisfy the whims of these very weird AIs.
You can join the conversation, and crochet along, at the HAT3000 LSG thread (if you register first and don’t mind the swearing). There’s also a twitter thread that collects most of the patterns and many of the crocheted examples. There’s a big generated set of patterns here.
I generated far more HAT3000 responses to story prompts than would fit in this post , but I picked some of my favorites to highlight as bonus material. I think they’re fascinating. If you have ever dreamt of a crossover between Star Wars/Harry Potter fan fiction and crochet, well YOU ARE IN LUCK. You can become an AI Weirdness supporter to get them as bonus material! Or become a free subscriber to get new AI Weirdness posts in your inbox.
You can order my book You Look Like a Thing and I Love You! It’s out November 5 2019.