LLM-Enhanced Search and Discovery for Grocery E-commerce

instacart · E-commerce · year n/a · source Agentic: no · promotional bias: low · source-backed · extracted with prompt 0.5.6 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Grocery e-commerce search and discovery

Instacart needed better search query understanding and discovery for tail queries where traditional models lacked engagement data and general LLM knowledge did not match grocery-specific user intent.

Constraints:

Architecture

Instacart used LLMs as targeted enhancements to query understanding and discovery rather than replacing the search stack. For query-to-category classification, the LLM receives the query plus top converting categories and other Instacart context, turning open-ended prediction into context-informed ranking. Head and torso query outputs are precomputed offline and cached, long-tail cases fall back to existing models or distilled Llama exploration, and generated discovery content is served from a feature store after batch LLM generation, ranking, and evaluation.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  Query_understanding_module["Query understanding module"] --> Query_to_category_classifier["Query-to-category classifier"]
  Query_to_category_classifier --> Taxonomy["Taxonomy"]
  Taxonomy --> LLM_context_ranker["LLM context ranker"]
  Top_converting_category_context["Top converting category context"] --> LLM_context_ranker
  LLM_context_ranker --> Batch_precompute_cache["Batch precompute cache"]
  Batch_precompute_cache --> Feature_store["Feature store"]
  LLM_context_ranker --> Discovery_content_generator["Discovery content generator"]
  Discovery_content_generator --> Feature_store
  Feature_store --> Search_ranking_stack["Search ranking stack"]
  Query_understanding_module --> Search_ranking_stack
  LLM_context_ranker --> Evaluation_pipeline["Evaluation pipeline"]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Query understanding module Upstream search component containing query normalization, tagging, classification, and category classification. Query-to-category classifier, Query rewrite model, Search ranking stack
Query-to-category classifier Maps user queries to product-category labels in Instacart's taxonomy. Taxonomy, LLM context ranker, Search ranking stack
Taxonomy Product category label space with about 10,000 labels and 6,000 commonly used labels. Query-to-category classifier, LLM context ranker
Top converting category context Instacart-specific behavior signal used to align LLM outputs with actual user intent. LLM context ranker, Query-to-category classifier
LLM context ranker LLM call that predicts or ranks categories/content using query, taxonomy, and Instacart metadata. Top converting category context, Batch precompute cache, Discovery content generator
Batch precompute cache Offline cache for head and torso query LLM outputs to avoid real-time latency. LLM context ranker, Feature store
Discovery content generator LLM process generating complementary and substitute shopping-list content with domain metadata. LLM context ranker, Feature store, Search ranking stack
Feature store Online lookup layer for precomputed LLM-generated query metadata, content, and candidate products. Batch precompute cache, Search ranking stack
Search ranking stack Existing recall and ranking stack that retrieves products using the enriched query understanding outputs. Query understanding module, Feature store
Evaluation pipeline Automated evaluation including LLM-as-judge checks for generated content and query predictions. LLM context ranker, Discovery content generator

Data flow

Queries enter the query understanding module, which includes normalization, tagging, classification, and category classification. For category prediction, Instacart provides taxonomy and top converting categories as LLM context, ranks candidates, validates downstream, and precomputes outputs for frequent queries. For discovery content, historical search logs are batch-processed by LLMs with query metadata and behavior context, stored with candidate products, and served online through fast feature-store lookup into the existing retrieval/ranking stack.

3 supporting quotes
“our query understanding module has multiple models in them like query normalization, query tagging, query classification, category classification etc.”transcript, stated
“we took the most commonly converting categories or the top K converting categories for each query and fed that as additional context to the LLN.”transcript, stated
“We called LLM in like a batch mode and stored everything. So query content metadata along with even the products that could potentially show up in the carousel”transcript, stated

Why this architecture

The architecture keeps low-latency search serving practical by batching and caching frequent LLM outputs, while injecting Instacart-specific behavior data to correct the mismatch between general world knowledge and grocery search intent.

3 supporting quotes
“this mismatch wherein the LLM doesn't truly understand Instacart user behavior was really the cause of the problem.”transcript, stated
“by comput premputing 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”transcript, stated
“we really found success by combining the domain knowledge of Instacart with LLMs”transcript, stated

Models used: LLMs · FastText-based neural network · NPMI co-occurrence model · BERT-based models · distilled Llama model · LLM-as-judge · PCTR/PCBR ranking models

Scale

Alternatives considered (roads not taken)

Use traditional FastText/NPMI/BERT models alone

Rejected because: They worked for head and torso queries but had low tail-query coverage and BERT latency did not justify the gains.

“these uh techniques work great for the for the head and torso queries, we had really low coverage for our tail queries”transcript, stated
“while we did see some improvement, the lack of engagement data meant that for the increased latency, we didn't see the wins”transcript, stated

Ask the LLM for categories without Instacart behavior context

Rejected because: Manual outputs looked sensible but online tests showed that general world knowledge misread grocery intent.

