AI Writes New ‘Harry Potter’ Chapter With Predictive Text Algorithm, But Can It Emulate JK Rowling’s Style

harry potter

“Harry tore his eyes from his head and threw them into the forest. Voldemort raised his eyebrows at Harry, who could not see anything at the moment.”

For those of you who are wondering if whether this bizzare image is from JK Rowling’s Harry Potter series, do not be alarmed by this dip in her narrative capabilities. In fact, this is a dialogue from an AI-generated “chapter” called Harry Potter and the Portrait of What Looked Like a Large Pile of Ash  based on the boy wizard’s story.

The chapter was written using an AI-enabled algorithm created by Botnik Studios and was trained using the text from the original seven books in the series. As far as creative liberty goes, the algorithm seems to have taken full advantage of the original series and has created many eccentric scenarios such as Ron cannibalising Hermione’s family or Death Eaters engaging in public display of affection.

How Was It Written?

Botnik Studios, an open community of writers, developers and artists who produce interesting and strange contents with the help of AI, fed the text from the seven volumes of the wizarding saga into an predictive algorithm. The algorithm then learnt the pattern in which the words were paired throughout the series. Interfaced in the form of predictive keyboards (like the predictive text on mobile phone texting apps) the algorithm learnt to make suggestions based on its understanding of this pattern.

Two different predictive keyboards were used for the purpose — one for narration and the other for dialogues. The sentences that are formed tend to be anything from hilarious to outright crazy. Perhaps this is the reason why the content generated makes for a very entertaining read.

Since the sentences created by various users sound like drunken ramblings in isolation, the team picked the best ones and compiled it into a structured chapter to give the lines context and flow.

A key figure in the project is Jamie Brew, CEO and co-founder of Botnik, who is also a former writer for The Onion and Clickhole. Brew has an experience with automated text prediction after having worked on similar assignments on Tumblr.

So How Is The New Chapter?

While Harry Potter and the Portrait of What Looked Like a Large Pile of Ash is (obviously) a far cry from Rowling’s spellbinding narration, it does seem to have captured her tone on some level. The rhythm in her writing seems to have managed to seep into the lines which have been put together. But that’s where the similarity ends.  

If the four page chapter about the life and events at Hogwarts has to be described in one word, it would be hilarious. Maybe two words — absurdly hilarious. However, it would not be wise to compare the chapter to the works of the original author herself. But it is impossible to not burst into laughter while reading some of the priceless lines in the context of the original narrative.

Apparently for some reason Ron decides to make a meal out of Hermoine’s family. “Ron was standing there and doing a kind of frenzied tap dance. He saw Harry and immediately began to eat Hermione’s family,” it says. There are references to Ronald Weasley’s questionable taste in fashion at one point. “Ron’s shirt was just as bad as Ron himself,” reads one line.

Haven’t the books taught us that Death Eaters, the menacing minions of Voldemort, were serious, vile and impolite bullys? Well an entire passage devoted to an exchange between two of them raises some serious doubts about that. Including some questionable display of affection between them!

And for all those who lamented the death of Albus Dumbledore in Harry Potter And The Half Blood Prince , there is good news as the AI has resurrected him. A brief mention of the white bearded wizard is made towards the end of the chapter were he, weirdly, anoints the pig of Hufflepuff.

An Exercise In Human-AI Collaboration:

The chapter is not entirely penned by AI. While the algorithm made suggestions, the decision to choose the next word in the sentence from a list of suggested words was with the humans. This can be seen as an exercise where AI assisted textual content can be created by human beings for entertainment.

“The idea of Botnik is that humans and machines working together can come up with things that neither would be able to on their own,” Brew told a blog.

Botnik’s interest in developing such collaborative work can be seen in some of their other works as well. For example, they penned the screenplay for episodes of popular shows such as Seinfeld and X-Files. Various predictive keyboards for other shows, songs and more can also be found on their website.

In August last year, a fan of the Game Of Thrones series had “written” five AI-generated chapters using recurring neural network (RNN). While the fan had managed to capture George RR Martin’s style of writing, the results were again in the realm of absurd.


Going by the ‘literary’ works generated by AI, it can be safely said that writers do not have to worry about the need for their craft and the appreciation of its literary flair being replaced by that of a machine’s. While AI may have single handedly contributed to the sudden and accelerated obsoletion of many jobs, replacing art and literature entirely is a far-fetched idea. At least for the foreseeable future.

More Great AIM Stories

Jeevan Biswas
An unapologetic movie buff with a special admiration for Marlon Brando and Stanley Kubrick, Jeevan is a post graduation student in Journalism and Mass Communication. He hopes to make an impact with his uncompromising reportage some day.

More Stories


8th April | In-person Conference | Hotel Radisson Blue, Bangalore

Organized by Analytics India Magazine

View Event >>

30th Apr | Virtual conference

Organized by Analytics India Magazine

View Event >>

A beginner’s guide to Spatio-Temporal graph neural networks

Spatio-temporal graphs are made of static structures and time-varying features, and such information in a graph requires a neural network that can deal with time-varying features of the graph. Neural networks which are developed to deal with time-varying features of the graph can be considered as Spatio-temporal graph neural networks. 

Yugesh Verma
A guide to explainable named entity recognition

Named entity recognition (NER) is difficult to understand how the process of NER worked in the background or how the process is behaving with the data, it needs more explainability. we can make it more explainable.

Yugesh Verma
10 real-life applications of Genetic Optimization

Genetic algorithms have a variety of applications, and one of the basic applications of genetic algorithms can be the optimization of problems and solutions. We use optimization for finding the best solution to any problem. Optimization using genetic algorithms can be considered genetic optimization

3 Ways to Join our Community

Discord Server

Stay Connected with a larger ecosystem of data science and ML Professionals

Telegram Channel

Discover special offers, top stories, upcoming events, and more.

Subscribe to our newsletter

Get the latest updates from AIM