Search and Recommendation Systems of LLMs

Technical architecture behind LLM-powered semantic search, vector embeddings, and personalization engines.

Speakers: Ahmet Kuzubaşlı

Content author

22 Nov 2023

Video Transcript

⏱ 20 min read• 3,431 words

Read the full speech or switch languages

— Hey everyone, I'm Ahmet Kuzubaşlı. I work as a Staff Data Scientist at Udemy. I'm based in the San Francisco office. Today I'll be talking about LLM-based search and recommendation systems. I might switch between English and Turkish. Please bear with me on that. Let's jump right in. I know this is the last talk of the day. So I don't want to keep you too long. I just wanted to walk you through how LLM'ler get used in search and recommendation systems. And how they'll reshape this space.

I won't go deep into the technical details. I won't try to cover everything. I know it's the last session of the day. So I'll keep it short. They kindly gave me 45 minutes. But I plan to wrap up in 15 or 20. Since this is the last session and it's online, I won't be taking questions today. But you can always reach me on social media or by email. It's easy: ahmetkuzubasli@gmail.com. I'm on every social platform under that same name. Here's the agenda. I'll do a short intro. Then I'll cover the landscape. I won't do an intro to LLM'ler. It's the last session of the day. Someone has probably already introduced them a few times. I'll focus mostly on search and recommendation systems.

Again, what kind of problems there are, what kind of limits there are. I'll be talking about those. I'll also touch on future trends a bit. But of course these are topics that need constant updating. These are areas that need updating. Even while I'm talking to you right now. A new paper may have dropped this week. A new blog post may have gone up. So I can already tell you this presentation is out of date. Like I said, today I'll be talking about search and recommendation systems. Plenty of products offer services built on this. Plenty of companies do too. For many companies, the whole reason they exist, the entire business model, rests on recommendations. You know the ones I mean.

As I mentioned. The real point of my talk today is to give you a taste. How do LLM and search engines work? But especially, how can search and recommendation systems work? Search is a bit more, well, I'm sure you've heard. I'm guessing you already know the dramatic impact on this space. And again, I'll start my talk by introducing myself. So, I'm a METU graduate. I also have a PhD in computer engineering at METU, on deep learning. I started it but never finished. Unfortunately I had to drop it when I moved to the States.

Right after graduating I worked as a research assistant at METU. Then I founded my own company. Three or four years, and it went really well. Later I sold my shares in that company to my partners and exited. Then came my solo consulting journey. I did consulting on TAIE and other platforms, especially on AI and data science. And for 5 years now, which I think is a pretty long time. I've been working as a data scientist at Udemy. First I was in the Turkey office. For the past 2 years I've been in the San Francisco office in the US. On the other side. I've been hosting and guesting on radio shows on TRT Radyo 1 since 2015. About tech, about AI, especially about artificial intelligence.

I try to join shows often on topics like raising public awareness and career paths in data science. Twitter, X, LinkedIn, Instagram; it's Ahmet Kuzubaşlı everywhere. I'm really easy to find. Hit me up with questions, anything you want advice on. Or if you come to the US and want to grab coffee. Now when you look at the landscape. This stuff has become an inseparable part of it. We actually call these data products; search and search systems, for example. At Udemy I worked on search for 3 years first. And now I've been on recommendations for 2 years.

So this is an area that seriously moves the revenue models of mega companies like Netflix. Spotify, and Amazon. Around 30-40% of traffic comes from search. Another 20-30% comes from these recommendation systems. That's why the smallest change you make here, even a 1% improvement. Gets seen by millions of users. In some cases even billions of users. So it adds up to serious revenue. It brings you serious gains. I can say this from personal experience. It really brings us what we're looking for, fast and accurately. And on the other side. It predicts what we want without us having to search at all. With a good model, it hands us options. I think this came out of how online experience evolved after the 2000s.

That's the short version. I didn't want to go too deep into technical details. Right now I just want to say one thing. Search and recommendation systems are non-negotiable. You should start building them on day one. Now let's talk a bit about LLM applications in search. I'm sure Zeo has already given you plenty of info today. So let's start with the first big thing: query understanding. I sweated over this a lot at my own company too. You read the user's query. You expand it when needed. You narrow it down when needed. Then you surface more accurate results higher up.

There's a line from Sam Altman, OpenAI's founder, on this. He says search systems aren't just tools for pulling something out of a fact database anymore. They're a real reasoning engine now. You ask a question, it gives you an answer. And it generates that answer itself. These are what we'd call retrieval-augmented systems. I'm guessing we'll run into this term a lot: retrieval-augmented generation. It doesn't just hand you the result as found. The opposite. It layers its own knowledge on top. That's how it builds the final answer.

There are so many applications for this. We went from text match to semantic understanding. We understand natural language now. We solve the ambiguity problem. Classic example: dog toy dog. Do they want a toy dog or a dog toy? LLM'ler ile solving problems like that is very doable. Of course, this brings some headaches too. We'll get to those later, in the coming slides. But bottom line: we expect these improvements in search systems to move the needle on user experience. And by a serious amount.

