Spotify breaks songs down into 2 categories: content based filtering and collaborative filtering. Content based describes the song by analyzing the song itself through AI, and collaborative filtering describes the song based on users' interactions with other songs on the platform. With content based filtering, spotify uses metadata generated by the creator when uploading songs to their distributor (the middleman between an artist and various streaming platforms) including song credits, genres, label, artists hometown, featured artists, primary language, and instruments used. This gives spotify a head start when classifying what your song sounds like.
From there, spotify uses an AI to analyze raw audio data from the creators song to analyze different mood factors such as loudness, key, and bpm. This allows Spotify to track a song's valence (is it happy or sad?) danceability (is it fast or slow?) and its energy (is it loud or soft?). After this process takes place, Spotify will break down the song's structure, identifying different parts of the song and categorizing them according to their different attributes. With the combinations of these 2 AIs along with creator generated metadata, Spotify can completely reverse engineer a song, coming to the assumption that there will be a guitar solo at this section, or a dubstep bass drop at this section.
Spotify also analyzes lyrics supplied by the creator, and can further categorize the song based on lyrical content. Collaborative filtering is a little simpler; it analyzes what users that listen to your music also listen to (this is present on an artists spotify page under “fans also liked”). This was a bigger factor in previous years, but recently spotify has narrowed it down to if fans put 2 similar songs on the same playlist, as users music tastes vary wildly, but playlists tend to represent a general mood or sound.
Spotify also generates user taste profiles, focusing on user based insights similar to tiktok. The criteria for user taste includes liking songs, saving songs, adding songs to playlists, listener retention, and listen frequency. The combination of song and user metrics allows spotify to create eerily specific playlists that it thinks the user may enjoy. These playlists are broken up into genres and moods, giving users a curated experience when using the app, arguably what sets it apart from competitors. On the user side of the algorithm, it can be broken down into 3 categories: user-entity affinity ( "How much does user X like artist A or track B? What are the favorite artists/tracks of user Y?"), item similarity ("How similar are artist A & artist B? What are the 10 tracks most similar to track C?") and item clustering ("How would we split these 50 tracks/artists into separate groups?").
Spotify then creates a sort of cloud, with different artists and how closely related they are to each other to recommend songs to its user, pushing new songs by previously enjoyed artists to the users release radar, and artists that fall into their taste spectrum that the user has not yet listened to into their discover weekly playlist.
Source: Dmitry Pastukhov
https://www.music-tomorrow.com/blog/how-spotify-recommendation-system-works-a-complete-guide-2022