Imani Danielle Mosley

music historian | digital & public humanist | bassoonist

Breaking the Doodle: Bach, AI, and our quest for the human

Before I start this post, I just want to address where I've been. Since my last post, I finished my dissertation and will be defending it next week (!!!) Needless to say, that took all of my focus and effort. I've tried as much as I could to post interesting things over at @humanistmachine but I'm hoping that with this post, I will be able to get back into the regular swing of things. Thank you to everyone who has written me telling me how much they have enjoyed my writing, it is always noted and appreciated.

———

Bach.

Our Eternal (musical) Father in Heaven. My birthday twin (happy birthday to us!) Loathed by every musician who has to breathe in order to perform. Every scientist & mathematician's favorite composer. 269 years later, we are still as enthralled with him as ever, convinced that hidden within his compositions are the secrets of life, death, and the universe. I will admit my deep love for Bach before I continue to make my position clear; I have his family crest tattooed on my right arm. So my birthday is often spent thinking about Bach a fair deal (something I hated as a child, it's my birthday too, damnit). Today was no exception. I woke up this morning to news of today's Google doodle in honor of Herr Bach: an interactive game of sorts, created using machine learning where you could input a soprano melody line, crank up the machine, and watch as it generated some good old-fashioned Bachian eighteenth-century counterpoint.

In that moment, I had no idea that I would spend the entirety of my day talking about it but, honestly, I should have known better.

Today’s Google Doodle, in honor of Bach’s 334th birthday

Today’s Google Doodle, in honor of Bach’s 334th birthday

My copy of the Bach-Riemenschnieder, no house is complete without it

My copy of the Bach-Riemenschnieder, no house is complete without it

The doodle is adorable. It even comes with a Wendy Carlos Switched-on-Bach-style version that is equally adorable (though sadly there's no mention of that seminal work and its history) And on its face, it's pretty remarkable. The start up graphics tell you how the doodle was created and that 306 of Bach's compositions were used as a dataset…not bad (only Papa Bach can give us those kinds of data points, right?) But like the constant pedants we are, my friends — music theorists, musicologists, performers, etc — immediately saw the doodle as a challenge with the intention of breaking it. What does that look like, exactly? My friend and colleague (who teaches counterpoint) plugged in the chorale tune "Erhalt uns, Herr, bei deinem Wort" (number 72 in the Bach-Riemenschnieder book of 371 harmonized chorales if you're following along) to get a two-measure result that he then graded (he was grading counterpoint homework anyway). Another friend put in her own soprano line, nothing crazy, but the result ended strangely with an F-sharp in the soprano line sounding at the same time as an F-natural in the bass. Other friends put in well-known tunes for their soprano melody lines ("All Star," "Baby Shark," and so on) while theorists on social media dug their heels in, complaining about the game's inability to understand cross-relations, part-writing, and other staples of contrapuntal writing.

Counterpoint analysis graded, courtesy of Google and Douglas Buchanan

Counterpoint analysis graded, courtesy of Google and Douglas Buchanan

