Latest / Agentic Conversations (formally mlops.community) / RecSys at Spotify // Sanket Gupta // #232
Transcript
- 0:00The higher the hi guys. I'm Sankey.
- 0:01I work as senior machine learning Engineer Spotify and
- 0:05yeah, when interesting coffee routine, So I love lattice.
- 0:08So I used to be hitting all these different coffee shops in
- 0:11New York City trying to find the best one.
- 0:13But then I'm like after Pandemic, I was like, this is
- 0:16just not convenient to do. So I got this coffee machine
- 0:20that I brew my own espresso, grind my own beans and pull the
- 0:24short and stuff. So it's it's a lot of fun.
- 0:27I've been learning a lot about, like espressos, and there's a
- 0:31lot of connoisseurs out there. But yeah, learning a lot on that
- 0:35fun stuff. Welcome back to the Emblems
- 0:38Community Podcast. I'm your host, Dimitrios, and
- 0:40today is a very special one for me because I am such a deep and
- 0:45dedicated Spotify user. We get to talk with Sankey all
- 0:48about the recommendation systems within Spotify and how they've
- 0:53built that out so that various teams can leverage the embedding
- 0:58store that they have. I was fascinated by the
- 1:01different problems and challenges he talked about,
- 1:04especially when it comes to evaluating and re ranking and
- 1:09what their system looks like. There was some cool takeaways
- 1:12that I had from here. He broke down what the
- 1:15difference is between the vector store and the feature store and
- 1:17what kind of requirements are on each of these.
- 1:20He also talked to me about how me as a person who is using
- 1:25Spotify has an identity or I have a vector number attached to
- 1:30me and how they're constantly updating that.
- 1:33And for him, one thing that is very important is how they can
- 1:37continuously update that and make sure that the embedding and
- 1:42the place that I live in vector space is the freshest and most U
- 1:48to date as possible without blowing up the system.
- 1:50Because you can imagine, he said on here, there's 600 million
- 1:54monthly active users on Spotify. If you're constantly fine tuning
- 1:58these embeddings and you are churning them out for each user,
- 2:04you really have to think about how much is too much.
- 2:08And so he broke down those problems.
- 2:10I had a wonderful time talking with my man Sankey, and it turns
- 2:15out that he's really into coffee like I am.
- 2:18Let's get into it. And if you haven't got your
- 2:21tickets to the conference, I would get it now because we're
- 2:23almost selling out. All right, man, let's start with
- 2:31this. You just told me a viciously hot
- 2:35take that I I cannot let go too far from my brain.
- 2:38Before we get started, Rexis or Rags, break that down.
- 2:43Why do you think that? Got it.
- 2:45OK, sure. Let's let's look at.
- 2:47We're going right into the system then.
- 2:50OK, right. So the reason I think
- 2:52recommender systems have a lot of parallels to Rags is because
- 2:57of this thing called vector database, right.
- 2:59And I mean, it's a fancy word that we are not talking about,
- 3:02but these so-called embeddings and nearest neighbour lookups
- 3:07have been around for a long time, actually, it's just not
- 3:10been applied to text and NLP now.
- 3:13But let me give an example, OK? And then we can see how it
- 3:17relates back to rags. Say you're listening to a song
- 3:19on Spotify and you want to know what are the 10 most similar
- 3:23songs to that one, right. So let's say it's Bad Habits by
- 3:26Ed Sheeran, right? So now you want to know what are
- 3:28the 10 songs closest to bad habits, right.
- 3:31So how a human might do it is the human might like, go into
- 3:36other songs in which Sheeran, it might, like, look at pop genre
- 3:39and do something like that, right.
- 3:40But how would you do that at scale, right?
- 3:42Like, we don't have human sitting, right?
- 3:45We have algorithms. So how would you do that then?
- 3:47That's where kind of vector databases come in, right?
- 3:50So we have a embedding for bad habits, or vector, whatever you
- 3:54want to call it, Vector or embedding, which is just a
- 3:56series of numbers, and we do. Appreciate the sorry, hold on
- 4:01with the embedding. This is what I've always been
- 4:03curious to know is it's off of a description of the song or it's
- 4:09off of like all of the metadata, like the tempo and if he's
- 4:13singing and falsetto and so it's very much things that are
- 4:18describing the song, or it's off of the actual song itself.
- 4:22It's a song itself mostly. Mostly.
- 4:24I mean there are other aspects to it, but mostly it's kind of
- 4:28like the spectrogram analysis of the song.
- 4:30So as you said, like the tempo, the Valance, the instrumental
- 4:33Ness, the pitch, like all of those kind of features.
- 4:37And then you add in kind of the collaborative aspect, which is
- 4:40like which people put the songs together in a playlist, right.
- 4:43So it's kind of like playlist Co occurrence.
- 4:45So it's a combination of those two things which kind of builds
- 4:48the embedding. It's a massive system we can get
- 4:50into, but the end output is an embedding, right?
- 4:53It's it's an embedding. O We've uniquely represent each
- 4:57track on Spotify with an embedding.
- 4:59So that embedding model is a black box for now, right?
- 5:02We can go dig into that, but. But it outputs and embedding,
- 5:04right? And then you load all of these
- 5:07embeddings in an index, right, which we now call vector
- 5:11database, right? And basically now what you do is
- 5:14you do nearest neighbour lookups on that embedding, you get back
- 5:18like 100 or 200 items back, right?
- 5:20That's candidate generation, right?
- 5:22And then you do ranking, right? And this is very similar to what
- 5:25ranks do, right? Like they do.
- 5:26They retrieve like different documents with metadata and so
- 5:30on. And then they might like rank
- 5:32them based on if it's a New York Times article, it's higher.
- 5:35Like, you know, like that's the kind of sending and we do with
- 5:37rags, right. And it's very similar here,
- 5:39right? Like you get back like these 200
- 5:41songs and you're like, OK, so which one are you likely to
- 5:46listen to next, right. And and so on.
- 5:48So like you kind of do this personalization and like user
- 5:50understanding thing, then you rank based on a model you get
- 5:54back those 10 songs basically. So that's kind of the approach
- 5:57at least the retrieval augmented aspect is very much similar.
- 6:01The only thing I guess missing between Rag and Rexis is the
- 6:04generative aspect, right? Like you don't generate back
- 6:07like a paragraph like explaining why say shivers is similar to
- 6:12bad habits, right. They're sung by the same artist.
- 6:14They're like, so we don't do that.
- 6:15Like you just get the output basically.
- 6:17So that's kind of I see how I see Rags and Rex is kind of
- 6:20together. But how about when you're
- 6:23evaluating the Rexus? That's a whole different kind of
- 6:27worms too. Or do you feel like there are
- 6:28parallels there, like if it's actually working, how you score
- 6:32that, how you get ground truth, what the golden data set is?
- 6:36Yeah, I think evals are a little bit same and different, right.
- 6:40And I think similarities are in the sense of all those ranking
- 6:43metrics like NDCG and MRR and like AUCOC depending on how you
- 6:49set up the problem, right. So those metrics are like
- 6:51classic like I mean all of ML uses that.
- 6:54The difference is I think lie in kind of how we do text matching.
- 6:57So I see in rags like they do matching of like exact texts and
- 7:02like tokens and like Blues score and rules and things like that
- 7:05over here like because we're not generating like we don't really
- 7:08go into that. So I think that's kind of the
- 7:09difference. Yeah, yeah, that makes sense.
- 7:13So you've been doing a lot of stuff at Spotify with
- 7:17recommender systems. You're working on a few
- 7:19different ones, but is it safe to say that all the new music
- 7:24that I've found recently on Spotify is in part because of
- 7:28the work that you've been do? Ohh, that's a I could take some
- 7:32of the credit, but not all right?
- 7:33Like, there's just so many teams working on it.
- 7:36So yeah, I think. I think it's a lot of amazing
- 7:39people on this problem. All kind of.
- 7:42Where's your special sauce? Are you working mainly on the
- 7:44platform? On the models?
- 7:46On the optimization. Yep, So I work as a Senior
- 7:50Machine Learning Engineer in personalization.
- 7:52So kind of my focus is has been quite a bit on user
- 7:56understanding. So like how do we actually
- 7:58understand users in a way that helps out everyone basically in
- 8:02the company like in terms of the models.
- 8:04So more on models, some like obviously doing a lot of mill
- 8:08OPS because otherwise you can't ship anything, right?
- 8:11And then evaluations. Also a lot of evaluations.
- 8:15Yeah, I imagine your playing with features, you're knee deep
- 8:20in features and that's probably your day in, day out.
- 8:24Yeah, for sure. Any features that surprised you
- 8:29that have a whole lot of weight you would have never expected?
- 8:33I think one of them is say, an account each, which is very
- 8:37interesting. So account age basically is like
- 8:39how old is is an user, right? And we have seen interesting
- 8:44patterns like you wouldn't expect like people who have been
- 8:46on Spotify longer have certain kinds of patterns than the new
- 8:50users, right? So there are very interesting
- 8:52patterns there. Is it because of the UI features
- 8:55that you feel like the account is different or the account age
- 9:01makes a difference when it comes to features?
- 9:03Yeah, that's a that's a fair, I mean see, so I'm just giving an
- 9:06example of one model, right. So there we have like dozens of
- 9:09models. So every model works
- 9:11differently, right. I mean, and so on.
- 9:13South features are unique to the models.
- 9:16But speaking to your cushion, like, I think some of the older
- 9:20users may have certain habits, right?
- 9:22Some of the newer users may be getting onboarded due to
- 9:24podcasts, for example. Some of the older users may have
- 9:27joined because of music. So they have certain kind of
- 9:30habits, which is ingrained and it's hard to change people's
- 9:33habits and so on. So there are those kind of
- 9:36correlations also, right? And we recently lost audio
- 9:39books, so that's another thing. So all of those things play a
- 9:43role, Yeah. Yeah, I've been loving the
- 9:45audiobooks, by the way. So there are some really
- 9:48interesting problems that you face though, right?
- 9:50Like one being cold start and how you can recommend something
- 9:54to somebody who is first joining Spotify, which feels a little
- 9:58bit like. That's probably the minority, I
- 10:00would imagine, because we've all used Spotify in one way, shape
- 10:04or form by now. I would assume, but potentially
- 10:08no. You have better ideas on that,
- 10:11and so how do you deal with the cold start problem?
- 10:14Yep. So cold start is a very
- 10:16important problem, right? And there are two main reasons
- 10:19why I think cold start is very difficult to solve in recess.
- 10:22I think listeners who are from ecommerce would relate with what
- 10:24I'm going to say, right? So one is that you don't have
- 10:27any history that makes intuitive sense, like you just don't know
- 10:30anything about the user, right. And the second less intuitive
- 10:34reason is because of how the systems are managed, right.
- 10:37So we have usually bad systems. So these systems kind of operate
- 10:41maybe they infer like once a day for all of users and they're
- 10:45running behind, right. Like we have like almost like
- 10:47600 million plus users now. So it takes a while for us to
- 10:51like churn through all of them. And there are so many
- 10:53dependencies and systems. So it can take like one or two
- 10:57days for systems to kind of actually catch up actually,
- 11:00right. So someone new joins in.
- 11:02We don't have anything about them that's bad, but you can't
- 11:05do much about it. But our systems ourselves as a
- 11:07person starts engaging are also slow, right?
- 11:10So we take about two or three days to respond to it, right?
- 11:13So there are both of these problems, which kind of make a
- 11:16massive difference in cold start.
- 11:19And So what do you do? Yep.
- 11:21So let's solve the second problem first, right.
- 11:24So which is because it's controllable by us is to do a
- 11:28more like near real time systems.
- 11:30So someone joins on Spotify, they start listening to
- 11:33something like say 80's rock, right.
- 11:35And then our systems are like in minutes they respond and they
- 11:39kind of create new user taste profiles and like these new
- 11:43embeddings for them. And then those embeddings can
- 11:46then be used across the company right by all the models.
- 11:49So that's kind of the systematic aspect which is like go from
- 11:53batch to near real time or real time, right?
- 11:56But then for the first problem, we have this thing called taste
- 11:59onboarding where you kind of select, I don't know if you
- 12:01remember the doing that, but you can select three artists or four
- 12:04artists and you sign up and then you can also select languages
- 12:08and so on. South, it's about kind of
- 12:10smartly using that information when it's available, right?
- 12:14So it's kind of a combination of both of these things.
- 12:18So then you have a bit more information about someone.
- 12:22You mentioned that there are a lot of models that you're
- 12:25playing with. I am understanding that as
- 12:29there's a lot of models in the whole recommender system.
- 12:33Yes, there are a lot of models in the recommender systems,
- 12:36right? So just an example, right?
- 12:38Like search would have their own model, right?
- 12:40And then the home is going to have a different model.
- 12:43We have models that do ads, which are different models.
- 12:46We have Discover Weekly which would be a different model would
- 12:50have like as I said like the what are the next 10 songs?
- 12:54That's more of a candidate generation thing.
- 12:56That's another thing. Then we have multiple systems
- 12:59and people. So it's it's a very like even as
- 13:02as a as a company like there are obviously going to be a lot of
- 13:05people, teams and dependencies. No talk to me about because this
- 13:11is just for my own scratch, my own itch.
- 13:13Yeah, when I say go to radio for any song, is that a new model
- 13:19also? It's going to be a different
- 13:20kind of teams managing that, but a lot of them actually tend to
- 13:24use the embeddings, right? So the team I was working on is
- 13:28building kind of embeddings, and most of the commonality between
- 13:32all of that is the embeddings. And that's what I call as
- 13:35foundational embeddings, which is the kind of the goal here is
- 13:39to not have every team do everything from scratch, right?
- 13:43Like the user is the same, so if it's Demetrius, like it's the
- 13:46same user, we don't want teams to interpret you differently
- 13:50across the whole stack, right? Like, we want teams to have a
- 13:53unified and a common understanding of you, right?
- 13:56So just just to give you an example, right, say you wake up
- 13:59in the morning and you listen to some music and then you jump
- 14:02onto a car, you might be listening to a podcast and then
- 14:04you hit the gym. You're going to be listening to
- 14:06some high energy music. So those are some of the
- 14:09patterns that can be used across, right?
- 14:11It's not just one team, right. So as a user, you want to
- 14:15experience unified and a common thing and these embeddings kind
- 14:19of help that. So there is this embedding layer
- 14:22in between which kind of branches out across all these
- 14:24models. OK, so it feels like the I'm
- 14:28getting the embeddings right. Yes, is one of the most
- 14:31important things. I I think so.
- 14:34I think that that play a massive role especially for candidate
- 14:38generation, right, because we were talking about vector
- 14:41databases, right? How would you?
- 14:43So we have 100 million plus items in our catalogue.
- 14:45How would you take an item and bring back 100 out of 100?
- 14:49Like that's a very, very tough problem for any model to do.
- 14:53So you need some kind of candidate generation, right.
- 14:56So that's basically the retrieval problem, and that
- 14:58typically is solved by embeddings.
- 15:00So one thing that does come up quite a bit even in RAG, is how
- 15:04you evaluate the retrieval. And So what are you doing to
- 15:08make sure that what you are retrieving is the best?
- 15:13Out of those 100 million, did you say 100 million songs or 100
- 15:16million songs? How many?
- 15:17100 million items, right? So it's a mix of podcast, music,
- 15:21audio, books, everything, right? That's a lot, right?
- 15:24That's a lot of item. Yeah, kind of.
- 15:27And that's why evaluations play such a major role.
- 15:30So personally, as an engineer, like, I have spent more time
- 15:33evaluating systems than even, like, building the model, right?
- 15:36Like, I take the evaluations very seriously and it's a very
- 15:40hard problem, right? It's, it's like sometimes you
- 15:42need models to evaluate a model definitely.
- 15:47So let me give an example. I think to answer your question,
- 15:49right. So you said how would you know
- 15:51those 10 songs are correct, right.
- 15:53So that's one model that got the 10 right.
- 15:55Now you need maybe say another model that is going to rank or
- 15:59or test that, right. So you're going to see out of
- 16:03the 10, which ones are you likely to play next or play in
- 16:06the next 4 hours or seven days or whatever.
- 16:09And we kind of take an intersection of what you would
- 16:13have actually what you have been listening with that one and then
- 16:16we kind of do intersections for that.
- 16:17So those are the kind of things we do to kind of evaluate some
- 16:20of the systems. Now you mentioned as an engineer
- 16:25you've spent more time working on evaluation then even building
- 16:30the models, right? What is your time working on the
- 16:35evaluation system look like when I'm?
- 16:37Talking about evaluations, I'm talking about evaluating
- 16:39embeddings. OK.
- 16:40So let me be clear there. Because there are teams that do
- 16:42classification models where the valuations are going to be not
- 16:45as difficult, right? So I mean, that's going to be
- 16:47classic precision, recall, whatever, right?
- 16:49As long as you've set up the labels correctly, you can get
- 16:52kind of pretty far with just the basic metrics.
- 16:56So I'm talking about these embeddings, right?
- 16:59And in the LLM land, those embeddings may be coming from
- 17:02say text embedding 3 large model from open air, whatever, where
- 17:05you arse in a text and you get back embedding.
- 17:07Right. So those are the embeddings I'm
- 17:08talking about. And these are very like they're
- 17:12very abstract, you can't look at it like no human can look at an
- 17:15embedding and say like OK, that's good or bad.
- 17:17So basically, right, Like you can't do it right?
- 17:20So now you need, yeah. Computer language.
- 17:22It's a computer. Language at least numbers and
- 17:24these numbers kind of have these non-linear relationships with
- 17:26each other, right. So in terms of evaluations we
- 17:30kind of break it down into more like sub facets, right.
- 17:34So one is intrinsic evaluations, right?
- 17:36So we take these embeddings in sitting in the vector space and
- 17:41we say like OK so we have a demo three of embedding right?
- 17:45Like what are the 50 users similar to Demetrios right.
- 17:49So we do the nearest neighbour lookup on that embedding.
- 17:52We get back like 50 users. So it may be say me 49 other
- 17:56people and then we have these some kind of heuristic system
- 17:59which is going to be like OK, Dimitrius likes podcasts, mostly
- 18:03podcasts and it's user in US as well.
- 18:06Have you been looking at my embedding?
- 18:08No. Just good.
- 18:09We can't. We can't really look at anyone.
- 18:11But I'm just too. Easy to understand I'm.
- 18:14Just guessing, just just a guess, but based on those
- 18:17heuristics and matching, we're able to then say, OK, I think we
- 18:20are embedding is not bad, right? It's able to catch like 30% of
- 18:24what we thought Demetrius is similar, users look like.
- 18:27So these are the kind of like intrinsic evils I'm talking
- 18:30about. Then we'd also do extrinsic
- 18:32evals, which would take the embeddings into other models.
- 18:35So you build these mock models, which kind of mock some aspect
- 18:40of Spotify, right. So as I talked about predicting
- 18:44future lessons, so you would actually what you would do is
- 18:47you take Dimitrios embedding and then you put it into a system
- 18:50and say like what would Dimitris listen to in the next seven
- 18:53days, right. So and then you kind of see the
- 18:56actual listening and you kind of do overlaps of that.
- 18:59So you're kind of like really figuring out if embedding is
- 19:01actually good, is even doing his job bright and like that.
- 19:05Like you build these basically mock downstream models and you
- 19:10try to like evaluate these embeddings by passing through
- 19:13those models. So you make you convert
- 19:15evaluating embeddings into a classification problem.
- 19:18Essentially, yeah, it's kind of what.
- 19:20I'm saying, so you're trying to predict and you don't actually
- 19:23do anything. You're just putting that side by
- 19:26side with my real actions and you're seeing how well you were
- 19:30able to predict that. Yep.
- 19:33If that makes sense, right? Because embedding itself, you
- 19:35can't. As I said, it's hard, right?
- 19:36But then you can feed it into these systems, right?
- 19:40And these systems are now classification or regression
- 19:42systems, which we know from all our love with classical mill,
- 19:46right. Like those are they're classic
- 19:49techniques. You can easily evaluate them
- 19:51through Roc, precision, recall curves and so on.
- 19:54And then you when you feed them into, you can evaluate the
- 19:57downstream systems. So you're not evaluating the
- 19:59embeddings yet, you just evaluating the downstream
- 20:01systems and if they improve, you can basically like say
- 20:06embeddings are doing better. So it's a two stage process,
- 20:10which is what makes it an incredible problem, right?
- 20:13And and it's very hard to like tell people like, OK, so you're
- 20:17now like building embeddings and you have to evaluate with these
- 20:19like mock models which are there.
- 20:21So yeah, there's a lot of kind of lot going on there.
- 20:25And how are you able to test this stuff out easily?
- 20:30It feels like there's a lot of infrastructure in place to be
- 20:33able to support that O we. Have internal platform teams
- 20:37that kind of help with a number of things.
- 20:40And yeah, so it's a whole stack of distributed systems like
- 20:45cloud data flow, big table, we use queue flow.
- 20:49So all of those kind of things kind of play a role there.
- 20:52So a lot of the engineers time obviously is also not just in
- 20:54coming up with an idea, but also productizing it in their
- 20:58systems. Was it?
- 21:00Didn't one of these pipeline tools come out of Spotify way
- 21:05back when? Was it Luigi or something?
- 21:08Is that still in use? Yep.
- 21:10My team actually used it, But yeah, I know a lot of teams are
- 21:13now maybe moving to more modern tools, but yeah, Luigi is love
- 21:17Luigi, yeah. Really.
- 21:19Ohh, that's awesome. Ohh, that's great.
- 21:22And so it does feel like there are other ways to do this.
- 21:28What are different approaches if you don't use this?
- 21:30And correct me if I'm wrong, the style that you would call this
- 21:35is like transfer learning. Yeah.
- 21:38So the transfer learning exactly.
- 21:40Again, let me take an analogy of LLM.
- 21:42So I think that will help here. So Open Air comes up with a new
- 21:46embedding model, right? And then they create these
- 21:48foundational embeddings. But then you work in a finance
- 21:51company or say like you are in a law firm and you are analysing
- 21:55like a lot of these law techs or like tax, tax docs or whatever.
- 22:01So you might want to fine tune them on your data, right?
- 22:04So that's basically transfer learning, right?
- 22:06So you're kind of tuning the underlying model, you're not
- 22:08changing it. And that's kind of the same
- 22:10approach we take here where we build kind of these foundational
- 22:13embeddings. So our team would build like
- 22:15these representation learning based models to build embeddings
- 22:18and then all of the downstream teams would on their own task
- 22:22like tune them. Essentially what you were
- 22:26talking about, personalised DJ. Like they would maybe take the
- 22:28embedding and then they would tune it in the voice arena,
- 22:32voice setting like what works, what doesn't work?
- 22:35Search team would then instead look at like search features.
- 22:38So what are you likely to search?
- 22:40And they would still use the same embedding, they're just
- 22:41tuning it in their own models basically.
- 22:44That's kind of the approach of transfer learning.
- 22:46Are there ways that you think this could also work at Spotify
- 22:50without using transfer learning? Everything has an alternate,
- 22:54right? Like something used to be done,
- 22:56right. So now like, yeah, so the
- 22:59alternate is don't use embeddings, just kind of build
- 23:01everything from scratch, right? So we look at last end days of
- 23:05history of a user, we look at what devices the user uses, the
- 23:08country, the listening like. So you every team starts to do
- 23:12everything from scratch and you don't use any embeddings, you
- 23:16don't fine tune anything. So again, analogy to ALMS is the
- 23:20financial company builds their own LLM from scratch like they
- 23:24don't touch open a I, they don't touch LAMP or whatever, they
- 23:26just build the whole encoder, decoder transformer like it's
- 23:30possible, right? Like it's not impossible, I
- 23:32mean, you can still do it, but the amount of difficulty you
- 23:35might need to put in like 50 engineers for like 6 months to
- 23:38build that, right? So.
- 23:40Expensive. Yeah, it's.
- 23:41Expensive, right? And GPU costs and so on.
- 23:43So you just use someone else's learning and you transfer it to
- 23:47your own task, right? That's kind of the where the lot
- 23:50of the secret sauce and magic happens.
- 23:52So you're. Constantly updating me as a user
- 23:55in the embedding database or the vector database?
- 23:59And where do features come in? Yes.
- 24:03So it features come in during inference, right?
- 24:06So we train the model right and and say I'm like, OK, Dimitrios
- 24:11has started listening to Jazz and I want to update me too.
- 24:15Well man, what is going well, that's.
- 24:16Great. OK.
- 24:18I have a look at your no Evans. And I am stoked on a Saturday
- 24:22afternoon. My wow, my day is made.
- 24:27Anyways, I started listening to jazz.
- 24:28Yes, and. Our system is going to be like,
- 24:31OK, let's trigger an inference for Dimitrios, right?
- 24:34And when you trigger an inference, you're going to be
- 24:36like, OK, let's build the feature set for Dimitras, right.
- 24:39So then those features may be, say, demographics.
- 24:42They may be like what what have you been listening in the last
- 24:45six months? What have you been listening
- 24:47over the last 28 days? What have you been listening in
- 24:50the last week? So you have these different time
- 24:51frames and jazz kind of comes in into the mix basically, right?
- 24:56Right. So then you update the
- 24:58representation. So you're not like moving that
- 25:01embedding extreme like we just, we just forget everything you've
- 25:05heard in the last six months and we just make it like a jazz
- 25:07thing. But we just want to like dilute
- 25:10it a little bit. We're like, OK, let's just take
- 25:12like Dimitrios is like pop and rock taste and just put in a
- 25:18tinge of jazz onto it, right. And if Dimitri starts enjoying
- 25:22jazz quite a bit, like we will expand jazz in that taste and
- 25:25we'll remove some other things, right.
- 25:27So that's kind of how it continues to update, yeah.
- 25:30And do you have a weight on what I'm listening to right now
- 25:37versus what I listen to six months ago or six years ago?
- 25:41Because I've been on Spotify for a while, right.
- 25:42So how can you balance all of that music?
- 25:45I know there are sometimes that I'll see on the UI, something
- 25:49will pop up and it'll say like you and all the classic or
- 25:54something. I can't remember the exact
- 25:56words, but it's kind of like you used to like this.
- 25:59Do you still like it? Kind of thing and you want to
- 26:01jump back in and listen to it? No, that's a good.
- 26:04So I mean those those are against some teams that maybe
- 26:07like looking at raw data and and doing that right.
- 26:10But for in terms of like the taste profile and embeddings, we
- 26:14do have certain factors where we take some of the time, but we
- 26:17let them mostly we let the models decide it, right.
- 26:21So if you kind of are being very active when listening to
- 26:25something from five years back like our model will be that
- 26:28higher automatically, right. Otherwise we're going to be by
- 26:31default. We are weighing the recent more
- 26:33than not, basically. All right, real quick, let's
- 26:36talk for a minute about our sponsors of this episode, Making
- 26:39it All happen. Lattice flow AI.
- 26:42Are you grappling with stagnant model performance?
- 26:45Gartner reveals a staggering statistic that 85% of models
- 26:49never make it into production. Why?
- 26:50Well, reasons can include more data quality, labelling issues,
- 26:55overfitting, underfitting and more.
- 26:57But the real challenge lies in uncovering blind spots that lurk
- 27:01around until models hit production.
- 27:04Even with an impressive aggregate performance of 90%,
- 27:07models can plateau. Sadly, many companies optimise
- 27:11for prioritising model performance for perfect
- 27:15scenarios while leaving safety as an afterthought.
- 27:19Introducing Lattice Flow AI The pioneer in delivering robust and
- 27:24reliable AI models at scale. They are here to help you
- 27:28mitigate these risks head on during the AI development stage,
- 27:31preventing any unwanted surprises in the real world.
- 27:35Their platform empowers your data scientists and ML engineers
- 27:38to systematically pinpoint and rectify data and model errors,
- 27:43enhancing predictive performance at scale.
- 27:46With Lattice Flow AI, you can accelerate time to production
- 27:49with a reliable and trustworthy models at scale.
- 27:52Don't let your model stall. Visit Lattice Flow Dot AI and
- 27:58book a call with the folks over there right now.
- 28:01Let them know you heard about it from the M OPS Community
- 28:04Podcast. Let's get back into the show.
- 28:07One thing that is fascinating though is thinking about those
- 28:12people that are like me and you mentioned there's over 100
- 28:16million different items. Does that include people?
- 28:20Cause I would imagine people are there's you said there's 600
- 28:24million users of the app the six. 100 million MAU's
- 28:29worldwide, yeah. So yeah, I I'm just wondering
- 28:33like there's gotta be a tonne of people that are very much like
- 28:36me. I think I'm a special snowflake,
- 28:38but if I look in your vector database, I'm gonna find whole
- 28:42lot of people That's. The beauty of embedding, saying
- 28:44like everyone is a snowflake, right?
- 28:45No one person is going to get the same embedding.
- 28:48So that that's kind of so special, right?
- 28:51Yeah, yeah. That is very true.
- 28:53And so then as you're looking at these different embeddings and
- 28:59you're looking at ways to make it better in the future, what
- 29:02are things that you're focusing on?
- 29:05Yep, few things, right? One is definitely feature
- 29:08spaces. So like, how do we better
- 29:11represent a user, right. So you could.
- 29:14So for now, we have been focusing a lot on the music
- 29:16side, right? So we have a musical embedding
- 29:18and then we have podcast embedding and so on.
- 29:20But you can imagine like across content kind of embedding where
- 29:24you take Dimitrios's podcast listens along with music.
- 29:28So you may be listening to jazz on a day when you listen to say
- 29:32like a history of music, podcast, whatever, right?
- 29:36So there may be some correlations there which are
- 29:38actually very difficult to find algorithmically.
- 29:41So to do that, like we need to combine your podcast music and
- 29:45all of that taste together and pack it together.
- 29:48That's definitely like 1 aspect of improvement.
- 29:51Another one is how fast we respond.
- 29:54So you listen to something and we like bank like we respond
- 29:58immediately and all of your Spotify is updating tragically
- 30:02after that. So I think these two itself,
- 30:03these two, the two things I mentioned is itself a very tough
- 30:07problem and and it takes I think I would say several months or
- 30:10even years. Yeah, how hard is it to shift
- 30:15from the batch? Like you said, it was like a one
- 30:18to two day batch type recommendation cycle to going to
- 30:24that end cycle. Yep.
- 30:27Fascinating fascinating thing, right?
- 30:30The way I see it is that there is a Goldilocks zone with how
- 30:35often you infer, right? So I call it Goldilocks zone
- 30:38basically, right. So like, I think a lot of people
- 30:40think it's either batch or real time, right?
- 30:42But actually I think there may be something in the middle which
- 30:45is near real time. So by near real time it
- 30:48basically means that you don't need to infer for Dimitrius when
- 30:52you start listening to jazz and like 30 milliseconds, right?
- 30:55Like we don't like your Spotify list.
- 30:58You're not like dramatically switch in like less than a
- 31:01second, right? That's that's unlikely, right.
- 31:03So you instead you can put that jazz listen in a queue along
- 31:09with some other people and as a systems like process that so it
- 31:12can take a few minutes, but one or two minutes is acceptable
- 31:18latency there, right. So that's kind of what I say
- 31:20Goldilocks is. It's a good trade off between
- 31:24like being responsive but at the same time like you're not
- 31:27blowing up. Otherwise like just engineering
- 31:30systems have to like scale up to like massive skills and then
- 31:36your whole on call burdens you need to put in like I don't know
- 31:39how many shares and like do like all kinds of stuff to make that
- 31:43a reality right. So that's kind of the dream is
- 31:47to train as less as possible but infer as much as possible, but
- 31:53not in real time. That's kind of how I see this
- 31:56thing play out. O if I understand it correctly
- 31:59too, it's that every time you want to update, so the closer
- 32:04you get to real time or near real time, That means that you
- 32:09have to create new embeddings each time.
- 32:14Yep. And let me just give a little
- 32:17bit, just to break this in advance a little bit, right.
- 32:19OK. So our systems are faster.
- 32:22They're still like like the serving is all real time serving
- 32:26cannot be like you can't wait around 2 minutes to get back the
- 32:3010 lessons, right, like what I said.
- 32:31So it all has to be in 30 milliseconds, right.
- 32:34So I mean, I just want to be clear there, right.
- 32:36So that's kind of the final layer.
- 32:38But the question is that that online store, that feature store
- 32:42that is online that is serving those recommendations, how fast
- 32:46is that being updated? So you have, you have like we
- 32:50understand Dimitrios with that understanding maybe of three
- 32:53days back, right. So whatever you were doing on
- 32:56Spotify three days back is what our understanding is at this
- 32:59moment. That's what I see.
- 33:00That's still, it's still being sold very fast, like we still
- 33:03are serving that at 30 milliseconds, but it's still
- 33:06serving things that we know about Dimitrius 3 days back,
- 33:09right. So that is a batch features in
- 33:12online store, that's what I mean by that, right?
- 33:14It's still batch systems because you're understanding is behind,
- 33:17but you're still in online. The question is to move your
- 33:20understanding your features as much as closer to real time as
- 33:25possible, right. So it's you want to move it to a
- 33:28level where it's like a few minutes lagging features serving
- 33:32in 50 milliseconds. So near real time inference
- 33:35served with real time systems, if that makes kind of sense
- 33:38basically. It's very clear now, 100%.
- 33:42So you have and understanding of mine that's three days old and
- 33:49so whatever, I really like that. That put it into perspective,
- 33:52because now I see that, OK, whatever I do today, it's going
- 33:57to be reflected on my Spotify recommendations in three days.
- 34:02Yes. And so one other thing that I
- 34:06was thinking about is that the vector database that you have,
- 34:11is it just one gigantic database that everything goes into
- 34:14because you were saying that you want to be able to have any
- 34:17team, any ML team, any recommendation team lay off of
- 34:22it or is it a bunch of different ones depending on the location
- 34:26or whatever it is? Like how's the system look, I
- 34:28mean. We we leverage a lot of big
- 34:30table which is essentially a Google cloud product, amazing
- 34:34product. And we have like multiple
- 34:37different vector databases for like different purposes.
- 34:40But for say like tracks, that would be like 1 vector database
- 34:45because we want to keep all of that 100 million items or
- 34:48whatever that may be, right? Whatever we want to surface like
- 34:51in one vector database and then we do nearest neighbour lookups
- 34:53on that essentially. OK.
- 34:57And then you know which ones to go for depending on what the use
- 35:01case is. Exactly.
- 35:03Yeah. So that's kind of and we have to
- 35:05scale it quite as you can imagine like all of the auto
- 35:07scaling and it's a very, very complex system like just to get
- 35:11that to function like so that you see no difference basically
- 35:16as a user you see no perceive nothing is what our goal is and
- 35:19that takes tremendous amount of effort.
- 35:22So I do want to shout out to all the all my team members in that
- 35:25regard, yes. Shout out yes so correct me
- 35:29where I'm wrong. I'm going to try and break down
- 35:31the cycle here and you tell me where I'm not understanding it.
- 35:36I go on to Spotify, I play my Bill Evans and Chet Baker jazz
- 35:43playlist that I absolutely love. This is the first time that I'm
- 35:47playing it on Spotify. I haven't played it on Spotify
- 35:51because I didn't realise it was on there and I've always been
- 35:53playing it on YouTube, but now I play it and it's like ohh new
- 35:57information about Demetrius. That information gets taken and
- 36:03it gets put into an embedding model to update my embedding.
- 36:09And so you're you're constantly gathering information about me
- 36:13and if there's new things or whatever the information is,
- 36:16you're just adding a little bit to my embedding, which is my
- 36:19your understanding of me as a user.
- 36:22And once that embedding is there, then it goes and it's
- 36:26able to feed that information and that description to the
- 36:34online feature store and be able to serve everything very
- 36:40quickly. So that in a few days after I
- 36:43listen to my Bill Evans playlist I now am starting to see more
- 36:48cool great live Bill Evans tracks that I had never heard
- 36:53and it's coming U maybe on my if I'm just sometimes I'll let the
- 36:57Spotify just play and it will come up with random songs and so
- 37:01it'll be spiced in there and then I give it a like and now
- 37:05there's like more signals that ohh actually he's really getting
- 37:08into jazz and it gets reincorporated in.
- 37:11Where I think I'm losing or I'm not so clear on is how does the
- 37:17embedding and the vector store go to the feature store and like
- 37:26that pipeline or that route, what does it take and how does
- 37:29that look? So you said like you listen to
- 37:32that playlist that you had heard on YouTube and then you'll come
- 37:35on Spotify and listen. So our goal is to not take those
- 37:38five days or three or whatever the end days to respond.
- 37:41We want to respond ASAP, right. I think we are clear on that,
- 37:44right. So that's kind of the goal of
- 37:46this new model is like we update like ASAP, right?
- 37:49Or rather I should not say ASAP, like to be technically correct
- 37:52like few minutes. So we want to respond in a few
- 37:54minutes. Now your question was how does
- 37:58vector database and features stores kind of connect with each
- 38:01other? So it's actually like it's very
- 38:05simple, like it's kind of one and the same when you're talking
- 38:08in the online setting, right? Because a lot of the times teams
- 38:13don't care about embeddings. Great teams want to know the so
- 38:19the in a rack system like like a, a person will not care about
- 38:23what the embedding is, right? They want to know the documents,
- 38:26right? What are the nearest documents.
- 38:28Same thing applies here, right? Like teams don't like, they
- 38:32don't personally care what the embedding value is.
- 38:34So they call the vector database, which you can say is
- 38:38like an online feature store because they just calling that
- 38:40and then getting back those documents or tracks basically,
- 38:43right? So they don't really care as
- 38:47much about the raw embeddings when we're talking about these
- 38:52candidates generation cases. Now there is a second use case
- 38:55which is aligned to more what you are saying is say a team is
- 38:59doing ranking right and another ranking is where like you might
- 39:03feed in demographics and like are you a podcast listener there
- 39:08they fetch the raw embedding from our vector database.
- 39:11So that's why I'm like mixing the words so that it's in
- 39:16candidate generation, it's vector database in a ranking
- 39:19setting, it's a feature store. They're one in the same thing.
- 39:21I mean if that makes sense more. Interesting.
- 39:23Yeah. I mean, it's a.
- 39:25Little, little nuanced, right? But because ranking team is
- 39:29building their own models there, they care about the real values
- 39:33of embedding. Yeah, they want the real value
- 39:35of the embedding. Dimitrius is like whatever like
- 39:38128 or 256 dimensional embedding and that goes into their model
- 39:43which would then infer, OK right.
- 39:44Like I think when you search for queue is it like queen or is it
- 39:48like some other other artist? Right.
- 39:50Yeah, so. They're like in that search
- 39:53model, like your raw embedding matters.
- 39:57But when we're talking about the bad habits and shivers example
- 40:01like they're the wrong bedding does not matter.
- 40:03You just want those 200 candidates or 200 tracks back,
- 40:07right? That's where that's a more
- 40:08vector database analogy. And in the ranking it's a more
- 40:12online feature store analogy. I don't know if that helps.
- 40:15Yeah, I like it. It separates it very much
- 40:18because I was under the impression that it would be
- 40:20like, OK, cool vector database now goes to the feature store or
- 40:24the embedding now goes to the feature store.
- 40:26But it's more like, no. The feature store is kind of
- 40:29doing what the vector database does, and so it there's a little
- 40:35bit of overlap there and you still need the embedding, but
- 40:39it's not like you need the embedding when you're doing the
- 40:44different use cases. And So what I think about then
- 40:47is feature stores are very much known for being this power U
- 40:53when you need like real time, right?
- 40:56And when you're doing that very very fast inference, does your
- 41:00use cases with these embeddings and trying to get the embeddings
- 41:05out and the candidate generation like do you have, how do you
- 41:11make sure that that is fast on inference?
- 41:14Because is that still like you're still having to go up
- 41:17against whatever 50 milliseconds inference time, right?
- 41:19Yep. So we keep everything in these
- 41:22fast online stores, which are super fast, 50 milliseconds,
- 41:25right? And we update them in the back
- 41:28end. That can be one day, 2 day,
- 41:31three day or that can be a few minutes, right?
- 41:33So, but we still need some notion of Dimitrios in that
- 41:38online store so that the search model can call that in 50
- 41:41milliseconds essentially. Right.
- 41:43Are they getting the best version of Demitrius?
- 41:45They can, maybe not, right. They are still getting a couple
- 41:48of days behind, but in many majority of cases that's fine,
- 41:51right? Even 2 days behind is not such a
- 41:53bad, you know, like it's fine like for maybe 90% of the
- 41:56systems, they don't really care, right?
- 41:59Like they're like, Oh yeah, queue wouldn't mean queen for
- 42:01Dimitrios and not like some other artist starting with you.
- 42:04Like that thing to be honest is going to be very similar for
- 42:07you, right? Like but for another team say
- 42:10that is building out the home shelves.
- 42:13They really care about up to date because if you started
- 42:15listening to jazz, you better want to see jazz there.
- 42:18Yeah, Do you want to see? Jazz like right up on the home
- 42:20screen and that team cares about it being updated fast.
- 42:23So it's really is is again very nice, like which team, what is
- 42:27the use case and how fast they want to be updated these
- 42:31embeddings. And so the next step on this
- 42:34journey feels very much like, how are you informed at how your
- 42:40product is going to be used within the Spotify app?
- 42:43Because it feels like the whole way you go about creating the
- 42:49product would change depending on where you're gonna sit within
- 42:54the app. Exactly.
- 42:55It's like so many different use cases and complexities.
- 42:59I think that's where the we're talking about evaluations,
- 43:01right? When you want to make a
- 43:03generalised foundational embedding, you have to cover so
- 43:06many cases. How do you even evaluate that?
- 43:09We can't predict how is it going to be used, right?
- 43:13So that's why, as I said, evaluating these systems
- 43:16sometimes is harder than even building them, right, because
- 43:21not everyone can. I said you can just fine tune,
- 43:23but not everyone can fine tune. Not all teams have the capacity
- 43:27or ability or desire to fine tune.
- 43:30They're like, I'm just going to use your product.
- 43:32If it's good, we'll use it, otherwise not.
- 43:34Now you really have to step up and build embeddings that can do
- 43:38something for everyone, right? And and that's where like doing
- 43:42something for everyone in Mill you know like how difficult that
- 43:45is essentially because. It's exactly like it wasn't hard
- 43:49enough already, yes. She's got.
- 43:52Three teams that you're servicing and they all want you
- 43:55to go in different directions, yes.
- 43:58What are some of these different polls?
- 44:00So I guess the way that it works within Spotify on the
- 44:03organisational level is that you're creating this product and
- 44:07then the UI or UX teams come to you or do you have UI UX people
- 44:14embedded in your team to help you and guide you with how it
- 44:18would be used? And I would imagine also the
- 44:20product managers are helping along the I don't.
- 44:23Personally work with UUX as much because a lot of these systems
- 44:29are ML. Systems create candidates that
- 44:32can basically be a black box. So for a UI, UX person is going
- 44:36to be like, OK, we will get 10 tracks.
- 44:40How are they created? We don't care, right?
- 44:43That's that's like all of this ML that we talked about in this
- 44:46show, right? Yeah.
- 44:46So for for the UI UX person, it's again a black box.
- 44:49They don't technically need to care about it.
- 44:52They only care about, OK, once we know the 10 tracks, how is
- 44:55the best layout? Do we allow Demitrius to skip
- 44:58past it? Do we allow Dimitrios to swipe
- 45:01up and add to playlist? So there's a lot of those like
- 45:03UI UX elements that you actually interact with.
- 45:06But the way we play a role in that is through feature
- 45:09collection, right? So sometimes we as ML
- 45:12practitioners, we want to know if Dimitrios is skipping past
- 45:17some of those things and radio or not.
- 45:19And that is something we want to get logged and things and then
- 45:22we use those logs in our models. That's kind of where I see the
- 45:25loop. So it's going more from the UI,
- 45:27UX to Mill rather than the other way, if that makes sense.
- 45:32So it's all features, it's all kind of interconnected.
- 45:36Wow, so I'm trying to figure out where where to go next because
- 45:40this is so cool to think about. How?
- 45:43You're basically just saying, hey, here's here's what you get,
- 45:47if it's valid, take it, go have fun, plug it into the A, and if
- 45:53not, maybe request something else or it's probably not for
- 45:58you, go ask another team. Some something like that.
- 46:02I mean, it's more nuanced, but yeah, something like that, yeah.
- 46:05OK. And it does feel like there are
- 46:10constantly new features that are coming U that you could
- 46:14potentially want to track. Like I know that there is the
- 46:20playlist where you can kind of tune into a playlist by swiping
- 46:25through it. And Justice hearing 30 seconds
- 46:28of a song, how do you, how do you stay up to date with.
- 46:31All right, there's this new feature that's going to be
- 46:34rolled out across the app now. You can incorporate this into
- 46:37your fine tuning methods. Yeah, fantastic question.
- 46:41Yeah, we have some amazing data engineers and data scientists.
- 46:44So we typically start this process at data science level,
- 46:47right. So we so instead of
- 46:49incorporating a new fancy feature like right away because
- 46:52you know how difficult productization is, right, we
- 46:55first, I mean the way that at least my philosophy personally
- 46:58is to 1st use those features in evaluations.
- 47:01What you could do is say a fancy new audiobook thing is coming
- 47:05out, you could just use that feature to build a cohort,
- 47:09right? So you would say, OK, we have
- 47:11been evaluating embeddings on podcast listeners, music
- 47:14listeners, how about audiobook? And we use kind of those
- 47:16audiobook features in that evaluation.
- 47:19And if we gain confidence in these kind of notebook
- 47:23environments and with analytics and AB testing kind of
- 47:26situations, then you know, OK, this feature is not bad.
- 47:29You know this feature is pretty good and it's helping us.
- 47:33If it's helping us move our metrics in the evaluation land,
- 47:37maybe it will help our model we bring it back, right.
- 47:40So it's we do will not like typically jump onto anything new
- 47:45and fancy unless it's really, really cool.
- 47:48So that's kind of how I see it kind of play out like, yeah.
- 47:52And are the main metrics you're looking at right now what you
- 47:55were talking about with speed and relevance?
- 47:59Yep. Relevance is definitely one of
- 48:01them. So it would be like essentially
- 48:05like things like relevance, accuracy, like all those things
- 48:10but also like we have this ranking metrics right.
- 48:13So in like imagine like you have a, you have home like where
- 48:17there are like multiple shelves. This is a ranking problem,
- 48:20right? Where like which one are you
- 48:22clicking or which one are you engaging with, right?
- 48:24So that's where like things like Mr and NDCG come into play.
- 48:32But yeah, you could say like this, that's some form of
- 48:34relevance. That's a more of a ranking
- 48:36relevance, yeah. Yeah.
- 48:39And and that's also where that, like that twin or that
- 48:43prediction simulation comes in, where you get to say, let's see
- 48:47if we do this or if we show these or whatever, Let's pretend
- 48:51like we're going to simulate out what Dimitri is going to do for
- 48:54the next three days, 5 days. And.
- 48:57And then I throw you a curveball and I listen to Gregorian chants
- 49:00and you go, whoa, I was not expecting that from this guy.
- 49:04Yes. Exactly, exactly.
- 49:07But but some of our discovery teams will be very happy, right?
- 49:10They will be like, OK, this is discovered something new like
- 49:14can we update Discover Weekly now?
- 49:16Because Discover Weekly like follows you, but then they want
- 49:18to give you something you've never heard before, right?
- 49:21So they really like, they love it.
- 49:23OK, now you have heard this something new genre like let's
- 49:25pick on that and start showing you so, but some other team is
- 49:30going to be unhappy, some other like.
- 49:31So it's, you know, it's kind of how like all these different
- 49:33systems interplay and work together to kind of satisfy the
- 49:38user basically. Man, it's been awesome talking
- 49:42to you. I really appreciate how
- 49:43transparent you are in all of this stuff that you're working
- 49:46on. It sounds like a really hairy
- 49:48question when it comes to evaluating this.
- 49:51Keeping it fast, but also making sure that what you're getting is
- 49:57up to date and it is interesting for the user is very fun.
- 50:03Yep. Absolutely.
- 50:04Fun stuff. Right on, man.
- 50:06Well, this has been a pleasure. Thanks for coming on here.
- 50:09Thank you SO. Much for inviting me pleasure.