Computational Linguistics & Lyrics
- INTRO -
The debate surrounding the origin of language is closer to a philosophical discussion than a linguistic or sociological one. The truth is we don’t know if language developed slowly or suddenly after consciousness. Language changes rapidly--words fall out of style, change meaning over time and context. We struggle to properly translate between languages and slang in one part of a country is nonsense in another. We use idioms and proverbs that make no objective sense unless you’ve heard them before. It’s a reflection of our evolution and a contributor to how we frame the world around us.
It’s difficult to break down what language means to us. A hateful slur and loving tone both illicit a physiological response in us. There are objective consequences to words and yet they're subjective to each person. Linguistics studies the structure of language, sociology studies how societies affect it, psychology studies how our brains develop our individual use of it, philosophy considers how it influences understanding of our reality. It’s fundamentally interdisciplinary--like most things, it can’t be properly appreciated from a single vantage point.
The following analysis is rooted in computational linguistics, an attempt to quantify the individuality of each writer and observe an inter-connectivity that may not be immediately obvious, and thereby use machine learning to enhance a human understanding of music.
- VERSE 1 -
Natural language processing is an old approach in computational linguistics, with roots in Alan Turing's Computing Machinery and Intelligence in 1950. The journey from that seminal work to now is interesting in its own right. In the broadest sense, it segments language into elemental pieces, analyzes how those pieces relate, and projects a meaning. From there it attempts to surmise mood, contextualize ideas, identify topics, summarize, and translate. It's practical applications provide the foundation for Alexa and Siri, filtering spam in your inbox, paraphrasing news articles on Reddit, and identifying fake news (a day late and a dollar short).
I'm only just dipping my toe in the water, so I wanted to start a project that was personal, but not necessarily groundbreaking. I looked for something more abstract than news--I thought about movie scripts, stand-up sets, short stories, but I landed on music lyrics mainly because I could listen to the artists as I worked and live in the vibes they demanded. It’s given me a chance to get a fresh look at some of my favorite tunes and gave me an excuse to revisit the artists and the places in my life when I first discovered them as meaningful.
- CHORUS -
My musical education started in my dad’s pick-up truck, driving around rural South Texas listening to a now defunct oldies station. He’d crank up the radio when Peter Frampton came on, Tom Petty, Merle Haggard, George Jones, Creedence Clearwater Revival, Funkadelic. Like a lot of people in my generation, School of Rock gave a great historical lesson in music. There’s a montage where Jack Black goes through the history of rock and there’s a few moments spent on a chalkboard that had bands laid out in a network. When I saw that, I paused it and recreated it on a few sheets of paper so I could have an outline--seemed a lot more fun than school.
Nowadays, I'll listen to pretty much any genre. People from all walks of life have something to say and it'a a fun exercise to pull from each. A big moment for me was when I got heavy into punk music. I loved the inherently subversive nature of what I was listening to, not only in lyrics, but in its structure or, rather, its deconstruction. In its historical context it seemed that much more amazing and I realized that I was ignoring my generation’s rule-breaking, paradigm-shifting artists. And as I got more into the modern, it made me see the similarities in what I listen to, to look beyond the auditory aesthetic and toward the substance.
So that's what I want to do with this project. In addition to finding the songs that are unique to that artist, I want to see why my model might confuse artists and thus use machine learning to further my understanding of our complex musical network through the lens of what I like listening to.
- VERSE 2 -
For this project, I picked artists based on a few criteria: a subjective appreciation for lyrics, genre, and historical importance. Genres are very vague categorizations--an artist can be great for their command of one genre or for their unique blend of seemingly disparate ones. The Clash brought in elements of reggae, rockabilly, and R&B. Bob Dylan famously jumped from gospel to folk and country to rock. Sturgill Simpson pulls from blues and R&B with a firm foundation in country. A lot of rap samples from jazz and R&B for their loops. In short, genres help us initially identify an artist but are not as useful in mapping their place in the history of music.
I used the Genius API to access the lyrics and the GeniusR package to extract them. I picked three albums each to get a good spread. I wrote them into CSV files and loaded them into Python--I would’ve kept it in R, but the course I’ve completed required Python. The lyrics come in one row per line, so I grouped the lines by song. I did some regular expression manipulation to iron the quirks in the data--removing the “Remastered Edition” from the album title, removing “(intro)” from the song lyrics, and changed words like “changin’” to “changing.” I also unpacked contractions--by manually creating a dictionary to replace them--and identified and removed covers to prevent pollution of the artists’ voices.
- BRIDGE -
There’s currently a big push in Artificial Intelligence to understand complex human products like art and social networks through natural language understanding. There’s machines out there that are trying to write original jokes, create original paintings, construct original songs. It’s an interesting academic challenge, but feels hollow in an artistic sense. How can a machine calculate instinctive cadence and timing of Patrice O’Neal, quantify the passage of time in a brushstroke like Cezanne, construct an operatic tale of redemption in a dystopian society like Pink Floyd?
I’m skeptical. A machine can parrot popular themes--humans do it all the time--but that fundamental human touch is what makes art so compelling. Code cannot encapsulate the human experience, it cannot interpret the myth of Sisyphus like Albert Camus, capture the absurdity of everyday life like Elliott Erwitt, manipulate space and light like Louis Kahn, capture the spirit of a time and place like Hunter S. Thompson, effortlessly use food to understand humanity like Anthony Bourdain. There's often incongruity between the intentions of the artist and the interpretation. Therefore it's not unreasonable to assume that a machine's art can be inspirational, but it does mean that the lack of contextual enhancements surrounding it necessarily limit its...je ne sais quoi. It's inherently derivative of consciousness and not a product of it.
That's not to say machines can never make the jump. Computers have already surpassed the processing power of the human brain. Given the unprecedented pace of technological advancements in today's world, the evolution of human consciousness through the creation of Homo technologicus is probably closer than we're comfortable with. Therein lies the inflection point for transcendent machine art.
- SOLO -
It’s immediately obvious that rap lyrics are more dense. It’s a genre that promotes creative word play and vocal percussion to accompany the music. The Clash look to have a dense catalog as well, but this a reflection of their ambitious and lengthy albums, a defiant middle finger to their record company's demands to keep them short to increase profits. This likely will affect the model by providing a bigger bag of words that are associated with them. Wire and the Ramones have a relatively sparse bag of words--like their music, their lyrics are minimalist, packing as much as possible in a seemingly uncomplicated product.
A common theme for all artists is "time": how little we have, making the most of it, the incessant struggle throughout it. Another is possession, the combination of “get” and “got”: things acquired, lessons learned, a desire for something tangible or conceptual. Artists write about what they “see” in front of them or in the future: how it influences actions, how it stimulates thought, how we wish it was different. They communicate motion through "go" and "back": what we feel we must do, a return to a positive or negative place literally and metaphorically, or leaving that place.
- CHORUS -
Rap is a complete deconstruction of familiar noise, first into looped hooks and then into sound itself while mirroring the grim subject matter and raw energy popularized by punk. Discovering rap directly led to me viewing music in a much more abstract way, away from the differences and towards the inter-connectivity of genres.
We all have vastly different life experiences and yet there are common themes in the larger human experience. Hank Williams can sing about a descent into depression and alcoholism and we somehow think it’s inherently different that than that same insecurity and resignation and nihilism in Eminem’s verses.
As consumers, we put a premium on that new sound, that originality, but its really the same themes coming from a person with a different life journey. Urban and rural decay, lack of opportunity and sudden success, unexpected and self-inflicted tragedy are universal to humanity and not restricted by the arbitrary marketing of the music industry.
- VERSE 3 -
The scikit-learn package offers a wide range of machine learning techniques. The first step in prediction for NLP is vectorizing, a process that numerically maps out words, assigning a value for each. I used a tf-idf transformer (term frequency-inverse document frequency) to down-weight frequently used words, the idea being that there are diminishing returns of insight when a word appears more frequently for an individual artist and the larger sample.
The best version I created used a regularized support vector machine model with stochastic gradient descent. This particular approach works well for NLP because it can handle sparse arrays--there a lot of words a particular artist uses that aren’t used by anybody else and that individuality in word usage is important in identifying an artist.
The greatest advantage of using scikit-learn is the speed it process data. So to fully leverage this, I ran 100 different random splits into training and test data as a way to avoid the influence of a particularly unique song in an artist’s catalog. I separately kept track of each prediction in two ways: tracking the individual songs and the artist my model predicted; and the clustered matrix shown to the right. It breaks down those predictions as a percentage and clusters artists based on their word profiles.
- BREAKDOWN -
The most unique lyricist is Danny Brown--the only song that got predicted incorrectly featured verses by Kendrick Lamar. Rap artists in general have a more unique catalog. This isn't too surprising given the volume of words in a rap song versus, for example, a minute and a half song by the Ramones. The Clash were the most well-predicted punk band and actually took a lot away from every artist outside of rap. They had a wide range of topics in their songs, ranging from general mayhem to political statements and deftly span optimism and pessimism. Kris Kristofferson has the most distinctive catalogue for the country artists. Sturgill Simpson, Jimi Hendrix, and Bob Dylan have the widest spread of incorrect predictions. They all have a spectrum of love songs, psychedelic musings on life, and they do have more than a touch of disillusionment in what they have to say.
Townes Van Zandt's "Pancho and Lefty" from The Late Great Townes Van Zandt, among his most acclaimed works, was confused with The Clash in 79% of tests. It's a ballad about criminals running from the law, a betrayal of one partner to another, and pained reflection in the betrayer's final years. The Clash famously covered The Bobby Fuller Four's "I Fought the Law" in what remains as one of the most impressive cross-genre covers ever done. They had a kindred spirit with country through sympathetic tales of the outlaw, best featured in "Rebel Waltz" from Sandanista!. They also wrote somber and reflective songs like "The Guns of Brixton" and "Death or Glory" from London Calling. But I've never heard a Clash song with that can handle both elements like Townes could. Even for him it was exceptionally great and that's precisely why it has maintained a revered place in country music history.
Sturgill Simpson's "Time After All" from High Top Mountain, a straight up outlaw country song, was confused with Danny Brown in 54% of tests. It makes meta references to song structure, discusses self-medication in difficult circumstances, an inability to escape difficult circumstances. Danny Brown most exemplifies these themes in "XXX" and "Downward Spiral" from Atrocity Exhibition (interestingly, a reference to Joy Division's opening track in Closer). A trap in Nashville is, at its core, indistinguishable from a trap in Detroit. An ambiguous future forces them to live in the moment--for better and worse.
The Ramones' "Questioningly" from Road to Ruin, punk's take on lost love, was confused with Bob Dylan in 57% of tests. The song begins with an unexpected meeting of two people no longer in a relationship, the raw emotion still attached, and the inevitability of its failure. Bob Dylan's Blood on the Tracks, written after a painful divorce, is essentially a concept album for very similar themes, exemplified in "Simple Twist of Fate" and "Shelter From the Storm." This vulnerability was new for the Ramones when this album came out and, while not a commercial hit, showed some willingness to get out of the 90-second break-neck pace that made them famous.
There are quite a few interesting mistakes--for a full view, visit my GitHub page. Here are a few honorable mentions. Bob Dylan's "It Takes a Lot to Laugh, it Takes a Train to Cry," a bluesy song with rural imagery, was predicted as Jimi Hendrix in 84% of tests. Sturgill Simpson's "The Storm," filled with sailor imagery and parallels between mood and nature, was predicted as Townes Van Zandt in 97% of tests. Kris Kristofferson's "Help Me," closely resembling a gospel hymnal, was predicted as Kendrick Lamar in 29% of tests.
- OUTRO -
As I've cultivated my technical skills, I've found myself looking to nurture my artistic sensibilities in equal measure. Like art, good code merges the technical and the abstract. Technical insights feed an understanding that data is merely a piece of. Machine learning and artificial intelligence are useful conduits to illuminate the shadows, but "if one does not know to which port one is sailing, no wind is favorable." These increasingly important technical models are the wind that carry us to the unknown, but without human curiosity and drive, you're getting an inferior product that falls tragically short of authenticty. The time, money, and effort I've invested in learning the art of data science has contributed greatly to my ability to think computationally and philosophically about the problems in front of me.
I can barely keep a beat, my artistic ability is objectively laughable, and I've never been accused of being a genius. I'll never compete as a professional athlete, I'll never sell out arenas with my band, and I'll never have my art featured at MOMA. But I can draw inspiration from the people that do and use it to walk my own path.
The story of humanity is one of exploration outward and inward, perpetually in search of transcendent experiences that get us closer to answering the question: why am I here? Every one of the artists mentioned were put on this planet to do precisely what they did, what they're doing, and what they'll do, thereby evolving into much more than their flawed selves, elevating their very existence to an ethereal plane free from the shackles of time. That's a damn good port to sail to.