This post isn't really about whether or not machine learning did a good job in this exercise. I'm not a theorist and though I'm trained well enough to talk extensively about contrapuntal writing and when it is and is not successful, I'm not quite concerned with that. My hat is off to the team at Google Magenta (a project with which I'm familiar) who used TensorFlow.js and other tools to create this doodle. If you have read my previous posts, you know that this type of project is similar to the kind of work I was doing at NPR and I know what goes into creating something like this. 306 compositions is a relatively small dataset, generally speaking (in my opinion, not nearly enough for supervised learning) and I think that it has provided a lot of people with some enjoyment today.

What I am interested in is the AI community's, dare I say it, obsession with Bach. Because I believe that the continued use of Bach as jumping off point for artificial intelligence reveals some very important things, namely how we think about Bach, how we think about the compositional process, and AI's ethical relationship to art and even humanity. This doodle is not the first example of using neural networks & machine learning to replicate Bach. An article in MIT Technology Review titled "Deep-Learning Machine Listens to Bach, Then Writes Its Own Music in the Same Style" asks readers if we could imagine trying to distinguish music written by Bach and music written by a neural network trained in Bach's style. The neural network, called DeepBach, is the work of Gaetan Hadjeres and Francois Pachet at the Sony Computer Science Labratories in Paris. Like the Google Magenta team, they started with 352 of Bach's chorales but in order to expand the dataset, they transposed them and the various permutations created a dataset with 2503 chorales. Their result, unsurprisingly, is far more nuanced than that of the Google doodle. And in their findings, half of their participants (that included professional musicians, music students and the like) thought the AI-generated music was by Bach 50% of the time, a very good number for such a project. While the research behind this is interesting, the text in the article sneakily gives away why Bach is the subject of such fascination: "These compositions have attracted computer scientists because the process of producing them is step-like and algorithmic. But doing this well is also hard because of the delicate interplay between harmony and melody."

Won’t you please think of the kittens?

Won’t you please think of the kittens?

Let's start with the first part of this thought. In a conversation I had today with a data scientist at Duke and our music librarian, I used the term "formulaic," a term I instantly regretted. I was not trying to say that Bach was formulaic in his compositions (something that our librarian clocked me on immediately), but that this understanding of counterpoint as rule-driven is problematic. Outside of musicology (and I mean that with a capital M, including theory and analysis) — and, in some places, within our discipline as well — there persists this idea of the mathematical Bach, the orderly Bach, the Bach who embodied the centuries-old rules of contrapuntal writing (if you're a music major, then you've seen the Bach parallel fifths kitten meme). Unsurprisingly, it is always more complex than that. Yes, from Gradus ad Parnassum and onward, we music students learn about the dos and donts of contrapuntal writing at our peril. What's good for Fux, is good for us, nein? But as I told our young data scientist today, this is and has always been a baseline (oh god, sorry for that pun) from which we can see and appreciate the creativity involved in composition of all things. I had one counterpoint teacher in college who often said that you can't break the rules if you don't know the rules. And Bach was a rule-breaker. There's no space here to get into the dizzying landscape that was Bach's compositional process. But it is important to place that brilliance alongside Bach's very real, very mortal life as a working composer. Even with this context, the mathematical Bach persists, enough to connect at least his chorale compositions to the modern idea of algorithms.

But what is to be said for melody and harmony as the second part posits? In Forkel's biography of Bach, he writes extensively on Bach's harmonic writing. In the following passage, he outlines how freedom is an essential quality of Bach's compositional process:

In such an interweaving of various melodies which are all so singing that each may, and really does, appear in its turn as the upper part, Bach's harmony consists … In his compositions in four parts, you may sometime even leave out the upper and lower part, and still hear in the two middle parts an intelligible and pleasing music. But to produce such harmony, in which the single parts must be in the highest degree flexible and yielding towards each other if they are all to have a free and fluent melody, Bach made use of quite peculiar means, which had not been taught in the treatises of musical instruction in those times, but with which his great genius inspired him.

Leaving the genius part at the end alone for now, this description of Bach's contrapuntal writing is as far away from step-like and algorithmic as possible. It is not quite as plug and play as the doodle might suggest. And this description of Bach comes at the beginning of the nineteenth century (contributing to the resurgence in Bach scholarship), it is not some twenty-first century portrait. Perhaps, the persistence of the mathematical Bach stems from Douglas Hofstadter's popular work Gödel, Escher, Bach though the book itself is more a study on cognition than anything else. Rahul Siddarthan, in his article on Bach and mathematics, attributes the appeal of Bach to scientists as the following:

The music of Bach seems to have a particularly wide following among scientifically or mathematically minded people … One could point to several reasons for this — the highly regular structures, the complex counterpoint, the use of simple themes to construct elaborate structures.

While we've already tackled some of these points earlier, this I think gets to the heart of the issue. How do we explain what music is, what it does, why it exists? Evolutionary biologists have been struggling with some of those questions for a long time (not to mention philosophers and mathematicians) There is a deep desire within humans to connect with pattern making and repetition, we know this. And with an art as non-representational as music, coming from who knows where, the mere presence of patterns gives us a grounding, a place to start from, a way to understand the non-understandable. And isn't that at the heart of artificial intelligence? The question has always been whether or not AI can re-present the most human aspects of our intellegence: creating art or music or humor. All of the other stuff is relatively simple by comparison. Language is just networks and networks are the computer's bread and butter (though deep learning has shown us that sometimes writing is hard, too) But to replicate the work of Picasso or Pollock? Bach or Mahler? That's the good stuff, that's the threshold. So with Bach, supposedly, you get the sublime ethereality of a brilliant composer (very human) with the math of a calculator. And this provides some really interesting questions and ethical debates for us to ponder. Does this desire to re-create art through AI act as another way for us to understand the unknowns of our own human mind? What purpose does this exercise serve? It can't be more than a digital party trick, it has to be at the service of something greater. I'm no philosopher so I won't attempt at these larger questions but as we approach (or are in) the posthumanist age, I think there is a desire, nay a need, to know more about what makes us human more than ever. Using AI perhaps is the long way round but it's a desire with which I can empathize.

This is all to say that I doubt that Bach will stop being the go-to for AI-generated music soon. I personally would love to see the rationale behind a Mahler dataset or a Sibelius dataset or any other composer, really (in truth, Schubert lieder could provide some fantastic data points), a composer to whom these ideas of rigidity are not so stubbornly attached. I think it would raise more questions than answers, more problems than solutions. But that's okay because it's one of the things that makes art, art.