# From Scoring to Spelling: Rebuilding Ads Retrieval at Instacart

DevFeed: [From Scoring to Spelling: Rebuilding Ads Retrieval at Instacart](<https://devfeed.tech/articles/from-scoring-to-spelling-rebuilding-ads-retrieval-at-instacart-20105.md>)

Original publisher: [Read original article](<https://tech.instacart.com/from-scoring-to-spelling-rebuilding-ads-retrieval-at-instacart-cf36b4e8d1bb?source=rss----587883b5d2ee---4>)

Author: Karuna Ahuja

Published: 2026-06-02T18:50:19Z

Content type: article

Language: en

Sources: [Instacart](<https://devfeed.tech/sources/instacart.md>)

Topics: [Transformer](<https://devfeed.tech/topics/transformer.md>), [recommendations](<https://devfeed.tech/topics/recommendations.md>), [systems](<https://devfeed.tech/topics/systems.md>), [context](<https://devfeed.tech/topics/context.md>), [real-time](<https://devfeed.tech/topics/real-time.md>)

Tags: [bert](<https://devfeed.tech/tags/bert.md>), [context](<https://devfeed.tech/tags/context.md>), [generative](<https://devfeed.tech/tags/generative.md>), [inference](<https://devfeed.tech/tags/inference.md>), [machine-learning](<https://devfeed.tech/tags/machine-learning.md>), [model](<https://devfeed.tech/tags/model.md>), [real-time](<https://devfeed.tech/tags/real-time.md>), [recommendation-system](<https://devfeed.tech/tags/recommendation-system.md>), [recommendations](<https://devfeed.tech/tags/recommendations.md>), [retrieval](<https://devfeed.tech/tags/retrieval.md>)

## AI overview

Instacart describes rebuilding its ads retrieval system by moving from a product-scoring encoder to a generative model that predicts product IDs token by token. The system uses contextual shopping sessions and a BERT-like transformer to retrieve sponsored and organic recommendations.

## Source excerpt

Key Contributors: Karuna Ahuja, Marko Avdalovic, Soroush Sobhkhiz, Shrikar Archak, Xiyu Wang, Ji Chao Zhang, Hao Yan Introduction Every time a user opens Instacart, they see product recommendations: on the retailer home page, in search results, and alongside their cart. Many of these recommendations are sponsored products surfaced by a retrieval model that decides which products to show from a vast ads product catalog. A relevant ad helps users discover products they didn't know they needed; a less relevant one generates friction. Two years ago, we introduced Contextual Recommendations (CR), a BERT-based sequence model powering retrieval for both ads and organic recommendations across all major browse surfaces. In this post, we'll focus on our ads retrieval. We will detail how we rebuilt the system, by moving from an encoder that scores products to a generative model that spells them out, token by token. By doing so, we unlocked a new level of contextual matching -- ensuring brands appear exactly when users want them, while simultaneously opening up discovery of thousands of relevant products the previous system couldn't retrieve. Contextual Recommendations: A recap At its core, CR treats grocery shopping as a language modeling task, where atomic product IDs function as tokens and, the finite subset of the catalog it is trained on, acts as its 'vocabulary'. The model leverages the user's real-time session, which includes product views, item page visits, and cart additions, as a sequence of these product tokens. A BERT-like transformer is then trained on millions of authentic shopping sessions to predict the next token (i.e. singular product) in the sequence. This process allows the model to learn and capture complex purchasing patterns, such as the tendency for users who add pasta and olive oil to frequently add garlic next. This single retrieval layer replaced multiple ad-hoc systems and powers recommendation carousels across all major browse surfaces, serving both