6 min read

How does Spotify Wrapped Work?

Archived from MediumRead original →

Year Ends, Late Night Stands, and Spotify Wrapped in Your Hands

Photo by Diego Alexander on Unsplash

Before diving in let’s tune into this poem written by me.

A Year of Tunes, A Melody Stored
Beneath the streams, your data roars,
An algorithm’s hand, a silent guide,
Crafts Wrapped’s story, far and wide.

To put it simply and straightforwardly, Spotify wrapped is a genius marketing strategy that makes the listeners more personalized towards the platform by showing interactive thumbnails, and card designs and also by surprising the listeners by saying “You listened for 23,975 minutes this year”. Never mind this was my 2024 Spotify Wrapped.

Spotify Wrapped

But how does this data get collected so accurately?

What Happens Behind the Scenes? What people are behind this?

How Does It Work?

According to various sources, I get to know that Spotify starts tracking your 5 Most listened-to artists and 30 songs for at least 30 seconds of listening time, these are the minimum requirements to have a Spotify wrapped at the end of the year.

There are several algorithms and structural approaches followed by Data scientists to give you the year-long pleasure of Spotify wrapped, some of them are as follows:

1. Data Collection

Spotify collects large amounts of data from users, This data includes

  • Track information: Which songs, albums, and artists were played?
  • Playback details: Is this song played, skipped, or liked?
  • User Interactions: Likes, playlist additions, and shared activity.

This data is collected continuously by Spotify’s backend and massive influx using their robust distributed databases like Cassandra and Hadoop.

2. Data Processing and Analysis

Once data is collected and analyzed it undergoes rigorous transformations and considerations.

a) ETL Pipeline: ETL stands for Extract, Transform, and Load, spotify uses this to extract the data that came from the above, which is then sanitized and cleaned by Transform and then loaded to the analytical datasets.

b) Streaming and Batch Processing: Tools like Apache Kafka and Spark are employed for both real-time and data processing. This ensures that user listening habits are measured accurately and analyzed promptly according to the requirements.

c) Key Metrics Calculation: Spotify wrapped computes metrics that everybody finds personalized and required like.

  • Top songs, artists, and genres.
  • Total minutes streamed.

3. Collaborative Filtering

Collaborative Filtering, in an easy way, is like a friend’s music tastes like my music taste. I told it more broadly but Spotify determines popular songs, artists, and genres among groups of users with similar tastes. It operates under the assumption that if two users have the same listening pattern, they likely going to hear the same artists, songs, etc in the future.

So how it is used in Spotify wrapped,

A. User Taste Profiles

What Spotify does is generate User Taste Profiles by logging user activity that you all see in the library sections and categorizing them into listening sessions. This provides contextual information about:

  • Explicit Feedback: Actions like track saves, skips, and clicks
  • Implicit Feedback: Behaviors such as listening durations, repeats, and shuffling the same playlists again and again.

B. Weighing Feedback

Both the feedbacks get different preferences depending upon their importance. For example:

  • Explicit Feedback: This gets most preferences because they are directly interacted with by the user.
  • Implicit Feedback: This gets the least preferences because they do not directly get feedback from the user.

C. Personalized Wrapped Highlights:

Using collaborative filtering, Spotify wrapped can:

  • Identify the top tracks, artists, and songs you like most.
  • Able to achieve insights that look personal like “You are in the top 0.01% of fans of Sidhu Moosewala”.
A Dance of Data, a Profile Designed
Collaborative threads, taste intertwined,
Your Wrapped unfolds, a story aligned,
With insights crafted, and uniquely refined.

Content-Based Filtering

You have seen that Wrapped also contains a page dedicated to that you have changed somewhat little also — which means you also listened to other artists. An artist's being coming to your wrap is not a god’s signal if you like him/her solely, that’s the different conditions but if you found him/her out randomly then this is due to the Content-based filtering.

Content-based filtering plays a crucial role in finding a new artist, or an album in your feed, it does this by analyzing the metadata of the current music or genre songs are listening to and finding similar artists or albums using their audio models. Metadata can have the tempo, key elements, danceability, and different sonic characters.

So in Spotify Wrapped, they are generally used to leverage user-specific insights like hidden gems or rising stars.

4. Natural Language Processing(NLP):

Playlist

Have You ever wondered how Spotify knows that this song is Punjabi and that not, you can guess that Spotify engineers listen to every song and put them into the playlist, but wait a minute the same work can be done by us also so why Spotify pay their engineers, Spotify engineers have brains so that’s why they use NLP to transform playlists into textual documents to identify relations in lyrical patterns of the songs?

6. ANNOY(Approximate Nearest Neighbors Oh Yeah)

Generally, this is a C++ library with Python binding used for the recommendation model by searching for points in the space that are near the given query point by the user.

So in easy terms, it does the following things:

  • ANNOY searches for songs that are close to each other in the sense of parameters like the same Beat Per Second(BPS).
  • Also to increase efficiency, ANNOY creates a read-only file based on the data structures which are mapped to memory locations and allow different processes to share the same data.

So, overall the backbone of the recommendation systems of Spotify.

I can’t explain the whole codebase here but if you want you can go to their Github.

7. Machine Learning Models

Spotify leverages machine learning to personalize Wrapped:

  • Clustering Algorithms: Identify listening trends and group similar users.
  • Convolutional Neural Networks (CNN): Spotify uses CNNs on audio data to analyze and process audio features, similar to facial recognition technology. This helps the platform identify patterns and relationships in music that inform recommendations.
  • Reinforcement Learning from Human Feedback(RLHF): Spotify uses reinforcement learning which includes learning from the user interactions and their behaviors.

Spotify also uses different ML models including Audio Models, Data Aggregation, and Model Ensembling.

8. Visualization and Design

Spotify Wrapped isn’t just data; it’s a visual feast. Programmatically, this involves:

  • Front-End Frameworks: Using Tools like React-Native to design the interactive stories
  • Data Visualization Libraries: D3.js and WebGL used to create the 3D and the smart starting animations visually appalling.

After all of this Spotify uses Lottie an Open-Source Animation Library. This tool allows seamless, lightweight animations with highly customizable features which helps Spotify to create eye-catching animations, providing a lasting impression on users.

Conclusion

So by concluding this, we can Spotify Wrapped is a masterpiece of data engineering, machine learning, and user-centric design. Spotify Wrapped is like an Emotion till 2023, but this year 2024 if You see that they removed various other features in Spotify wrapped like “Your music taste”.