“when we actually ran an online AB test the results weren't as great.”transcript, stated
“users when they search for protein They look for protein bars and protein shakes rather than what LLM would give us an answer which is chicken, turkey and tofu”transcript, stated

Call the LLM online for every query

Rejected because: Latency and cost made real-time LLM calls impractical for serving all generated discovery content.

“It's impractical to call the LLM in real time because of latency and maybe cost concerns sometimes.”transcript, stated

Patterns

semantic-caching (serving)

Instacart precomputes LLM outputs for head and torso queries offline and serves them from cache or a feature store to avoid online latency.

“by comput premputing 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”transcript, stated
“online it's just a very quick look up from a feature store.”transcript, stated

eval-driven-development (evaluation)

Instacart used online A/B tests, downstream retrieval/ranking results, business metrics, and LLM-as-judge evaluation to iterate on query and content quality.

“when we actually ran an online AB test the results weren't as great.”transcript, stated
“We used LLM as a judge in order to make this happen but very very important step and we realized that kind of late.”transcript, stated

llm-as-judge (evaluation)

The team used LLM-as-judge checks to evaluate generated content and query predictions against Instacart product requirements.

“The evaluation part is really key. Uh so having a robust automated evaluation pipeline was important.”transcript, stated
“We used LLM as a judge in order to make this happen”transcript, stated

Tradeoffs

Use LLMs with domain context for query understanding.

Chose LLM predictions constrained by Instacart behavior data over Open-ended LLM category generation.

Rationale: Domain context aligned outputs with actual shopping intent and improved tail-query precision and recall.

“we took the most commonly converting categories or the top K converting categories for each query and fed that as additional context”transcript, stated
“Our precision improved by our 18 percentage points and our recall improved by our 70 percentage points”transcript, stated

Precompute frequent-query LLM outputs offline.

Chose Batch mode plus cache/feature-store serving over Online LLM calls for all queries.

Rationale: This preserved low-latency serving while still improving long-tail coverage and discovery content.

“It's impractical to call the LLM in real time because of latency and maybe cost concerns sometimes.”transcript, stated
“online when a query comes in we could just serve it off of the cache with very low impact on latency”transcript, stated

Use a hybrid model portfolio instead of consolidating immediately.

Chose Existing models, cached LLM outputs, and distilled Llama exploration over One unified LLM/SLM for all query understanding immediately.

Rationale: The source says model consolidation may improve consistency, but the production design still uses hybrid fallback while replacements are explored.

“consolidating all of these into an SLM or a or maybe a large language model uh can make the results a lot more consistent.”transcript, stated
“we're actually trying to replace them with a distilled lama model”transcript, stated

Gotchas (what bit them)

General LLM world knowledge conflicted with grocery-user intent.

Root cause: The LLM interpreted queries semantically in the general world rather than through Instacart shopping behavior.

Resolution: Inject top converting categories, query annotations, and subsequent-user-query metadata into prompts.

“the LLM doesn't truly understand Instacart user behavior was really the cause of the problem.”transcript, stated
“we augmented the prompt with Instacart domain knowledge.”transcript, stated

Tail queries lacked enough engagement data for existing models.

Root cause: Traditional models depended on engagement/co-occurrence signals that were sparse in the long tail.

Resolution: Use LLM world knowledge combined with Instacart context and explore distilled Llama models for long-tail replacement.

“we had really low coverage for our tail queries because again, we just didn't have enough engagement data to train the models on.”transcript, stated
“we're actually trying to replace them with a distilled lama model uh so that we can actually do a much better job compared to the existing models.”transcript, stated

LLM-generated content that looked good did not necessarily drive engagement.

Root cause: Common-sense generated lists were not what users were actually looking for.

Resolution: Rework prompts with Instacart-specific metadata, ranking, business metrics, and evaluation checks.

“the results were good but users weren't engaging it as much as we would have liked it”transcript, stated
“while LLM's answers uh were like common sense like answers and so on and such they weren't really what users were looking for”transcript, stated

Evaluation

Instacart evaluated query/category models through online A/B testing, downstream retrieval and ranking impact, tail-query precision and recall, engagement and revenue for discovery content, and LLM-as-judge checks for hallucination and product fit.

Metrics: online A/B test results · 18 percentage point precision improvement · 70 percentage point recall improvement · engagement · revenue · ranking recall · LLM-as-judge content evaluation

3 supporting quotes
“when we actually ran an online AB test the results weren't as great.”transcript, stated
“Our precision improved by our 18 percentage points and our recall improved by our 70 percentage points”transcript, stated
“we definitely saw like a huge improvement in both engagement as well as revenue.”transcript, stated

Outcomes

Instacart's query-category taxonomy has about 10,000 labels, with about 6,000 commonly used, and the serving strategy separates head/torso batch caching from long-tail fallback.

3 supporting quotes
“Our precision improved by our 18 percentage points and our recall improved by our 70 percentage points”transcript, stated
“we definitely saw like a huge improvement in both engagement as well as revenue.”transcript, stated
“evaluating the content as well as the cure predictions and so on as such was far more important and far more difficult uh than we anticipated.”transcript, stated