Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Meta Engineering 9 min read Case study mediumAdept

Scaling the Instagram Explore recommendations system

Instagram Explore uses a four-stage funnel of retrieval, first-stage ranking, second-stage ranking and final reranking, built around caching and pre-computation so heavier models can be used at every stage. Two Tower neural networks with cached user and item embeddings and ANN search handle retrieval, and they also serve as a lightweight first-stage ranker distilled from the heavy second stage. The second stage is a multi-task multi-label model whose engagement probabilities are combined by a tunable weighted value model, with some recommendations precomputed off-peak. Final reranking applies integrity filters and diversity rules, and the system's hundreds of parameters are tuned by online Bayesian optimization or by faster offline tuning that maps offline metrics to online ones.

Assumes: neural network basicsembeddingsapproximate nearest neighbor search

Related posts

  • Beyond Two Towers: Launching the 3-Tower Engagement Co-Train Model (Part 2)

    Pinterest Engineering hardMaster

    Pinterest's ads lightweight ranking adds a third cross tower to its two-tower engagement model. The cross tower runs cross-attention between user sequences and candidate-derived query tokens, and a shared-bottom inter module jointly predicts CTR, gCTR30 and oCTR. Co-training keeps a fast two-tower head that scores all candidates, and the three-tower path rescores only a utility top-K subset. The three-tower predictions cut offline loss by about 30%. Serving optimizations brought P99 inference from over 200 ms to about 30 ms: caching Pin preprocessing in the Pin tower, BF16, late expansion of user features, and pre-layer normalization.

  • ML based ranking using Nrtsearch

    Yelp Engineering mediumAdept

    Yelp moved ML-based ranking out of a standalone scoring service and into Nrtsearch, its Lucene-based search engine, via an Inference Plugin that extracts features from indexed documents and request parameters and scores them in-process on replica nodes. The change removes the network transfer and feature-payload overhead that became a bottleneck with large candidate sets. MLeap models such as XGBoost and neural networks are stored in MLflow and loaded at replica bootstrap. Teams either implement a Java scorer interface or use a generic scorer that defines features with Lucene expressions. Models are hot-swapped node by node via Jenkins without restarts, scorer changes go through canary and rolling restarts, and Prometheus metrics track model latency and errors.

  • Our Early Journey to Transform Instacart’s Discovery Recommendations with LLMs

    Instacart Tech mediumAdept

    Instacart rebuilt its Shopping Hub discovery recommendations around a top-down, cascaded LLM pipeline. It first generates personalized page themes, then taxonomy-grounded retrieval keywords, then applies quality and diversity filtering, and finally hands off to existing product and pagewise ranking services. Keyword generation uses a teacher-student fine-tuned open-weight model (Llama/Qwen with LoRA ablations). It also uses RAG that prunes a 300,000-term keyword corpus to about 100 nearest neighbors per theme, which cut generation costs 15–20%. Quality is enforced through embedding-based deduplication, LLM-as-a-judge evaluators calibrated with human-in-the-loop data, and a fine-tuned cross encoder for theme-product relevance at scale.

  • Adapting the Facebook Reels RecSys AI Model Based on User Feedback

    Meta Engineering mediumAdept

    Facebook Reels added a User True Interest Survey (UTIS) model that learns from in-feed survey responses asking how well a video matches the viewer's interests, instead of relying only on engagement signals like likes and watch time. A lightweight "perception layer" is trained on binarized, bias-weighted survey responses, using the main multi-task ranker's predictions as features. Its output feeds late-stage ranking as a value-formula input and drives retrieval through re-ranked interest profiles and knowledge distillation. Offline, precision rose from 48.3% to 63.2% and recall from 45.4% to 66.1% over heuristics, and A/B tests with over 10M users showed +5.2% engagement and +5.4% high survey ratings.

  • Bypassing inference bottlenecks: Accelerating complex AI search with Retrieve-for-Train

    Google Research hardMaster

    Retrieve-for-Train replaces expensive inference-time LLM reasoning for query fan-out with a one-time offline RL stage. A 4B fan-out language model (Gemma3-4B or Qwen3-4B) is trained with Soft-GRPO on a composite set-level reward that combines groundedness to the database manifold, Vendi Score diversity and query alignment. The trained model then synthesizes query-to-target-set pairs, which are distilled into a 53.9M-parameter diffusion retriever that produces a whole slate of target embeddings in one non-autoregressive pass. On fashion (CLIP) and music playlist (MuLan) retrieval it beats zero-shot expansion and Best-of-N, with a 12–20x speedup, staying at sub-second to a few seconds where autoregressive fan-out reaches nearly 50 seconds. Ablations show that without the diversity term the policy reward-hacks into degenerate strings.

The quest for software engineering knowledge.

Look:
Layout: