AIAI EngineerJul 16, 2025· 21:10

Transforming search and discovery using LLMs — Tejaswi & Vinesh, Instacart

Vinesh Gudla and Tejaswi Tenneti from Instacart detail how they use LLMs to overhaul search and discovery. They address challenges with conventional search: broad queries suffer cold start, tail queries lack engagement data. Using LLMs with Instacart's domain knowledge—e.g., top-converting categories as context—they improved precision by 18 percentage points and recall by 70% for tail queries, and cut zero-result queries. For discovery, LLMs generate complementary/substitute items; but pure LLM suggestions like 'chicken' for 'protein' missed user intent, so they augmented prompts with behavioral data (top categories, subsequent queries) to boost engagement and revenue. They use a hybrid approach: pre-compute offline for head/torso, distilled Llama 8B for long-tail, and LLMs as judges for evaluation. Key takeaways: combining LLM world knowledge with domain-specific data is critical, and evaluation is as hard as generation.

Transcript

Intro0:00

Vinesh Gudla0:16

Hi. Good afternoon, everyone. My name is Vinesh, and he's Tejaswi. We are part of the Search and Machine Learning team at Instacart, so today we'd like to talk to you about how we are using LLMs to transform our search and discovery.

Um, so yeah. So first, a little bit about ourselves. Yeah, as I mentioned, we are part of the Search and Discovery ML team at Instacart. And for those of you who may not be par who may not be familiar with Instacart, it's the leader in online grocery in North America.

Uh, and our mission is to create a world where everyone has access to the food they love and more time to enjoy it together. So, coming to what we'll actually talk about today, uh, first we'll talk about the importance of search, uh, in grocery e-commerce.

Uh, then we'll look into some of the challenges facing conventional search engines, uh, and then actually get to the meat of the talk today, which is how we are using LLMs to solve some of these problems. Uh, finally, we'll, uh, finish with some key takeaways from today's talk.

Search Importance1:00

Vinesh Gudla1:16

So, coming to the importance of search in grocery e-commerce. Uh, I think we've all gone grocery shopping. Customers come with long shopping lists, uh, and it's the same on the platform as well. People are looking for tens of items, uh, and of these, a majority of them are just restocking purchases.

That is, things that the customer has bought in the past. Uh, and the remaining are items that the user is trying out for the first time. So, uh, and, and the majority of these purchases come from search. So, uh, search has a dual role.

It needs to both support, uh, quick and efficient, uh, it needs to help the customer quickly and efficiently find the product they're looking for, and also enable this new product discovery. Uh, and new product discovery isn't just important for the customer.

Search Challenges2:00

Vinesh Gudla2:00

It's also great for our advertisers because it helps them showcase new products. Uh, and it's also good for the platform because, uh, overall it encourages larger basket sizes. Uh, so, so let's see what some problems are with our existing setup that sort of, uh, makes this hard.

Uh, so, so to begin with, uh, we have two classes of queries that are, are generally more challenging, especially from an e-commerce perspective. Uh, the first are overly broad queries. Uh, in this case, like on the left, the snacks query, where there are tons of products that map to that query.

Uh, and now, because our models are trained on engagement data, if we aren't exposing these products, uh, to the user, it's hard to actually collect engagement data to, to them, rank them up high. So the traditional cold start problem, in a way.

Uh, then, uh, as you can see on the query on theright, we have very specific queries like unsweetened plant-based yogurt, where the user is looking for something very specific. And these queries, uh, don't happen very frequently, which means that we just don't have enough engagement data to train the models on.

Uh, and while we have, uh, done quite a bit of work to sort of, um, improve this, uh, the challenge that we continually keep facing is that while recall improves, uh, precision is still a challenge, especially in a pre-LLM world.

Uh, the next class of problems is how do we actually support that new item discovery as we spoke about. So when a customer walks into a, a grocery store, uh, let's say into a pasta aisle, they might see new brands of pasta that they would want to try out.

Uh, along with that, they would also see pasta sauce and every other thing that's needed to make a bowl of pasta. Uh, and customers would want a similar experience on our site. Uh, we have heard multiple feedback, uh, multiple rounds of feedback from our customers that, "Hey, I can find the product that I'm that I want via search, but when I'm trying to find any other related products, it's, it's a bit of a dead end.

I would need to make multiple searches to get to where I want to." So this was a problem that we wanted to solve as well. And yeah, as I mentioned, uh, pre-LLMs, this was a, a hard problem because of the lack of engagement data, etc.

So let's see how we actually use the LLMs to sort of solve these problems. Uh, I'll sort of talk specifically about how we use the LLMs to uplevel our query understanding module. Now, query understanding, as I'm sure most of you know, uh, is the most upstream part of the search stack.

Query Classification4:10

Vinesh Gudla4:26

Uh, and very accurate outputs are needed to sort of enable better retrieval and recall, uh, and finally improve our ranking results. Uh, so our query understanding module has multiple modules in them, like, uh, query normalization, query tagging, query classification, uh, category classification, etc.

So in the interest of time, uh, I'll just, uh, pick a couple of modules and talk about how we, uh, sort of really improve them. Uh, the first is our query to, uh, category, uh, product category classifier. Uh, essentially, we are taking a query and mapping it to a category in our taxonomy.

Uh, so as an example, if you take a query like watermelon, that maps to categories like fruits, organic fruit, foods, etc. Uh, and our taxonomy has about 10,000 labels, of which 6,000 are more commonly used. So because a product a query can map to multiple labels, this is essentially a multi-label classification problem.

Um, and in the past, our traditional models, uh, which were we actually ha-had a, a couple of different models. One was a fast text-based, uh, neural network, which essentially modeled the semantic relationship between the query and the category.

Uh, and then as a fallback, we had an NPMI model, which was a statistical co-occurrence model between the query and the category. Now, while these, uh, techniques were great for the for the head and torso queries, we had really low coverage for our tail queries because, again, we just didn't have enough engagement data to train the models on.

Um, and to be honest, we actually tried more sophisticated bird-based models as well. Uh, and while we did see some improvement, the lack of engagement data, uh, meant that for the increased latency, we didn't see the wins that we actually hoped for.

So, um, so this is where we actually tried to use an LLM. Uh, first, we took all of our queries, uh, and we, along with the taxonomy, we fed it into an LLM and asked it to predict the most relevant categories for that query.

Now, the output that came back was decent. Uh, actually, when we all looked at it, it made a lot of sense. Uh, but when we actually ran an online A/B test, the results weren't as great. Uh, and one particular example that illustrates this point very well is a query like protein.

Uh, our users that come to Instacart, when they type something like protein, they're looking for maybe protein shakes, uh, protein bars, or other protein supplements. The LLM, on the other hand, thinks that pro when a user types protein, they're looking for maybe chicken, tofu, or other protein foods.

So this mismatch, wherein the LLM doesn't truly understand Instacart user behavior, was really the cause of the problem. So to sort of maybe improve our results, we sort of switched the problem around. We took the most commonly converting categories, or the top K converting categories for each query, and fed that as additional context to the LLM.

Uh, and then I'm sort of simplifying this a bit. There's a bunch of, uh, ranking and downstream validation that happens. But essentially, that, that was what we did. We generated a bunch of candidates, uh, ranked candidates, and this greatly simplified the problem for the LLM as well.

Uh, and again, to illustrate this with an example, uh, take a query like Werner soda. Uh, our previous model actually identified this as a as a brand of fruit fla or a fruit-flavored soda, which is not incorrect, uh, but it's not very precise either.

Now, the LLM, uh, did a much better job. It identified it as a brand of ginger ale. And with this, our downstream retrieval and ranking improved greatly as well. And as you can see from, uh, the results below, uh, especially for tail queries, we saw a big improvement.

Our precision improved by over 18 percentage points, and our recall improved by over 70 percentage points, which is actually pretty significant for our tail queries. Um, and maybe to, to very briefly look at our prompt, as you can see, it's very simple.

Uh, we are essentially passing in the ca the top converted categories as context. Uh, there are a bunch of guidelines about what the LLM should actually out do, and, and that's it. So this was all that is needed to sort of enable this.

Uh, again, I'm simplifying the overall flow, but, uh, the general concepts are pretty straightforward. So coming to the another model, uh, the query rewrites model is actually pretty important as well, uh, from, uh, a gr from an e-commerce perspective, especially at Instacart, because not all retailers are created equal.

Some have large catalogs, some have very small catalogs. The same query may not always return results. And that is where a rewrite is really helpful. For example, going from a query like 1% milk to just milk, or at least return results that the customer can decide to buy or not.

Query Rewrites8:57

Vinesh Gudla9:13

Uh, and again, our previous approach, which was trained on, uh, engagement data, didn't do too well. It suffer or it did decently well on head and torso queries, but it suffered from a lack of engagement data on tail queries.

Uh, so by using an LLM, similar to how we did for the product category classifier, uh, we were able to generate very precise rewrites. Uh, in the example here, you can see that there's a, a substitute, a broad, and a synonymous rewrite.

So for the case of avocado oil, the substitute is olive oil. A broader rewrite is, um, healthy cooking oil, and a synonymous rewrite is just avocado extract. And again, uh, just, just looking at the results from this, and if you we saw a bunch of offline improvements.

And just moving from, uh, from th using third-party LLMs here, just going from more simpler models to better models improved, uh, the results quite a bit. Uh, this is based off of our human evaluation data. Uh, so as you can see, just improving the models itself improved the overall performance of the task.

And in terms of online improvements, we actually saw a large drop in the number of queries without any results. This is pretty significant again because, uh, we could now actually show results to users where they previously saw empty results, uh, which was great for the business.

Offline Serving10:34

Vinesh Gudla10:34

So, uh, coming to the sor sorta the important part of this, which is how we actually scored and served the, the data. Uh, the thing is that Instacart has a pre uh, has a pretty idiosyncratic, uh, query pattern.

There's a very fat head and torso set of queries, and we have a sort of a long tail. So by compu pre-computing the outputs for, for all of the head and torso queries offline in a batch mode, we were able to sort of, uh, cache all of this data.

And then at online, when a query comes in, we could just serve it off of the cache with very low impact on latency, uh, and fall back to our existing models for the long tail of queries. And again, this worked really well because it didn't, uh, impact our latency, while it greatly improved our coverage for the long tail of queries.

Now, for the, the really long tail where I said we would fall back to our existing models, we're actually trying to replace them with a distilled Llama 8B model, uh, so that we can actually do a much better job compared to the existing models.

Um, so yeah, to sort of summarize, uh, essentially what we saw was that, uh, from a query understanding perspective, we have a bunch of models, uh, and just using our hybrid approach greatly improved their performance. But what's actually more interesting is that today, query understanding consists of a bunch of models.

And as Yuzu was talking about in the Netflix talk, managing all of these models is actually complex from a system perspective. So, uh, consolidating all of these into an SLM or a or maybe a large language model, uh, can make the results a lot more consistent.

And I'll finish it off by giving an example here. Uh, there's a query hum that we sort of saw some interesting issues with, uh, which is spr which is spelled H-U-M-M. Uh, the actual query the our, our query brand tagger identified the brand correctly as a brand of, uh, kombucha, but then our spell corrector unfortunately corrected it as hummus.

So the results were really confusing to users, uh, and was pretty bad. But by using a more unified model, I think the results were much better. The second is by passing in by using an LLM for query understanding, uh, we can actually pass in extra context.

Um, so instead of just generating results for that query in isolation, we can tr really try to understand what the customer's mission is. Um, so for example, detect if they're actually here to buy ingredients for a recipe, etc., and then generate the content for that.

So to talk more about that, uh, I have Tejaswi here.

Tejaswi Tenneti13:18

Thank you, Anish. Uh, now I'll quickly talk about how we used LLMs for showing more discovery-oriented content in search results page. Uh, just to re uh, restate the problem, uh, our users found that while our search engine was very good at showing exactly the, the, the results that they exactly wanted to see, once they added an item to the cart, they couldn't do anything useful with the search results page.

Discovery Content13:18

Tejaswi Tenneti13:38

They either had to do, like, another search or go to another page to fulfill their next intent to some sort. Uh, tradis solving this with traditional methods would require, like, a lot of feature engineering or manual work. Uh, LLMs solved this problem for us, and I will talk about how.

Uh, so this is how it looked in the end. So for queries like Swordfish, uh, let's say there are no exact results, we used LLMs to generate substitute results like other seafood alternatives, meaty fish like tilapia, and whatnot.

Uh, and similarly, for queries like sushi, where there were a lot of exact results, let's say, uh, we would show at the bottom of the search results page, we would show things like Asian cooking cooking ingredients or Japanese drinks and so on, uh, in order to, like, you know, uh, get the users to engage.

Uh, I'll talk about the techniques here, but, uh, both of these uh, both of these discovery-oriented results we saw, like, improv uh, led to, like, improvement in engagement as well as improvement in revenue, uh, for our per each search.

Uh, cool. Uh, like I said, I'll get into the techniques, but let's first talk about the requirements to generate such content. Uh, first, uh, obviously, we wanted to generate content that is incremental to the current solutions. We don't want duplicates to what we were already showing.

And the second requirement, and the most important one, is we wanted all of the LLM answers or, or the generation to be aligned with Instacart's domain knowledge. What does this mean? So if a query's if a user searches for a query called dishes, LLM should understand that it refers to, like, cookware and not food, uh, and vice versa for a query like Thanksgiving dishes,right?

Domain Alignment15:10

Tejaswi Tenneti15:10

So with these requirements in mind, we set up with we started with, like, a very basic generation approach. So what did we do? We took the query and we told the LLM, "Hey, you are an AI assistant, and your job is to generate two shopping lists.

One is a list of complementary items, and another is a list of, like, uh, substitute items for a given query,"right? Um, looked good. Uh, I mean, so we, we saw the results. They looked pretty good. Uh, our PMs vetted everything.

We looked at everything. Uh, and, and like Vinesh said in, in, like, QU, we when we launched this to our users, uh, we saw that the results were good, but users weren't engaging it as much as we would have liked it to.

So we went back to the drawing board, and we were like, uh, we, we tried to analyze what was going on. And what we realized quickly was, while LLMs' answers, uh, were, like, common sense, like, answers and so on and such, they weren't really what users were looking for.

Uh, taking the protein example again, like, uh, users, when they search for protein, they look for protein bars and protein shakes rather than what LLM would give as an answer, which is chicken, turkey, and tofu, and whatnot,right? So, uh, so what we did was we augmented the prompt with Instacart domain knowledge.

So, uh, in one case, what we did was we took the query and then we augmented it with, like, here, here is the query, and here are the top converting categories, uh, for this particular query, along with any annotations from the query understanding model, like, "Hey, here is a brand present in the query.

Here is, like, a, uh, dietary attribute present in the query," and so on and such. Uh, in another case, we were like, "Here is the query, and here are the subsequent queries that users did once they issued this particular query."

So once you augmented the prompt with this additional metadata about how Instacart users behave, the, the, the results were far more better. Uh, I don't have the time to show, like, the before and after, but like I said, we definitely saw, like, a huge improvement in both engagement as well as revenue.

Uh, I'll quickly talk about, like, how we served, uh, all of these contents, uh, like, very similar to QU. It's impractical to call the LLM in real time because of latency and maybe cost concerns sometimes. So what we did was, uh, we took all of our, uh, historical search logs, we called LLM in, like, a batch mode, and stored everything.

Serving Discovery17:05

Tejaswi Tenneti17:24

So query, content metadata, along with even the products that could potentially show up in the carousel. And online, it's just a very quick lookup from a feature store. Uh, and that's how we were able to, like, uh, serve all of these recommendations in, like, blazing fast time.

Uh, again, things weren't as simple as, as we making them out to be. The, the, the like Vinesh said, the overall concept is simple. The, the prompt itself is very simple, but there were three key challenges that we solved along the way.

Uh, one is aligning generation with business metrics like revenue. Uh, this was very important to select top-line bins. So we iterated over the prompts and the kind of metadata that we'd fee that we would feed to the LLM in order to achieve this.

Second, we spent a lot of time on ranking, uh, on improv improving the ranking of the content itself and so on and such. So our traditional PCTR, PCVR models did not work. So we had to, like, employ strategies like, uh, diversity-based re-ranking and so on and so forth to get users to engage with the content.

Uh, and then the third thing is evaluating, uh, the content itself. So one is making sure that, hey, whatever LLM is giving, uh, is oneright. It's not hallucinating something. Uh, and second, it adhered to, like, what Instacart or what we need as a product,right?

Cool. Uh, so summarizing the, the key takeaways from our talk, uh, LLMs' world knowledge was super important, uh, to improve, uh, query understanding predictions for especially for the tail queries. Uh, while LLMs were super helpful, we really found success by combining the domain knowledge of Instacart with LLMs, uh, in order to see the top-line bins that we saw.

Key Takeaways18:36

Tejaswi Tenneti18:58

Uh, and the third and the last one is evaluating the content a-as well as the QU predictions and so on and such was far more important and far more difficult, uh, than we anticipated. We, we used LLMs as a judge in order to make this happen, but very, very important step.

We and we realized that kind of late. So yeah, that's all from us. We'll take questions now.

Vinesh Gudla19:20

Thank you, Jojo. Tejaswi, Vinesh. Um, yeah, we'll take questions at the mic while the next speaker gets set up.

Guest19:25

Hi. Uh, thanks for the talk. Um, have you also been trying around queries which are very long in natural language, like, uh, "I want these three items and these five items," like what we would do it on Chat ChatGPT, or it's still, like, single item that's the focus?

Q&A19:25

Vinesh Gudla19:43

Uh, yeah. I, I think we have. We have actually launched something in the past, uh, like Ask Instacart, if you've heard, heard of it, which essentially takes natural language queries and tries to map that to search intent. So for example, you might ask you might say, "Healthy foods for a three-year-old baby," or something like that.

And so that would map to things like fruit slices. Uh, I don't know if three-year-old toddlers can eat popcorn, but something along those lines. And, and then we had our usual ranking, uh, recall and ranking stack sort of retrieve those results.

Guest20:16

So, uh, any learnings from that experiment for you?

Vinesh Gudla20:19

Yeah. So, so I think we actually have a lot of learnings from that. Essentially, uh, as Tejaswi already mentioned, uh, we need to inject a lot of Instacart context into the model to be able to get re decent results.

The evaluation part is really key. Uh, so having a robust automated evaluation pipeline was important. And lastly, passing context. That is, for example, if it's a let's say it's a Mother's Day query, and let's say we come up with, uh, individual search intents as perfumes.

You really want women's perfumes to be in there, whereas when we just had perfumes, we could see all kinds of items. So passing that context from the LLM to the downstream systems is really important.

Guest21:01

Cool. Thanks.

Tejaswi Tenneti21:01

Yeah, we have a lot of examples where we failed. We can talk about.