Because when people look for something, they can't always phrase it well. At first they do what we call an initial search. They fire off a few searches, a few queries. They figure out what they should be searching for. Then they bring the real query. That drives up the average number of searches. But people should be able to just blurt it out. They should type it raw and still get a solid result. On top of that, there's in-video search and in-context search.

I'm sure you've run into this. You're not looking for the video itself. You're looking for a specific second in it. A specific moment. In some cases it can find that for you. People have been working on this for a while. But with LLM'lerle it really takes off. Semantic search shifts toward more natural language queries. We expect a more chat-based search system. And on top of that, we expect product discovery to get seriously better. That brings a lot of problems with it. In systems like text match, you can build a dataset. Then you can run a performance benchmark on it.

I'm not saying it's easy. But it's doable. Once LLM'ler enter the picture, evaluation gets really hard. Especially when the result is augmented. The same problem shows up in summarization. There are serious debates going on about it. People say LLM'ler have passed human performance. Meanwhile, others argue that human baseline wasn't drawn from the right people. Real benchmarking is not an easy job. On the other side, we're starting to see examples. Examples of LLM tabanlı systems. The biggest problem in front of LLM tabanlı systems right now is price. That's how I see it. You hit the LLM'e on every query. If you don't run your own LLM stack, it gets genuinely expensive. In time, in response time, and in what you pay per query.

Of course there are plenty of workarounds. Caching, for example. Let's keep going. There's honestly so much more I could say about this. The e-commerce use cases are one thing. The streaming ones are another. Every domain, every vertical hits its own problems. And finds its own solutions. In a 15-20 minute talk, you can't go into all of that detail. But if you ever want to grab a chat, or another talk. Or another project, I'm always around. Let's keep going. Alright, let's get to recommendation. Now, I put this here to be a bit of a troll. Very traditional recommendation algorithms. What we see here is collaborative filtering. It's based on matrix factorization. It approximates a user-item matrix.

Once you factorize, you're left with a user vector and an item vector. And you can vectorize users and items that never met before. Things that never left a mark on each other. Item-to-item pairs too. So you can compute how they'd affect each other. It works really well. Works great, honestly. As long as you have enough users and enough products, of course. Where does it break down? It's pretty basic. If a new user shows up. If you're a fast-growing platform. Or content gets added really fast. Like Medium, medium.com. Or YouTube. Or TikTok, for example. When content lands that fast, recommending it off past interactions alone isn't easy.

That's exactly what we call the cold start problem. And right here is where we need context. Who is this user? What might they want? Not just their past actions. Demographics, taste, earlier choices. On the other side, a new movie drops. A new article gets published. What is that article even about? So what's in the context? Understanding that is exactly what LLM'ler are built on. And at this point, personalization is the biggest thing. You have to surface the right result. It's a ranking problem, just like in search. But the word to underline here is personalization.

Results came back. But I need to know they were ranked for me. I need to feel that the order matches my request. That it matches my personal taste. If that happens, I find what I want in the top three. On the flip side, it recommends something I never thought of. Then I engage with the platform more. My retention goes up. My session time goes up. I'm sure you already know how much personalization matters. So I won't belabor it. Personalization has driven serious profits over the last three or four years. On the other hand, in-video interactions keep growing. Our company allows this, for example. Our platform lets you take notes while you watch a lesson.

Taking those notes, for example. Then recommending other things based on those notes. That kind of action is possible. YouTube has something similar with bookmarks. Bookmark suggestion could be its own separate product. So improving user experience with LLM'ler ile, and how satisfied people are with the platform. Every company has at least 9 or 10 projects on this right now. And those 9-10 are the ones picked out of a hundred-plus ideas. It's happening. It's flowing. Product managers are genuinely sweating right now. Which one do we build first? Meanwhile, different industries and companies can use different recommendation engines. The impact isn't the same across the board.

Take natural language feedback. Say I can pause a video and drop a suggestion. Or I leave a review on a product page. And that review actually gets understood and used properly. Not just one to five stars. Something I can really use. Here's the part I love: it generates the review for me. You go to a restaurant. Some things you liked, some you didn't. But you don't feel like sitting down to write it up. So it writes a review for you, in your own voice. I really like that.

A couple clicks later. On the other hand, sure, you can get away from stuff like that. Right now, recommendation systems at some companies still lean on one thing. They lean on popularity. They show you the popular items. But maybe you don't care about popular products. Maybe you're not that into pop culture. In that case, hitting your actual taste without LLM'ler isn't always easy. Sooner or later, popular products start taking over. But what we call contextual recommendations is stepping up. Those are systems that understand the content, understand you, and match the two.

But it's not like we drop everything and go all in on LLM'lere. Honestly, that's not the move. Same as with search, same as with vector databases. In recommendations too, you still want collaborative filtering in the back. You still want content-based filtering. Because there are multimillion users and multimillion products. You can't cross all of them. Multimillion times multimillion just blows up. So first you need to filter the products down. Then you ask which of these should I recommend. At this point I'm guessing you get the problems with recommendations. The biggest problem here is picking from way too many products for way too many users. You can't just dump that raw into an LLM'e. Honestly, that's not a thing.

