Last week, I trained a neural network to generate the names of magic spells from the game Dungeons and Dragons, by giving it a list of existing spells and asking it to generate more like them. It obliged, with spells like “Charm of the Cods”, “Primal Rear”, and “Hail to the Dave”.

Blog reader Greg V suggested I try the same with the spells from Harry Potter. I used the list of spells from, which includes not only the spells from the books, but also spells used in the movies and plays. The list included many with official names in questionable Latin (Arresto Momentum, Engorgio Skullus, Expelliarmus), and many more known only by their effects (Bubble-Head Charm, Endless Sandwiches, Twitchy-Ears Hex).

With about 560 spells to study, the neural network had a tendency to produce spells that were either exact repeats of existing spells or else terribly-mangled pseudo-Latin, but I did manage to find some apparently functional gems.

First, the charms. The Wiki quotes J.K. Rowling defining charms as “those spells which do not change the intrinsic character of the object on which the spell is cast". By that definition, the “Herring Charm” and “Cracker Charm” seen below do not manufacture herrings and crackers, but likely merely cause them to dance.

Herding Charm
Anti-Dining Charm
Creaking Charm
Clicking Charm
Revelling Charm
Hoot Charm
File-Baking Charm
Hair Logs Charm
Herping Charm
Pot-reversaters Charm
Herring Charm
Cracker Charm
Ant Charm
Ant Stacking Charm
Bubble-animating Charm

The neural network also learned to produce jinxes, hexes, and curses, as well as a few unpleasant-sounding charms. Hard to tell whether the neural network would have been a valuable ally at the Battle of Hogwarts, or primarily a weird distraction.

Corn jinx
Curse of the saris
Bedthing Curse
Tragha Fracking hex
Cars Jinx
Hero Curse
Furring Curse
Curse on Marvolo Curse
Crushing Charm
Anti-Shack Jinx
Fight Charm
Hork Charm
Smoking Charm
Terding Charm

It becomes clear, though, that the neural network doesn’t really understand what spells are, exactly. Here are a few that it invented. Note that “X to Y” type spells are transformation spells, so I’m not sure how turning a spell into a pug would work, exactly. It also seems to be searching unsuccessfully for the word “counterspell”.

Spell to pug
Spell to Rum
Spell to hum
Spell spell
Spell-Spell Spell
Anti-Spell spell
Curse of spell
Spell to cure Spell
Spell Reversal spell
Charm to Cure Curse of Charm
Hex Charm
Hex Hex
Hex Hax Hex

The animagus spell, in which you turn yourself into an animal of your choice, is notoriously difficult. As a mark of its very advanced difficulty-ness, the spell itself is four words long, and annoying to remember: Amato Animo Animato Animagus

Maybe it’s memorable if you know Latin. The neural network doesn’t know Latin, though. And it has a heck of a time trying to cast the animagus spell:

Animato Animagus
Arato Agio Animagus
Amaro Amamoco Animagus
Amato Anima Animatus Charm
Amato Animo Animagus
Amanto Dure Anto Animato Animagus
Amato Animato Animagus
Animagus Antmater Charm
Arato Anima Animagus
Amato Animo Animogo
Amato Anima Mumora
Animagus Anto Animato Animagus
Beper andmoto Animagus
Amato Anima Anima to Animato Animagus
Arinta AnimaconStrag spell
Repello Inimato Animagus

It’s unclear what the neural network’s chosen animal form might be. Ox?

Its favorite spell, though? Curse of the Bogies. Garbled variations of that spell kept showing up over and over.

Jend-curse of the Bogies
Regrowing hair to curse of the Bogies
Curse of the Bogiegs
Misten per to Spell-barrh Counter-curse of the Bogies
Fineey curse of the Bogiess
Curse on to barter op Dhe Bogee’s
Curse of the Bogiess Curse
Sounger-curse of the Bogiess Curse
Tebbed to curse of the Bogies
Curse of the Mogies
Hex of the Bogery curse

And I think these two might be secretly versions of Curse of the Bogies

Soungor-curse of the Cougee spell

And perhaps there’s evidence that I didn’t clean up the text I extracted from the Harry Potter Wiki as much as I might have. One SINGLE stray line of css code, and now the neural network has latched onto it, convinced that “MediaWiki” does something powerful.

RediaWiki:Inf oforo Diolecum Charm
MediaWiki:InfoboxColoure Revelloro
MediaWixi:I foritious

At other times, I couldn’t tell what the neural network was trying to do.

Horbing spell
Mumbledore’s Reverore Inceacus Curse
Durser rabbity hair Logiot
Hork Lighty spell
Hord Ligery Spell
Mevitiblichainh’s grate Flare
Jigxe-sen tre Mucan to bog
Brechaim hedbivicus Doobers Spell

However, I’m beginning to suspect that the neural network might be making fun of the names.

Stickee spell
Hurder-gerping Charm
Snombeling Charm
Dumbledory Spell
Hombledory Spell
Fubbledory Charm
Sbuggly wiggly
Bubbledor curse
Bubbiro forjuling Charm
Mubble-ponde Charm
Sluggly wiggly
Pockongum Dookors Spell
Squggly-wing fart

Other neural network Harry Potter experiments:

Generating Harry Potter fan fiction summaries with word-rnn

Generating Harry Potter fan fiction summaries with char-rnn

Become an AI Weirdness supporter to get bonus content! Or become a free subscriber to get new posts in your inbox.

Subscribe now

Subscribe now