Skip to main content
  1. Home
  2. Emerging Tech
  3. Computing
  4. News

Digital Trends may earn a commission when you buy through links on our site. Why trust us?

A neural network tried to write a 9th Harry Potter book, with hilarious results

Add as a preferred source on Google

Do you remember that memorable scene in the Harry Potter books when a person seeking revenge on Ron turns out to be Dumbledore hiding behind a cream cake?

If you don’t, that’s probably because you read the version of Harry Potter written by J.K. Rowling instead of an LSTM recurrent neural network — trained to generate new Hogwarts-related stories using a data set consisting of the series’ first four books.

Recommended Videos

“I’ve been experimenting with deep learning over the past few weeks, and the Harry Potter story is the result of one of those experiments,” creator Max Deutsch told Digital Trends. “Beyond just looking for a fun way to practice what I’ve been learning, the Harry Potter project was an attempt to make something enjoyable to read.”

Since the results are more surreal mashup than anything likely to give Rowling sleepless nights, “enjoyable” may not be exactly the word. However, it’s a fascinating demonstration of what happens when a neural network turns its attention to creativity.

“The computer is quite good at capturing the rhythm and style of the source text, but the sentences themselves are mostly nonsense,” Deutsch admits. “Occasionally, there is a glimmer of sense, and these moments — plus the knowledge that a computer wrote it — is what makes the read enjoyable to me.”

Interestingly, this isn’t the first time textual analysis algorithms have been applied to the work of J.K. Rowling. When the U.K. newspaper the Sunday Times outed the mega-successful author as the scribe of detective novel The Cuckoo’s Calling a few years ago — writing under the pen name Robert Galbraith — computer scientists were called in to use machine learning to solve the mystery. By analyzing the text based on word-length distribution, usage of common words like “the” and “of,” and recurring-word pairings, they proved that she was.

Max Deutsch’s work might not have quite the academic rigor of that work, but it moves beyond it by not simply analyzing existing works — but generating new ones. “Creativity is a hard thing to explain, even in the context of humans,” he says. “If creativity is simply the act of creating something new — often based on connecting pre-existing things in new ways — then you can argue that the Harry Potter neural network was very creative. In fact, this might be the first time anyone, or anything, has constructed the sentence: ‘Dumbledore will get out from behind a cream cake.’”

You can read the rest of Deutsch’s deep learning Harry Potter story here.

Luke Dormehl
I'm a UK-based tech writer covering Cool Tech at Digital Trends. I've also written for Fast Company, Wired, the Guardian…
Virgin Galactic is charging $750,000 for three minutes of weightlessness, and nearly 700 people are already in the queue
Three minutes of floating, one very expensive ticket.
Virgin Galactic featured image

I’ll be honest with you. Three minutes of weightlessness for the price of a very nice house sounds absurd to me. Even so, hundreds of people have already lined up to experience it.

Most recently, Virgin Galactic unveiled Apeiron, the first spaceplane in its new Delta class. The company flew it from its Arizona factory to Spaceport America in New Mexico, where it will begin flight testing.

Read more
Google is making Gemini and Search work better with the apps you love
Gemini's guest list is growing, and your favorite apps are invited.
Gemini AI on a phone.

Google has been finding more ways to make Gemini a part of your daily routine, from putting together playlists to ordering groceries through your favorite apps. Now it's expanding those capabilities to more services, with Google Search joining in, too.

The company has announced a new Connected Apps Platform that makes it easier for developers to bring their services to both Gemini and Search. Alongside this, Google is adding new partners to its growing lineup, bringing more of the apps people already use into its AI ecosystem.

Read more
AI bots are now trying to sabotage public health policies, like banning disposable vapes
Thousands of AI bots voted in a public health poll to block sales restriction on disposable vapes. It's like Big Tobacco is back from the dead.
Woman smoking a vape.

In the broad context of AI and its perceived harms, health and medical risks often pop up in the conversation. The warnings even come from frontier AI labs, such as ChatGPT-maker OpenAI and Anthropic, both of which have warned about misusing AI to cook up bioweapons. Security experts have already spotted a few such incidents in the wild, especially with the usage of AI models without any solid guardrails. 

Well, it appears that the risks run deeper. As per an analysis appearing in the British Medical Journal (BMJ), AI bots are now being deployed to influence public policies governing health risks to citizens. In this instance, an attempt was made using AI bots to thwart regulations that aim to restrict the sale of disposable vapes, all while disguising the manipulation efforts as a response from real humans. 

Read more