You still have to use the old methods. On the other hand, we can talk about the general problems with LLM'ler. I don't want to go too deep into these today. They've been covered in other talks. Ethics and privacy problems have started rising seriously. For example, there needs to be an "I don't want recommendations" option. When an LLM makes really good recommendations, people's trust in the platform actually drops. Like, are we being listened to? Is it listening to us? How can it recommend this well?

Things like this start coming up. I talked about travel and cars with a friend. That evening I saw the listing on Instagram. An ad showed up right in front of me. Being paranoid doesn't mean you aren't being tracked. But when recommendations get this good and get personalized with LLM'ler. And the reason for that recommendation can be explained with LLM'ler. It really starts getting weird. It starts getting scary. Maybe at that point we need to put the focus back on recommendation systems. Old systems, let's call them traditional systems, don't tell you why a recommendation was made. So when you open Netflix right now, you see something in every row.

It's trying to give you an idea. Because you watched this before, so I'm recommending this to you. But you don't know exactly why it recommended that. If LLM'ler can do the necessary reasoning, and in some cases they can. Then it can say: yes, I recommended you this Python course. Because you want to be a data scientist down the road. In this Python course, you'll learn the pandas library. So that's why you should take this course. Or here's why you should watch this video. It's genuinely great that it can answer: here's why we picked this movie for you.

It also cuts down on that concern a bit. On the flip side, computational cost and resources are a real problem. Doing this one by one for every query, every user, every product is seriously expensive. In every sense. And beyond that, there's even the climate damage from all the GPUs being used. So these things need to get much cheaper. That means cheaper financially and lighter on computation too. On the other hand. What we should highlight today is that fine tuning and model selection are becoming less of a thing.

So you can take an AI that OpenAI built and use it in your own system. LLM tabanlı. How do you do that? By the way, there's P5 for an LLM'e, I added the references. In P5 you train it yourself end to end. But newer systems use the LLM as the core. They put agents around the LLM and build the recommendation system that way. So you're not training an LLM end to end just for recommendations. That cuts the fine tuning burden down. It also improves things on the model selection side. But like I said, one of the biggest problems here is benchmarking.

So how do you benchmark it? Personalization especially — how do you benchmark that? A new user shows up. You give them recommendations. But they have to click before you get feedback. We call it this: negative signal is hard to get. Because they see it, and when they see it, they click. But when you never show it to them. You don't know if it's a yes or a no for those products. And you can't show everything. You can't show a user millions of products. You can only work with what you showed.

So at that point, measuring this — the benchmark. The evaluate part — those are still real problems. Still serious problems. But there are workarounds. You make some assumptions, accept some limitations. And you can still test the system you built. At the simplest, if you can't do anything else. Take it offline into an A/B test. Give half the users one algorithm, half another algorithm or model. Then A/B test on whatever your business metric is. If we talk a bit about the future. At this point we need to talk about GPT-4 and beyond.

At this point reasoning came out better. And factuality, or fewer hallucinations, means you can use it better. You can actually ship it in a product. With 3.5 the hallucinations were high. So in recommendations, running it in prod, in production. Live — there were things you had to watch out for. Because there were problems with 3.5, as you know. Say it makes a wrong recommendation. And it bases that on wrong factuality. That's when you get trouble. On the other hand, this is a very active research area. That's why I didn't want to go too long on it today.

Because whatever I say today, something much better could show up next week. I just wanted to talk about its general impact on this field. I wanted to call attention to it. Agents, I mean, from what I see too. Whether it's LangChain or the Llama side. The things built on top are heading toward being used as agents. In recommendation and search systems too, you put an agent on the LLM'e. You put the LLM in the middle and wrap agents around it. You hook it up to a database so it can fire a SQL query. Or you hook it into your collaborative filtering system.

And in the middle, the LLM handles the needed queries. It could be chain of thought. It could be tree of thought. Or, for example, I read something yesterday. What was it called? Self-evaluating, it says. That thinking system where it reviews its own reasoning again. Let's just call it a thought process today. People are trying to build recommendation systems on top of those systems. Honestly, I couldn't read many industry blog posts about this. I couldn't find them. Right now everyone's experimenting. I mostly see it in the papers.

So they ran this on Amazon's database. On a public dataset, and they published it. But honestly, I haven't seen a good LLM-based blog post from Netflix or Spotify yet. Maybe we need to do talks like this every three or four months. Yiğit, maybe that's a to-do for us. I put down a QA session, but sadly we can't do one today. I still left a tag up there. Ahmet Uslu, that's the handle. Gmail, X, Twitter, LinkedIn, Instagram if you use it. I'm on pretty much all of them. I try to stay reachable everywhere I can. That's how I see LLM use in recommendation. These are the projects I work on day to day. We're a public company, so I can't share any of it in detail. It's not legal either. So I couldn't get very specific with you today.

But I wanted to share roughly what companies are trying to do. If you have more questions, ideas, tips, or complaints, reach out to me. Have a great time at the launch party, everyone.

— Thank you. Thanks, Ahmet.

This transcript was generated using AI speech recognition and verified against subtitle style rules.

Content author

Zeo's Guest

author

Contact us

How we handle your data

Open as a full page