No history yet

Candidate Retrieval Scalability

Transcript

Beau

Okay, Jo, I've been thinking about this. We've gone through all these incredible models—you know, the Two-Tower architectures, the deep learning stuff, even using Transformers to predict what someone might want next. It all makes sense in theory. But... how does it actually work in practice? When I open a streaming app, there's no way it's running a complex neural network on its entire catalog of millions of movies just for me, in real time. Is it? That would take ages.

Jo

You've just hit on the single biggest engineering challenge of production recommenders. And you're exactly right—it doesn't. Scoring the whole catalog is computationally impossible for a live request. That's why real-world systems use what's called a multi-stage architecture, or a funnel.

Beau

A funnel? Like for marketing?

Jo

Sort of, but for data. Think of it like this: Stage one is 'Retrieval' or 'Candidate Generation.' Its only job is to be incredibly fast and to cast a wide net. Instead of looking at millions of items, it finds a few hundred, maybe a thousand, potentially relevant candidates. It's optimizing for recall—making sure we don't miss anything good.

Beau

Okay, so it's like a bouncer at a club who just checks for a pulse to let people in. Not super selective, just getting a crowd inside.

Jo

Exactly. Then, Stage two is 'Ranking.' This is where we can afford to use our heavy, complex models—the deep learning ones—because we're only scoring that small set of a few hundred candidates, not the full million. The ranking stage is all about precision, sorting that short list to put the absolute best recommendations right at the top.

Beau

That makes so much sense. So the magic isn't just one smart model, it's a... a dumb, fast model followed by a smart, slow one. But how does that first stage, the retrieval, work so fast? If you have millions of items, how do you find the closest few hundred in, like, milliseconds?

Jo

This is where we use something called Approximate Nearest Neighbor, or ANN, search. Remember from the Two-Tower models how we end up with a vector, an embedding, for every user and every item?

Beau

Yeah, a big list of numbers that represents their 'taste' or 'essence' in some high-dimensional space.

Jo

Perfect. So at retrieval time, we have the user's vector. The goal is to find the item vectors that are 'closest' to it in that space. The brute-force way is to calculate the distance to every single item vector. That's slow. ANN algorithms create a kind of... clever map of the vector space beforehand. It's like a data structure that groups similar vectors together.

Beau

Like a... a zip code system for vectors?

Jo

That's a great analogy. Instead of checking every address in the country, you just go to the right zip code and search there. An algorithm like HNSW, which stands for Hierarchical Navigable Small World, builds multiple layers of these connections, like a highway system on top of local roads. It allows you to quickly navigate to the right neighborhood of vectors without visiting every single one. That's how you get sub-10-millisecond lookups on a billion items.

Beau

And the 'Approximate' part means it might not find the *absolute* single closest vector, but it's guaranteed to find ones that are extremely close, which is good enough for a candidate set. Right?

Jo

Precisely. It's a trade-off. You sacrifice a tiny bit of accuracy for a massive gain in speed. And since we're optimizing for recall here, getting 99 of the top 100 closest items is a huge win. The ranking stage will figure out the rest. This whole process is often framed as a Maximum Inner Product Search, or MIPS, because that dot product similarity is what we're trying to maximize.

Beau

Okay, that clears up a lot. But what about the cold-start problem? A brand new item, say a new movie just added to the catalog, has no user interactions. It has no history. So its vector is... I don't know, a blank slate? How does it ever get retrieved and shown to anyone?

Jo

That's a classic and critical problem. You're right, an ID-based collaborative filtering approach would completely fail here. The solution is to create the item's initial vector not from interactions, but from its content. We use item-side features. For a movie, that's the genre, actors, director, plot summary... maybe even the movie poster's visual features.

Beau

Ah, so you use something like those LLMs we talked about to read the plot summary and turn it into a semantic vector. That vector gets placed into the ANN index, and now it's located near other movies with similar plots, even before a single person has watched it.

Jo

Exactly. So if a user's vector is in the 'dystopian sci-fi' neighborhood of the vector space, our new movie will get picked up by the retrieval stage because its content-based vector is already in that same neighborhood. It’s a hybrid approach. The system uses multiple retrieval strategies, or 'candidate generators,' and then merges the results. One generator for collaborative filtering, one for content-based, maybe another for trending items.

Beau

So it's like asking multiple experts for their opinion. One expert knows what you like, another knows what's new and similar, and a third knows what's popular right now. You take all their suggestions and then decide. One last thing... what if my taste changes in the moment? If I just watched three action movies in a row, does the system know to look for more action movies *right now*?

Jo

It can, and that's done through something called query-time feature injection. Instead of just using your pre-computed, long-term user vector, the system can augment it with very recent signals. It might take the average of the vectors for those three action movies you just watched and nudge your user vector in that direction before it does the ANN search. This gives you recommendations that are not only personalized to your history, but also to your current context.

Beau

Wow. So it's a constant dance between long-term preferences and short-term intent, all happening in a few dozen milliseconds. It's way more of an engineering and architecture puzzle than just a modeling one.

Jo

That's the key takeaway. The fanciest model in the world is useless if you can't serve it. The retrieval-ranking funnel is the architecture that makes it all possible.