<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ashton Gribble on Medium]]></title>
        <description><![CDATA[Stories by Ashton Gribble on Medium]]></description>
        <link>https://medium.com/@ashton.gribble?source=rss-32a5594fc6df------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*CwTpvZTVUwnxVeQKGx02fw@2x.jpeg</url>
            <title>Stories by Ashton Gribble on Medium</title>
            <link>https://medium.com/@ashton.gribble?source=rss-32a5594fc6df------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 21:54:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ashton.gribble/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Five-Second Fingerprint: Inside Shazam’s Instant Song ID]]></title>
            <link>https://python.plainenglish.io/inside-shazams-instant-id-9853e42aed2c?source=rss-32a5594fc6df------2</link>
            <guid isPermaLink="false">https://medium.com/p/9853e42aed2c</guid>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[music]]></category>
            <dc:creator><![CDATA[Ashton Gribble]]></dc:creator>
            <pubDate>Wed, 18 Jun 2025 02:07:06 GMT</pubDate>
            <atom:updated>2025-06-19T00:19:24.121Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This post continues </em><strong><em>Behind the Tap</em></strong><em>, a series exploring the hidden mechanics of everyday tech — from Uber to Spotify to search engines. I’ll dive under the hood to demystify the systems shaping your digital world.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dV5WRCcnuvdZG6FvwVtNuQ@2x.jpeg" /><figcaption>Photo by <a href="https://appshunter.io/">appshunter.io</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>My first relationship with music listening started at 6, rotating through the albums in the living room’s Onkyo 6-disc player. <em>Cat Stevens</em>, <em>Groove</em> <em>Armada</em>, <em>Sade</em>. There was always one song I kept rewinding to, though I didn’t know its name. 10 years on, moments of the song returned to memory. I searched through forums, ‘<em>old saxophone melody’</em>, ‘<em>vintage song about sand dunes</em>’, looking for years with no success. Then, one day at university, I was in my friend Pegler’s dorm room when he played it:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FwzCt7ABUU9Y%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DwzCt7ABUU9Y&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FwzCt7ABUU9Y%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0aa4bcc2a6c4799ab20534c71580ca4e/href">https://medium.com/media/0aa4bcc2a6c4799ab20534c71580ca4e/href</a></iframe><p>That long search taught me how important it is to be able to find the music you love.</p><p>Before streaming and smart assistants, music discovery relied on memory, luck, or a friend with good music taste. That one catchy chorus could be lost to the ether.</p><p>Then came a music-lover’s miracle.</p><p>A few seconds of sound. A button press. And a name on your screen.</p><p>Shazam made music recognisable.</p><h3>The Origin: 2580</h3><p>Shazam launched in 2002, long before apps were a thing. Back then it worked like this:</p><p>You’d dial <strong>2580#</strong> on your mobile (UK only).<br>Hold your phone up to the speaker.<br>…Wait in silence…<br>And receive a <strong>SMS</strong> telling you the name of the song.</p><p>It felt like magic. The founding team, Chris Barton, Philip Inghelbrecht, Avery Wang, and Dhiraj Mukherjee, spent years building that illusion.</p><p>To build its first database, <a href="https://www.youtube.com/watch?v=b6xeOLjeKs0&amp;list=LL&amp;index=3&amp;t=185s">Shazam hired 30 young workers</a> to run 18-hour shifts, manually loading 100,000 CDs into computers and using custom software. Because CD’s don’t contain metadata they had to type the names of the songs manually, referring to the CD sleeve, to eventually create the company’s first million audio fingerprints — a painstaking process that took months.</p><p>In an era before smartphones or apps, when Nokia’s and Blackberry’s couldn’t handle the processing or memory demands, Shazam had to stay alive long enough for the technology to catch up to their idea. This was a lesson in market timing.</p><p>This post is about what happens in the moment between the tap and the title, the signal processing, hashing, indexing, and pattern matching that lets Shazam hear what you can’t quite name.</p><h3>The Algorithm: Audio Fingerprinting</h3><p>In 2003, Shazam co-founder Avery Wang <a href="https://www.ee.columbia.edu/~dpwe/papers/Wang03-shazam.pdf">published</a> the blueprint for an algorithm that still powers the app today. The paper’s central idea: If humans can understand music by <strong>superimposing</strong> layers of sound, a machine could do it too.</p><p>Let’s walk through how Shazam breaks sound down to something a machine can recognise instantly.</p><h3>1. Capturing Audio Sample</h3><p><em>It starts with a tap.</em></p><p>When you hit the Shazam button, the app records a 5–10 second snippet of the audio around you. This is long enough to identify most songs, though we’ve all waited minutes holding our phones in the air (or hiding in our pockets) for the ID.</p><p>But Shazam doesn’t store that recording. Instead, it reduces it to something far smaller and smarter: a <strong>fingerprint</strong>.</p><h3>2. Generating the Spectrogram</h3><p>Before Shazam can recognise a song, it needs to understand what<strong> </strong>frequencies are in the sound and when they occur. To do this, it uses a mathematical tool called the <a href="https://www.sciencedirect.com/topics/engineering/fast-fourier-transform">Fast Fourier Transform (FFT)</a>.</p><p>The <strong>FFT</strong> breaks an audio signal into its component frequencies, revealing which notes or tones make up the sound at any moment.</p><p><strong>Why it matters: </strong>Waveforms are fragile, sensitive to noise, pitch changes, and device compression. But frequency relationships over time remain stable. That’s the gold.</p><blockquote>If you studied Mathematics at Uni, you would remember the struggles of learning the <a href="https://www.robots.ox.ac.uk/~sjrob/Teaching/SP/l7.pdf">Discrete Fourier Transform process.</a> <strong>Fast Fourier Transform (FFT</strong>) is a more efficient version that lets us decompose a complex signal into its frequency components, like hearing all the notes in a chord.</blockquote><p>Music isn’t static. Notes and harmonics change over time. So Shazam doesn’t just run FFT once, it runs it repeatedly over small, overlapping windows of the signal. This process is known as the <strong>Short-Time Fourier Transform (STFT)</strong> and forms the basis of the <strong>spectrogram</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*4QTvJNX2XsQlSJQQXbFLDg.png" /><figcaption><a href="https://www.nti-audio.com/en/support/know-how/fast-fourier-transform-fft">Source</a>: Fast Fourier Transformation Visualised</figcaption></figure><p>The resulting <strong>spectrogram </strong>is a transformation of sound from the <strong>amplitude-time domain</strong> (waveform) into the <strong>frequency-time domain</strong>.</p><p>Think of this as turning a messy audio waveform into a musical heatmap.<br>Instead of showing how loud the sound is, a spectrogram shows <strong>what frequencies</strong> are present <strong>at what times</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SJRWmJezaJoaWO_EuvY5-g.png" /><figcaption>A visualisation of the transition from a waveform to a spectrogram using FFT</figcaption></figure><blockquote>A spectrogram moves analysis from the <strong>amplitude-time domain</strong> to <strong>frequency-time domain</strong>. It displays time on the horizontal axis, frequency on the vertical axis, and uses brightness to indicate the amplitude (or volume) of each frequency at each moment. This allows you to see not just which frequencies are present, but also how their intensity evolves, making it possible to identify patterns, transient events, or changes in the signal that are not visible in a standard time-domain waveform.</blockquote><blockquote><a href="https://en.wikipedia.org/wiki/Spectrogram">Spectrograms </a>are widely used in fields such as audio analysis, speech processing, seismology, and music, providing a powerful tool for understanding the temporal and spectral characteristics of signals.</blockquote><h3>3. From Spectrogram to Constellation Map</h3><p>Spectrograms are dense and contain too much data to compare across millions of songs. Shazam filters out low-intensity frequencies, leaving just the loudest peaks.</p><p>This creates a constellation map, a visual scatterplot of standout frequencies over time, similar to sheet music, although it reminds me of a mechanical music-box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E48WEqrvCYgMwWNPGJnJaA.png" /><figcaption>A visualisation of the transition into a Constellation Map</figcaption></figure><h3>4. Creating the Audio Fingerprint</h3><p>Now comes the magic, turning points into a signature.</p><p>Shazam takes each anchor point (a dominant peak) and pairs it with target peaks in a small time window ahead — forming a connection that encodes both frequency pair and timing difference.</p><p>Each of these becomes a hash tuple:</p><blockquote>(anchor_frequency, target_frequency, time_delta)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SAX1Os_5mmUtaqvJ_35Tpg.png" /><figcaption><a href="https://www.ee.columbia.edu/~dpwe/papers/Wang03-shazam.pdf">Source</a>: ‘Fingerprint’ Hash Generation example from the original paper.</figcaption></figure><h4>What is a Hash?</h4><p>A hash is the output of a mathematical function, called a hash function, that transforms input data into a fixed-length string of numbers and/or characters. It’s a way of turning complex data into a short, unique identifier.</p><p><a href="https://www.codecademy.com/resources/blog/what-is-hashing/">Hashing</a> is widely used in computer science and cryptography, especially for tasks like data lookup, verification, and indexing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*X-xJmcQ4ibxRcVqJWcWSmg.png" /><figcaption>Refer to this <a href="https://medium.com/nybles/hashing-algorithms-d10171ca2e89">source</a> understand Hashing</figcaption></figure><p>For Shazam, a typical <strong>hash is 32 bits</strong> long, and it <em>might</em> be structured like this:</p><ul><li><strong>10 bits</strong> for the anchor frequency</li><li><strong>10 bits</strong> for the target frequency</li><li><strong>12 bits</strong> for the time delta between them</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/1*sGUN7HwOfza9xSBdSPM1tg.png" /><figcaption>A visualisation of the hashing example from above</figcaption></figure><p>This tiny fingerprint captures the relationship between two sound peaks and how far apart they are in time, and is strong enough to identify the song and small enough to transmit quickly, even on low-bandwidth connections.</p><h3>5. Matching Against the Database</h3><p>Once Shazam creates a fingerprint from your snippet, it needs to quickly find a match in its database containing millions of songs.</p><p>Although Shazam has no idea where in the song your clip came from — intro, verse, chorus, bridge — doesn’t matter, it looks for relative timing between hash pairs. This makes the system robust to time offsets in the input audio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aRq8Ebg45BDfb7N6FEje4w.png" /><figcaption><a href="https://www.cameronmacleod.com/blog/how-does-shazam-work">Source</a>: Visualisation of matching hashes to a database song</figcaption></figure><p>Shazam compares your recording’s hashes against its database and identifies the song with the highest number of matches, the fingerprint that best lines up with your sample, even if it’s not an exact match due to background noise.</p><h4>How it Searches So Fast</h4><p>To make this lightning-fast, Shazam uses a <a href="https://www.masaischool.com/blog/understanding-hashmap-data-structure-with-examples/"><strong>hashmap</strong></a><strong>, </strong>a data structure that allows for near-instant lookup.</p><blockquote>A hashmap can find a match in O(1) time, that means the lookup time stays constant, even if there are millions of entries.</blockquote><blockquote>In contrast, a sorted index (like B-tree on disk) takes O(log n) time, which grows slowly as the database grows.</blockquote><blockquote>This balance of time and space complexity is known as <a href="https://medium.com/@DevChy/introduction-to-big-o-notation-time-and-space-complexity-f747ea5bca58">Big O Notation</a>, theory I am not prepared of bothered to teach. Please refer to a Computer Scientist.</blockquote><h3>6. Scaling the System</h3><p>To maintain this speed at global scale, Shazam does more than just use fast data structures, it optimises how and where the data lives:</p><ul><li><a href="https://aws.amazon.com/what-is/database-sharding/">Shards</a> the database — dividing it by time range, hash prefix, or geography</li><li>Keeps hot shards in memory (RAM) for instant access</li><li>Offloads colder data to disk, which is slower but cheaper to store</li><li>Distributes the system by region (e.g., US East, Europe, Asia ) so recognition is fast no matter where you are</li></ul><p>This design supports <strong>23,000+ recognitions per minute</strong>, even at global scale.</p><h3>Impact &amp; Future Applications</h3><p>The obvious application is music discovery on your phone, but there is another major application of Shazam’s process.</p><p>Shazam facilitates <strong>Market Insights. </strong>Every time a user tags a song, Shazam collects anonymised, geo-temporal metadata (where, when, and how often a song is being ID’d.)</p><p>Labels, artists, and promoters use this to:</p><ul><li>Spot breakout tracks before they hit the charts.</li><li>Identify regional trends (a remix gaining traction in Tokyo before LA).</li><li>Guide marketing spend based on organic attraction.</li></ul><p>Unlike Spotify, which uses user listening behaviour to refine recommendations, Shazam provides real-time data on songs people actively identify, offering the music industry early insights into emerging trends and popular tracks.</p><p><a href="https://medium.com/@ashton.gribble/what-spotify-hears-before-you-do-ca7a86be3e20">What Spotify Hears Before You Do</a></p><p>On December 2017, <strong>Apple</strong> bought Shazam for a reported<strong> $400 million</strong>. Apple reportedly uses Shazam’s data to augment Apple Music’s recommendation engine<strong>,</strong> and record labels now monitor Shazam trends like they used to monitor <em>radio spins</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*e1O95_eqlFOWPgHc" /><figcaption>Photo by <a href="https://unsplash.com/@rachelcoyne?utm_source=medium&amp;utm_medium=referral">Rachel Coyne</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In the future, there is expected evolution in areas like:</p><ul><li><a href="https://thenextweb.com/news/shazam-can-now-scan-physical-objects-for-augmented-reality-and-exclusive-video-content"><strong>Visual Shazam:</strong></a><strong> </strong>Already piloted, point you camera at an object or artwork to identify it, useful for an Augmented Reality future.</li><li><strong>Concert Mode:</strong> Identify songs live during gigs and sync to a real-time setlist.</li><li><a href="https://www.digitaltrends.com/mobile/shazam-now-shows-the-worlds-fastest-growing-songs/"><strong>Hyper-local trends</strong></a><strong>: </strong>Surface what’s trending ‘on this street’ or ‘in this venue’, expanding community-shared music taste.</li><li><strong>Generative AI integration: P</strong>air audio snippets with lyric generation, remix suggestions, or visual accompaniment.</li></ul><h3>Outro: The Algorithm That Endures</h3><p>In a world of ever-shifting tech stacks, it’s rare for an algorithm to stay relevant for over 20 years.</p><p>But Shazam’s fingerprinting method hasn’t just endured, it’s scaled, evolved, and become a blueprint for audio recognition systems across industries.</p><p>The magic isn’t just that Shazam can name a song. It’s how it does it, turning messy sound into elegant math, and doing it reliably, instantly, and globally.</p><p>So next time you’re in a loud, trashy bar holding your phone up to the speaker playing <em>Lola Young’s ‘Messy’ </em>just remember: behind that tap is a beautiful stack of signal processing, hashing, and search, designed so well it barely had to change.</p><p>Curious about another everyday tech you don’t fully understand? Comment below and I’ll break it down in a future <strong><em>Behind the Tap </em></strong>post.</p><h3>Thank you for being a part of the community</h3><p><em>Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏<strong>️️</strong></li><li>Follow us: <a href="https://x.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/@InPlainEnglish"><strong>YouTube</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a> | <a href="https://twitch.tv/inplainenglish"><strong>Twitch</strong></a></li><li><a href="https://differ.blog/"><strong>Start your own free AI-powered blog on Differ</strong></a> 🚀</li><li><a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Join our content creators community on Discord</strong></a> 🧑🏻‍💻</li><li>For more content, visit <a href="https://plainenglish.io/"><strong>plainenglish.io</strong></a> + <a href="https://stackademic.com/"><strong>stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9853e42aed2c" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/inside-shazams-instant-id-9853e42aed2c">The Five-Second Fingerprint: Inside Shazam’s Instant Song ID</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Spotify Hears Before You Do]]></title>
            <link>https://python.plainenglish.io/what-spotify-hears-before-you-do-ca7a86be3e20?source=rss-32a5594fc6df------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca7a86be3e20</guid>
            <category><![CDATA[recommendation-system]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[spotify]]></category>
            <dc:creator><![CDATA[Ashton Gribble]]></dc:creator>
            <pubDate>Tue, 10 Jun 2025 12:10:36 GMT</pubDate>
            <atom:updated>2025-06-19T00:19:29.097Z</atom:updated>
            <content:encoded><![CDATA[<p>This post kicks off <strong><em>Behind the Tap</em></strong>, a series exploring the hidden mechanics of everyday tech — from Uber to Spotify to search engines. I’ll dive under the hood to demystify the systems shaping your digital world.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*HS5U_eNpqKUUa6wUzbtIZA.jpeg" /><figcaption><a href="https://www.hola.com/us/entertainment/20241202733614/when-spotify-wrapped-2024/">Source</a></figcaption></figure><blockquote><em>It’s 1985, and you’re cruising in your car, sliding a TDK cassette into the deck, ready to record </em>Money for Nothing<em> by </em>Dire Straits<em> off the car radio. If you time it right, you’ll capture that iconic guitar riff without the DJ’s speaking over it. That tape, maybe with a few other tracks, will be your soundtrack for the next month, unless the tape deck chews it up.</em></blockquote><blockquote><em>Fast forward 20 years, and you’re hunched over your Dell Inspiron 2200, burning the </em>Demon Days <em>album onto a CD with tracks you snagged from Limewire, each download infecting your PC with four irreversible bugs. You Sharpie </em>“Gorillaz ‘05”<em> on the disc and it’ll live in your stereo for weeks.</em></blockquote><blockquote><em>Now, 20 years on, you open Spotify with your morning coffee, tap the Home tab, and there it is: </em>Morning Acoustic Mix<em>, a relaxing and eclectic playlist that nails your mood, no search required.</em></blockquote><p>In four decades, we’ve gone from manually timing cassette recordings to AI that seems to read your mind.</p><p>This isn’t guesswork. It’s a precise blend of data, algorithms, and insights about you, delivered in a split second. In the moment before your playlist appears, Spotify’s recommendation system processes your habits, context, and even your mood.</p><p>This post unpacks that instant, explaining the tech in a way for Spotify fans and Data Scientists alike.</p><p><strong>TL;DR - Spotify’s Recommendations, Simplified:</strong></p><ul><li>Spotify turns songs and users into points in a mathematical space (vectors).</li><li>It tracks your context (time, device, location) and recent listening habits.</li><li>It picks songs that match your current vibe, not just your overall taste.</li><li>It uses advanced models, including Transformers, to balance familiarity with discovery.</li><li>The whole process happens in under a second.</li></ul><h3>The Split-Second Workflow: How Spotify Recommends a Song</h3><p>In the brief moment (likely under a second) before you see a recommendation, Spotify:</p><ol><li><strong>Captured your Context:</strong> It notes the time, your device (phone or laptop?), rough location, and device (headphones or a speaker?)</li><li><strong>Reviews your Behaviour:</strong> What did you listen to recently? Did you replay that Coldplay track or skip that jazz song after five seconds? These choices shape your musical profile.</li><li><strong>Turns you into numbers: </strong>Your listening habits become a “taste vector,” a numerical snapshot of your preferences.</li><li><strong>Finds Matching Songs: </strong>Spotify compares your taste vector to millions of song vectors, each capturing features like tempo or mood, to create a shortlist of tracks.</li><li><strong>Ranks the Best Options: </strong>A model scores each song based on how likely you are to enjoy it or discover something new, blending familiarity with surprises.</li><li><strong>Filters the Final Picks: </strong>It removes tracks you can’t access due to licensing, region, or content settings.</li></ol><p>By the time you stop scrolling, Spotify has crafted a recommendation that feels tailor-made.</p><h3>Music as Math: How Spotify Thinks in Vectors</h3><p>Spotify doesn’t see music as just genres or artists, it sees <em>vectors</em>. Every song is distilled into a set of numbers, a vector, that captures its essence. These numbers reflect:</p><ul><li><strong>Sound</strong>: Tempo, energy, acoustic or electronic vibe, happy or moody tone.</li><li><strong>Context</strong>: Artist popularity, release date, or playlist trends.</li><li><strong>Lyrics</strong>: Upbeat or sombre? Simple or complex? (Though audio features dominate.)</li><li><strong>Listener Behaviour</strong>: Do people skip it early or play it on repeat?</li></ul><p>This process, called <a href="https://towardsdatascience.com/word-embeddings-intuition-behind-the-vector-representation-of-the-words-7e4eb2410bba/"><strong>vectorisation</strong></a>, turns songs and your listening habits into points in a high-dimensional mathematical space. Imagine a map where vectors are close are far from each other based on their similarities. A chill lo-fi track might sit near an acoustic ballad but far from a death metal anthem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9bkdFe32lT3Kn6PAoa_yvQ.png" /><figcaption>A simplified tldraw visualisation of Vector Embeddings</figcaption></figure><p>You, the listener, get your own vector too. It’s built from your listening history, but it’s not static. At 7:43 a.m. on Tuesday, your vector might lean toward mellow tunes. At 10:23 p.m. on a Saturday, it might mean dance anthems. This <strong>embedding, </strong>a fancy term for mapping you and songs into this number space, lets Spotify find the perfect match for your mood.</p><blockquote>Spotify creates embeddings — typically 128- or 256-dimensional vectors, using audio features (via tools like EchoNest) and user interactions. Lyrics play a smaller role (although increasing importance for regional context), analysed with natural language processing (NLP) techniques like <a href="https://medium.com/@manansuri/a-dummys-guide-to-word2vec-456444f3c673"><strong>word2vec</strong></a>. To match your taste vector to millions of songs in milliseconds, Spotify likely uses <a href="https://github.com/facebookresearch/faiss"><strong>FAISS</strong> (Facebook AI Similarity Search),</a> an open-source library for efficient similarity searches. FAISS employs Approximate Nearest Neighbor (ANN) algorithms, like<strong> </strong><a href="https://www.pinecone.io/learn/series/faiss/hnsw/"><strong>HNSW </strong>(Hierarchical Navigable Small World)</a>, to find the closest song vectors in a massive dataset, optimising for speed and scale.</blockquote><h3>The Evolution of Spotify’s Recommendation System</h3><p>Spotify’s system has come a long way…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zGrkBsn8g0RmBAD5b3y77w.png" /><figcaption>A tldraw visualisation of Spotify’s model history (approximate)</figcaption></figure><p>Back in the day, it used the matrix factorisation method called <a href="https://medium.com/@umut.kocatas41/recommender-systems-association-rules-with-apriori-da15fc0f28ab"><strong>collaborative filtering</strong></a>. <em>If you liked Song A, and thousands of others who liked Song A also loved Song B, you’d get Song B. </em>Simple, but limited. It could trap you in a “loop” of similar music, ignoring your shifting moods.</p><p>By 2016, Spotify introduced <strong>BaRT</strong> (Bandits for Recommendations as Treatments), a personalised recommendation framework grounded in <strong>contextual multi-armed bandits</strong> and <strong>causal inference.</strong></p><p>It didn’t just show you what others liked — it tested whether a recommendation would <em>increase</em> your engagement compared to alternatives. Each suggestion was treated like a “treatment” in a clinical trial, and Spotify measured its <strong>uplift</strong> in play-through, skip rate, or playlist adds, tailored to your context:</p><ul><li><strong>Device</strong>: Phone sessions are shorter; smart speakers suggest background listening.</li><li><strong>Time</strong>: Chill in the morning; energetic at night.</li><li><strong>Listening Setup</strong>: Headphones imply more curated listening than Bluetooth in a car.</li></ul><blockquote><a href="https://thedecisionlab.com/reference-guide/statistics/casual-inference"><strong>Causal Inference</strong></a><strong>: </strong>The term used for the process of determining whether an observed association truly reflects a cause-and-effect relationship. It treats each playlist/song recommendation like a “treatment” in a clinical trial, and tries to learn the <strong>causal effect</strong> of showing a particular recommendation to a user in a given context (e.g., time of day, device, listening history).</blockquote><blockquote><a href="https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/37042.pdf"><strong>Contextual multi-armed bandits</strong></a><strong>: </strong>A machine learning approach that enhances decision-making by considering contextual information to select the best action for each specific situation, maximising cumulative rewards. Models used are Uplift Modelling, Thompson Sampling, and Bayesian Methods (“Ba” in BaRT)</blockquote><p>While <strong>BaRT</strong> optimised which song to play based on context, Spotify also needed to understand how users moved through listening sessions: what they skipped, replayed, or let play through. This led to the use of <strong>sequence models</strong>, such as <a href="https://www.ibm.com/think/topics/recurrent-neural-networks"><strong>Recurrent Neural Networks (RNNs)</strong></a> and <a href="https://unit8.com/resources/temporal-convolutional-networks-and-forecasting/"><strong>Temporal Convolutional Networks (TCNs)</strong></a>, which could learn patterns in the order of your listening. These models treated your sessions like evolving narratives, helping Spotify predict not just what you might like in general, but what makes sense next.</p><blockquote><strong>Recurrent Neural Networks (RNNs): </strong>A type of neural network designed to process sequential data by retaining information from previous steps, making it ideal for modelling time-dependent user behaviour.</blockquote><blockquote><strong>TCN (Temporal Convolutional Network):</strong> A convolutional architecture for sequence modelling that captures long-range dependencies using dilated causal convolutions, sometimes outperforming RNNs in stability and training speed.</blockquote><p>By 2018, Spotify started blending <strong>content-based features</strong> (like a song’s tempo or mood) with your behaviour to recommend new releases or obscure tracks. This solved the <a href="https://www.freecodecamp.org/news/cold-start-problem-in-recommender-systems/#:~:text=The%20item%20cold%20start%20problem,the%20item%20to%20be%20recommended.">“cold-start” problem</a>, how to recommend a song no one’s heard yet. They extract audio features and use embedding similarity &amp; user clustering to estimate whether a user <em>similar to you</em> would engage. They also introduced <a href="https://www.ibm.com/think/topics/natural-language-processing">Natural Language Processing (NLP)</a> approaches - scanning blogs, reviews, articles, and social media, building an understand how songs and artists are described online and to label tracks with trending genres, moods, and cultural context for more nuanced recommendations.</p><blockquote><strong>Natural Language Processing (NLP): </strong>a branch of artificial intelligence that uses machine learning and computational linguistics to enable computers to understand, interpret, and generate human language in both text and speech.</blockquote><p>In 2021, Spotify likely adopted<a href="https://research.atspotify.com/publications/multi-task-learning-of-graph-based-inductive-representations-of-music-content/"> <strong>multi-task learning</strong></a>, where models predict not just clicks but satisfaction metrics (e.g. click probability, replay likelihood, playlist adds) using shared representations. By 2023, they began exploring <strong>Transformer-based models</strong>, the same architecture behind systems like ChatGPT, though adapted for Spotify’s real-time recommendations. Combined with FAISS, these models make recommendations faster and more personal than ever.</p><h4>Technical Breakdown: Multi-Task Learning and Transformers</h4><blockquote><strong>Multi-task learning</strong> trains a single model to optimise multiple objectives (e.g., click probability, replay likelihood, playlist adds) using shared representations. This improves generalisation and reduces overfitting compared to single-task models.</blockquote><blockquote><strong>Transformers</strong>, with their attention mechanisms, excel at modeling sequential data, capturing long-range dependencies in listening histories (e.g., how a week of jazz influences a weekend of pop). Spotify likely uses lightweight Transformer variants for real-time inference, combined with <a href="https://towardsdatascience.com/comprehensive-guide-to-approximate-nearest-neighbors-algorithms-8b94f057d6b6/">FAISS </a>for scalable vector searches.</blockquote><h3>Where to from here?</h3><p>Spotify’s system is already a marvel, but it’s not standing still. Here’s where it’s likely headed:</p><ul><li><a href="https://research.atspotify.com/2020/05/giving-voice-to-silent-data-designing-with-personal-music-listening-history/"><strong>Spotify R&amp;D — Voice Assistance:</strong></a> Spotify R&amp;D team conducted empirical studies consisting of workshops where participants were asked to design potential <em>future</em> interactions with a voice assistant around music. Spotify acquired the live audio app <strong><em>Locker Room</em> </strong>in March 2021, rebranded it as Spotify <strong><em>Greenroom</em></strong>, and expanded its focus from sports to a broader range of live audio content for creators and fans to interact in real time.</li><li><strong>Emotion-Aware Recommendations</strong>: Future models could analyse your voice (via Spotify’s voice features) or wearable data (like heart rate) to gauge your mood. Feeling stressed? Spotify might suggest calming lo-fi without you saying a word.</li><li><strong>Social Listening</strong>: Imagine recommendations that blend your taste with your friends’, perfect for group hangouts. Spotify’s experiments with shared sessions could evolve into real-time, crowd-sourced playlists.</li><li><strong>Hyper-Personalisation</strong>: Advances in <strong>reinforcement learning</strong> could let Spotify adapt on the fly, tweaking recommendations based on your immediate reactions (like skipping a song after 3 seconds).</li><li><strong>Ethical AI</strong>: Spotify is investing in fairness, ensuring recommendations don’t amplify biases or over-prioritise popular artists, giving smaller creators a shot.</li></ul><blockquote>Reinforcement learning could use <strong>bandit algorithms</strong> to balance exploration (new songs) and exploitation (known favourites) in real time. Recommendation Fairness might involve <a href="https://web.stanford.edu/group/sisl/k12/optimization/MO-unit3-pdfs/3.1introandgraphical.pdf"><strong>constrained optimisation</strong></a>, ensuring diverse artist representation in recommendations</blockquote><h3>Final Thoughts</h3><p>Spotify’s recommendations feel like a friend who knows your music taste better than you do. But behind that perfect playlist is math and tech: vectors mapping your mood, neural networks predicting your next click, and algorithms racing to deliver in under a split second.</p><p>For everyday users, it’s a seamless experience that makes mornings brighter or workouts more energetic. For data scientists, it’s a masterclass in embeddings, real-time search, and Transformer models.</p><p>Next time you open Spotify, take a second to reflect: that Morning Acoustic Mix isn’t just a playlist. It’s a snapshot of you, crafted in a blink.</p><p>~~~</p><p>Curious about another everyday tech you don’t fully understand? Comment below and I’ll break it down in a future <strong><em>Behind the Tap </em></strong>post.</p><h3>Thank you for being a part of the community</h3><p><em>Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏<strong>️️</strong></li><li>Follow us: <a href="https://x.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/@InPlainEnglish"><strong>YouTube</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a> | <a href="https://twitch.tv/inplainenglish"><strong>Twitch</strong></a></li><li><a href="https://differ.blog/"><strong>Start your own free AI-powered blog on Differ</strong></a> 🚀</li><li><a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Join our content creators community on Discord</strong></a> 🧑🏻‍💻</li><li>For more content, visit <a href="https://plainenglish.io/"><strong>plainenglish.io</strong></a> + <a href="https://stackademic.com/"><strong>stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca7a86be3e20" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/what-spotify-hears-before-you-do-ca7a86be3e20">What Spotify Hears Before You Do</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[99 Ways to Stop Overfitting in Machine Learning]]></title>
            <link>https://medium.com/@ashton.gribble/99-ways-to-stop-overfitting-in-machine-learning-5fe6bb5a726f?source=rss-32a5594fc6df------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fe6bb5a726f</guid>
            <category><![CDATA[overfitting]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[model-evaluation]]></category>
            <dc:creator><![CDATA[Ashton Gribble]]></dc:creator>
            <pubDate>Thu, 05 Jun 2025 02:57:58 GMT</pubDate>
            <atom:updated>2025-06-05T06:24:30.286Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://drive.google.com/file/d/16IqwAay9sslhR3HY8eJvF5NpzOL1USA7/view?usp=sharing"><strong>Download the PDF Version!</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B_aC5BA9j4TZJvgZ9GIqVg.jpeg" /></figure><h4>…I got 99 problems…</h4><p>Your model hits 99% accuracy on training data and you think you’ve nailed it. But when it sees new data, it <em>collapses</em>. That’s not intelligence — it’s memorisation.</p><p>Overfitting happens when a model learns not just the underlying patterns — but the noise, quirks, and outliers in the training data. It performs brilliantly where it was trained, but fails to generalise. Underfitting is the opposite — a model that hasn’t even learned the signal properly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5GoHWaLfz96vB3KHQDAtFw.png" /><figcaption><a href="https://en.wikipedia.org/wiki/Bias%E2%80%93variance_tradeoff">Source</a></figcaption></figure><p>In production, generalisation is what matters. This post breaks down <strong>99 practical ways to beat overfitting</strong> — from better data practices to regularisation, architecture tweaks, and evaluation strategies. It’s a checklist for building models that don’t just perform in notebooks, but in the real world too.</p><h3>Data-Related Techniques (1–20)</h3><p><em>Data quality, quantity, and diversity are your first defense against overfitting.</em></p><p><strong>1. Increase Training Data</strong> → More examples = better generaliation.</p><p><strong>2. Data Augmentation</strong> → Flip, rotate, scale images or reword text to create diversity.</p><p><strong>3. Balance the Dataset</strong> → Handle class imbalance with SMOTE or undersampling.</p><p><strong>4. Clean Data</strong> → Remove outliers and fix labeling errors.</p><p><strong>5. Use Cross-Validation</strong> → Ensure stable performance across data subsets.</p><p><strong>6. Stratified Sampling</strong> → Maintain class proportions during splits.</p><p><strong>7. Synthetic Data Generation</strong> → Use GANs or simulation for scarce classes.</p><p><strong>8. Feature Selection</strong> → Keep only relevant features.</p><p><strong>9. Feature Engineering</strong> → Create meaningful, domain-informed features.</p><p><strong>10. Normalise/Standardise Data</strong> → Bring features to the same scale.</p><p><strong>11. Remove Duplicates</strong> → Prevent memorisation of identical data.</p><p><strong>12. Use External Datasets</strong> → Bring in complementary data sources.</p><p><strong>13. Data Shuffling</strong> → Avoid order bias in training.</p><p><strong>14. Time-Based Splits</strong> → For time-series tasks, preserve sequence.</p><p><strong>15. Domain-Specific Augmentation</strong> → NLP: synonym swap, Computer Vision: colour jitter.</p><p><strong>16. Handle Missing Values</strong> → Impute smartly or flag with indicators.</p><p><strong>17. Use a Validation Set</strong> → Hold out a set to monitor overfitting.</p><p><strong>18. Test-Time Augmentation</strong> → Boost robustness during inference.</p><p><strong>19. Data Denoising</strong> → Apply smoothing or filtering techniques.</p><p><strong>20. Cross-Dataset Validation</strong> → Validate on related datasets.</p><h3>Model Simplification (21–30)</h3><p><em>Overfit models are often just too complex for the task.</em></p><p><strong>21.</strong> <strong>Reduce Model Complexity</strong> → Fewer layers or parameters.</p><p><strong>22.</strong> <strong>Limit Model Depth</strong> → Shallower networks generalise better.</p><p><strong>23.</strong> <strong>Decrease Parameters</strong> → Constrain learning capacity.</p><p><strong>24.</strong> <strong>Use Linear Models</strong> → Simpler models first!</p><p><strong>25. Prune Decision Trees</strong> → Avoid overfitting to node splits.</p><p><strong>26. Restrict Polynomial Features</strong> → Avoid high-degree overfit.</p><p><strong>27. Simplify Activation Functions</strong> → ReLU over complex variants.</p><p><strong>28.</strong> <strong>Reduce Hidden Units</strong> → Limit each layer’s power.</p><p><strong>29. Use Shallow Networks</strong> → Especially when data is small.</p><p><strong>30. Avoid Over-Engineering</strong> → Don’t overdesign your pipeline.</p><h3>Regularisation Techniques (31–50)</h3><p><em>Regularisation constrains the model to prefer simplicity.</em></p><p><strong>31. L1 Regularisation (Lasso)</strong> → Encourages sparsity.</p><p><strong>32. L2 Regularisation (Ridge)</strong> → Penalises large weights.</p><p><strong>33.</strong> <strong>Elastic Net</strong> → Combines L1 + L2.</p><p><strong>34. Dropout</strong> → Randomly drops neurons.</p><p><strong>35. DropConnect</strong> → Randomly drops weights.</p><p><strong>36. Weight Decay</strong> → Implicit L2 penalty.</p><p><strong>37. Batch Normalisation</strong> → Stabilises and regularises.</p><p><strong>38. Layer Normalisation</strong> → Especially in transformers.</p><p><strong>39. Noise Injection</strong> → Adds input noise to discourage memorisation.</p><p><strong>40. Sparsity Constraints</strong> → Encourage fewer activations.</p><p><strong>41. Max-Norm Constraint</strong> → Limit weight magnitudes.</p><p><strong>42. Label Smoothing</strong> → Reduces model confidence.</p><p><strong>43. Mixup Regularisation</strong> → Blends examples and labels.</p><p><strong>44. Cutout</strong> → Randomly mask image patches.</p><p><strong>45. Stochastic Depth</strong> → Drop layers during training.</p><p><strong>46. Gradient Clipping</strong> → Stabilises training.</p><p><strong>47. Knowledge Distillation</strong> → Transfer generalisation from larger model.</p><p><strong>48. Adversarial Regularisation</strong> → Train with adversarial examples.</p><p><strong>49. Entropy Regularisation</strong> → Encourages diversity.</p><p><strong>50. Spectral Normalisation</strong> → Normalise weight matrices.</p><h3>Training Process Adjustments (51–60)</h3><p><em>Training itself can introduce or prevent overfitting.</em></p><p><strong>51. Early Stopping</strong> → Monitor val loss and halt early.</p><p><strong>52. Reduce Epochs</strong> → Don’t train forever.</p><p><strong>53. Learning Rate Decay</strong> → Stabilise learning over time.</p><p><strong>54. Smaller Batch Size</strong> → Adds gradient noise.</p><p><strong>55. Gradient Noise</strong> → Explicit noise injection.</p><p><strong>56. Cyclical Learning Rates</strong> → Helps escape sharp minima.</p><p><strong>57. Warm Restarts</strong> → Periodically reset LR.</p><p><strong>58. Annealing Schedules</strong> → Adjust regularisation over time.</p><p><strong>59. Monitor Validation Loss</strong> → Real-time overfitting alerts.</p><p><strong>60. Use LR Schedulers</strong> → Like cosine decay.</p><h3>Ensemble Methods (61–70)</h3><p><em>Ensembles reduce variance and prevent overfit.</em></p><p><strong>61. Bagging</strong> → Random samples + average.</p><p><strong>62. Boosting</strong> → Correct previous errors iteratively.</p><p><strong>63. Random Forest</strong> → Bagged decision trees.</p><p><strong>64. Model Averaging</strong> → Combine predictions.</p><p><strong>65. Dropout as Ensemble</strong> → Each dropout mask is a subnetwork.</p><p><strong>66. Stacking</strong> → Meta-learner on base models.</p><p><strong>67. Snapshot Ensembles</strong> → Save model states at intervals.</p><p><strong>68. Diverse Architectures</strong> → Heterogeneous ensemble.</p><p><strong>69. Cross-Validation Ensembles</strong> → Ensemble of folds.</p><p><strong>70. Bayesian Model Averaging</strong> → Weighted posterior.</p><h3>Optimisation and Loss Functions (71–80)</h3><p><em>The right loss can help avoid overfit.</em></p><p><strong>71. Use Robust Loss Functions</strong> → Huber &gt; MSE for outliers.</p><p><strong>72. Focal Loss</strong> → Focuses on hard examples.</p><p><strong>73. Contrastive Loss</strong> → For similarity learning.</p><p><strong>74. Triplet Loss</strong> → For embeddings.</p><p><strong>75. Cross-Entropy + Smoothing</strong> → Reduce overconfidence.</p><p><strong>76. Mixup Loss</strong> → Regularised blend.</p><p><strong>77. Adversarial Loss</strong> → For robustness.</p><p><strong>78. Regularised Loss</strong> → Add penalty terms directly.</p><p><strong>79. Temperature Scaling</strong> → Soften predictions.</p><p><strong>80. Use Proper Metrics</strong> → F1 &gt; Accuracy in imbalance.</p><h3>Architecture-Specific Techniques (81–90)</h3><p><em>Different models need different defenses.</em></p><p><strong>81. Residual Connections</strong> → Easier optimisation in deep nets.</p><p><strong>82. Attention Mechanisms</strong> → Focus on key info.</p><p><strong>83. Global Average Pooling</strong> → Replaces FC layers.</p><p><strong>84. Dilated Convolutions</strong> → Wider receptive field.</p><p><strong>85. Depthwise Separable Convs</strong> → Efficient CNNs.</p><p><strong>86. Recurrent Dropout</strong> → For RNNs.</p><p><strong>87. Zoneout</strong> → Dropout for RNN state.</p><p><strong>88. Gated Units (LSTM/GRU)</strong> → Smarter memory control.</p><p><strong>89. Pretrained Models</strong> → Fine-tune, don’t start from scratch.</p><p><strong>90. Transfer Learning</strong> → Leverage past training.</p><h3>Evaluation and Testing (91–99)</h3><p><em>Your test strategy affects what your model learns.</em></p><p><strong>91. Hold-Out Test Set</strong> → Final sanity check.</p><p><strong>92. Nested Cross-Validation</strong> → Prevents leakage.</p><p><strong>93. Out-of-Distribution Testing</strong> → Checks robustness.</p><p><strong>94. Adversarial Testing</strong> → Probe weaknesses.</p><p><strong>95. Monitor Learning Curves</strong> → Watch for divergence.</p><p><strong>96. Use Multiple Metrics</strong> → Accuracy isn’t enough.</p><p><strong>97. Bootstrap Validation</strong> → Estimate variability.</p><p><strong>98. Sensitivity Analysis</strong> → Test perturbations.</p><p><strong>99. Real-World Testing</strong> → Try it in production!</p><h3>Final Thoughts</h3><p>If you’re just starting out:</p><ul><li>Begin with <strong>cross-validation</strong>, <strong>L2 regularisation</strong>, and <strong>early stopping</strong>.</li><li>Watch your <strong>learning curves</strong> and track <strong>validation loss</strong>.</li></ul><p>Advanced? Try:</p><ul><li><strong>Mixup</strong>, <strong>Dropout</strong>, <strong>Spectral Norm</strong>, <strong>Ensembles</strong>, or <strong>Adversarial Training</strong>.</li></ul><p><strong>Save this checklist</strong>. Refer to it. Share it. Your future self (and your model performance) will thank you!</p><p><a href="https://drive.google.com/file/d/16IqwAay9sslhR3HY8eJvF5NpzOL1USA7/view?usp=sharing">Download the PDF Version!</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fe6bb5a726f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>