Byte-Sized Design

Byte-Sized Design

Share this post

Byte-Sized Design
Byte-Sized Design
How Spotify Knows What You Want to Listen to Next

How Spotify Knows What You Want to Listen to Next

Promise you will not be “annoyed”

Byte-Sized Design's avatar
Bhavana's avatar
Byte-Sized Design
and
Bhavana
Mar 05, 2024
∙ Paid
44

Share this post

Byte-Sized Design
Byte-Sized Design
How Spotify Knows What You Want to Listen to Next
3
Share

📝 tldr;

Whether or not you need a break from the ads, here's how Spotify recommends their next song:

  • They use an algorithm called ANNOY (Approximate Nearest Neighbors Oh Yeah).

  • ANNOY relies on objects (songs in this case) represented as “vectors”. Vectors are points in an n-dimensional space where points closer to each other are considered more similar than points far away from each other.

  • Instead of scanning the entire vector space to find the exact nearest neighbors of your song (which would need O(N) time), ANNOY uses a binary-tree-based approach to find the approximate nearest neighbors which brings down the time complexity to O(log N).

🙋‍♀️ Credit to our Contributing Author

Bhavana wrote this amazing article to share with our 21,001+ readers!

Bhavana Hindupur is a Principal Software Engineer at Microsoft. She brings experience from her tenure at tech giants Google and Amazon, where she designed and implemented several large-scale solutions in the cloud.

Read more from her at thepeoplessoftwareengineer

💡 What are Vectors?

In the context of search, vectors are a way of representing data as points in a multidimensional space where the distance between the points is an indicator of similarity.

💪 Brute Force Approach (k Nearest Neighbors or kNN)

Keep reading with a 7-day free trial

Subscribe to Byte-Sized Design to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Byte-Sized Design
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share