Recommendation, Search, Retrieval, and Ranking: Modern Architectures for Relevant AI Systems (in late 2026)

Primary references:

Modern search and recommendation systems are moving beyond a single embedding similarity score. Production systems increasingly combine structured query understanding, hard metadata filtering, semantic retrieval, learned ranking, catalog constraints, and personalization.

This document covers three complementary patterns:

  1. Retrieve-for-Train: compile expensive retrieval reasoning into a lightweight, single-pass retriever.
  2. Search-expert: convert natural-language queries into structured filters before semantic retrieval.
  3. GenRec: use an LLM-backed ranker with catalog-aware scoring for large-scale recommendation.

A note on source coverage: the ACM paper, several arXiv papers, LinkedIn engineering posts, Pinterest and Instacart posts, Spotify research, and Perplexity Photon links provided could not be fully verified from their primary pages in this pass. This document therefore focuses in depth on the three accessible primary sources above and treats the remaining links as a reading list rather than as verified technical claims.


Part 1: Foundations

Search versus recommendation

Search and recommendation solve related but different problems.

Dimension Search Recommendation
Primary input Explicit user query User history, context, and candidate inventory
Primary goal Satisfy the stated intent Maximize long-term user value
Typical output Ranked results for a query Personalized ranked slate
Hard constraints Often explicit: price, color, availability Often business or policy constraints
Main challenge Interpreting intent correctly Balancing relevance, diversity, and long-term satisfaction
Feedback signal Clicks, conversions, reformulations Plays, watch time, saves, skips, retention

A search query such as “noise cancelling headphones any colour but black, under $300, with a 4 star rating” contains both semantic intent and hard constraints. A recommendation request may contain no explicit query at all, but must still respect catalog, business, and personalization constraints. sarthakai.substack

The modern retrieval stack

A common production pattern is:

Natural-language query
        |
        v
+---------------------------+
| Query understanding       |
| - intent                  |
| - entities                |
| - filters                 |
| - language                |
| - reformulation           |
+-------------+-------------+
              |
              v
+---------------------------+
| Structured pre-filtering  |
| - price                   |
| - color                   |
| - availability            |
| - category                |
+-------------+-------------+
              |
              v
+---------------------------+
| Semantic retrieval        |
| - vector search           |
| - lexical search          |
| - hybrid retrieval        |
+-------------+-------------+
              |
              v
+---------------------------+
| Ranking / reranking       |
| - relevance               |
| - personalization         |
| - business constraints    |
| - diversity               |
+-------------+-------------+
              |
              v
       Ranked results

This pipeline separates concerns:

  • Query understanding decides what the user means.
  • Filtering enforces non-negotiable constraints.
  • Retrieval finds semantically relevant candidates.
  • Ranking orders candidates using relevance, personalization, and business objectives.

Search-expert frames this as structured pre-filtering followed by approximate nearest-neighbor vector search and a learning-to-rank reranker. sarthakai.substack


Part 2: Query Understanding as Structured Extraction

The problem

Natural-language queries often contain implicit filters that a semantic retriever may treat as soft preferences rather than hard rules.

For example:

noise cancelling headphones any colour but black, under $200 and over 4 stars

A pure vector-search system may return semantically similar headphones that are black, cost more than $200, or have a rating below 4 stars. The embeddings capture meaning, but they do not naturally enforce constraints.

Search-expert addresses this by converting the query into structured fields before retrieval:

{
  "product": "headphones",
  "feature": "noise cancelling",
  "color": ["ne:black"],
  "price": "lt:200",
  "rating": "gte:4"
}

The structured output uses explicit operators such as lt:, gte:, ne:, and between:100:200, so downstream systems can translate it into filters for Elasticsearch, SQL, ChromaDB, Pinecone, or another backend. sarthakai.substack

Why structured extraction matters

Structured extraction enables a hybrid retrieval pipeline:

Natural-language query
        |
        v
Structured extraction
        |
        v
Hard metadata filters
        |
        v
Vector search within filtered candidates
        |
        v
Semantic ranking
        |
        v
Ranked results

The hard filters ensure that a $400 product is not returned when the user asked for “under $200.” Vector search then ranks the surviving candidates by semantic relevance. sarthakai.substack

Search-expert design

Search-expert is an 800M-parameter small language model, search-expert-json-0.8b, fine-tuned from Qwen3.5-0.8B using LoRA. It converts a natural-language search query into structured JSON. sarthakai.substack

Property Value
Base model Qwen3.5-0.8B
Model size 800M parameters
Fine-tuning method LoRA
LoRA rank 16
LoRA alpha 16
Trainable parameters 0.74%
Quantization 4-bit NF4
Approximate VRAM footprint 1–2 GB
Training framework Unsloth FastLanguageModel
Training data 100,000 synthetic query-structured-output pairs
Domains E-commerce, real estate, flights, hotels, jobs, cars, restaurants, movies, healthcare, courses
Reported key F1 0.913
Reported parse rate 98.2%

The model is trained to output only fields explicitly present in the query, reducing hallucinated fields. A separate LoRA adapter is trained for each serialization format, such as JSON or YAML. sarthakai.substack

Training configuration

The published training setup uses: sarthakai.substack

Effective batch size:       16
Per-device batch size:      8
Gradient accumulation:      2
Training steps:             300
Learning-rate schedule:     Cosine
Warmup steps:               100
Peak learning rate:         2e-4
Optimizer:                  AdamW 8-bit
Maximum sequence length:    512 tokens
Sequence packing:           Enabled

LoRA adapters are injected into:

q_proj
k_proj
v_proj
o_proj
gate_proj
up_proj
down_proj

This is a practical demonstration that a small, domain-specialized model can perform constrained structured extraction reliably. The author explicitly argues that the task is bounded enough that a purpose-trained small model can outperform a general-purpose large model in cost, speed, and consistency. sarthakai.substack

Constraint-satisfaction benchmark

Search-expert was evaluated on 25 complex, multi-constraint Amazon search queries. The evaluation measured whether the top six results satisfied the user’s hard constraints. sarthakai.substack

Pipeline Overall constraint satisfaction Perfect@6
Hybrid: search-expert plus filtered vector search 1.00 1.00
Amazon search 0.76 0.42
Pure vector search 0.56 0.21

The hybrid pipeline achieved perfect price satisfaction, color exclusion, and color match across the evaluated queries. Pure vector search performed worst because embedding similarity treats constraints such as color and price as soft semantic signals rather than enforceable rules. sarthakai.substack

These results are specific to the author’s benchmark, query set, product pool, and retrieval configuration. They should not be generalized as universal superiority over any production search engine.

Search-expert draws an important distinction:

Approach Strength Limitation
Text-to-SQL Exact lookup over structured data Does not rank by semantic relevance
Pure vector search Understands unstructured meaning Treats hard constraints as soft signals
Hybrid retrieval Enforces constraints, then ranks semantically Requires query understanding and more infrastructure

The production pattern is therefore:

structured extraction
→ hard metadata filters
→ vector search within filtered set
→ semantic ranking

Search is not merely “which rows match?” It is “which items are most relevant?” Relevance includes both structured constraints and unstructured meaning. sarthakai.substack


Part 3: Retrieve-for-Train

The inference bottleneck

Complex AI search often requires query fan-out: breaking one broad prompt into several related sub-queries to retrieve a coherent set of results.

For example, a query such as “camping gear” should not return ten slight variations of four-person tents. It should return a complementary slate: a tent, sleeping bag, portable stove, and headlamp. research

Google Research identifies two problems with using a general LLM for this at inference time:

  1. Paraphrastic collapse: the model generates near-synonymous queries instead of complementary facets.
  2. Autoregressive latency: the model spends a large thinking budget generating intermediate reasoning tokens before producing search terms. research

For example, given “Bohemian festival style,” a zero-shot LLM may generate:

- bohemian festival fashion
- bohemian festival clothes

These are redundant paraphrases. A more useful fan-out might include distinct facets such as:

- fringe jackets
- crochet dresses
- suede boots

The second set covers complementary dimensions of the original intent. research

Retrieve-for-Train idea

Retrieve-for-Train moves the expensive exploration offline. Instead of forcing an LLM to reason at inference time, it uses offline reinforcement learning once to learn reward-aligned query fan-outs, then distills that behavior into a lightweight retriever. research

Broad query
     |
     v
+---------------------------+
| Fan-out language model    |
| Trained once with RL      |
+-------------+-------------+
              |
              v
+---------------------------+
| Supervision synthesis     |
| query -> target-set pairs |
+-------------+-------------+
              |
              v
+---------------------------+
| Diffusion retriever       |
| Single-pass fan-out       |
+-------------+-------------+
              |
              v
      Set of target embeddings

This is a conceptual reconstruction of the three-step framework described by Google Research. research

Three-stage pipeline

Stage Purpose Output
Fan-out language model training Learn property-aligned sub-queries with reinforcement learning Fan-out language model
Supervision synthesis Generate query-to-target-set pairs offline Supervision data
Diffusive retriever training Learn to map query embeddings to target embeddings Lightweight diffusion retriever

The fan-out language models used were 4B open-source models: Gemma3-4B and Qwen3-4B. Each generated exactly 10 sub-queries for every main search prompt. research

The final diffusion retriever has 53.9M parameters and maps a query embedding directly to a complete set of target embeddings in one non-autoregressive pass. research

Set-level rewards

Traditional learning-to-rank evaluates items independently. Retrieve-for-Train optimizes properties that exist only at the set level.

The composite reward balances: research

Property Meaning Failure it prevents
Groundedness Generated sub-queries correspond to retrievable database items Nonsense strings that exploit embedding coordinates
Diversity The sub-query set covers broad semantic breadth Repetitive paraphrases
Alignment Sub-queries remain related to the original prompt Semantic drift

Diversity is measured using the Vendi Score over the entire set of sub-queries. research

These rewards act as mutual counter-anchors:

  • Groundedness alone can reward degenerate strings.
  • Alignment alone can reward repetitive paraphrases.
  • Diversity forces the model to explore distinct, useful directions. research

Training method

Google Research uses Soft-GRPO, combining group relative policy optimization with soft proximal policy optimization regularization. The fan-out language model is optimized against the composite reward. research

The important architectural insight is that reinforcement learning is used as a one-time objective transducer, not as an online inference engine. The expensive reward-driven exploration happens during training; the deployed retriever performs a fast single-pass mapping. research

Results

Retrieve-for-Train was evaluated on:

  • Open-ended abstract retrieval, where quality is measured by set-level properties such as diversity, alignment, and groundedness.
  • Weakly supervised compositional retrieval, where queries are paired with a weak reference set. research

The evaluation used:

  • A fashion dataset of user-curated outfits, evaluated with a CLIP-based retriever.
  • A proprietary industrial dataset of expert-generated music playlists, evaluated with MuLan. research

Reported results:

Outcome Retrieve-for-Train result
Retrieval quality Outperformed single-query search, zero-shot expansion, and Best-of-N baselines
Inference speed 12 to 20 times faster than autoregressive approaches
Large-batch latency Autoregressive fan-out approached 50 seconds; diffusion remained sub-second to a few seconds
Model size Final diffusion retriever: 53.9M parameters
Fan-out models Gemma3-4B and Qwen3-4B
Sub-queries per prompt 10

These results are from Google Research’s described experiments and should be interpreted in the context of their datasets, embedding backbones, and retrieval tasks. research

Why this matters

Retrieve-for-Train shows that expensive reasoning does not need to happen at inference time. A system can use a large model and reinforcement learning offline to discover good behavior, then compile that behavior into a much smaller, faster model.

This is analogous to using a teacher model offline and deploying a student model online:

Large reasoner + reward model
        |
        | offline training
        v
Compact retriever
        |
        | online inference
        v
Fast, property-aligned retrieval

Part 4: GenRec and LLM-Native Recommendation

The recommendation problem

Netflix’s GenRec addresses full-catalog ranking: given a user $u$, interaction history $H$, current context $\tau$, and time $t$, produce a ranking $\pi$ over catalog items $C$. netflixtechblog

Formally:

\[(u, \tau, t, H) \rightarrow \pi\]

where $\pi(i)$ is the position assigned to item $i$. The objective is expected long-term member utility, not merely short-term engagement. netflixtechblog

Why traditional recommenders become complex

Netflix describes its prior production stack as relying on thousands of hand-crafted features over users, items, and interactions, plus specialized architectures for sequence modeling, feature interactions, and multi-task objectives. Adding a new content type or surface can require substantial feature engineering, architecture change, infrastructure work, and experimentation. netflixtechblog

LLMs offer a different approach: represent user histories and item metadata as text, capture relationships in a shared semantic space, and steer behavior through natural-language prompts. netflixtechblog

However, off-the-shelf LLMs are not production recommenders. Netflix identifies four issues:

  • Over-recommending globally popular content.
  • Hallucinating out-of-catalog items.
  • Ignoring business constraints.
  • Providing limited personalization. netflixtechblog

GenRec architecture

GenRec is an LLM-backed recommendation ranker. It post-trains an internal foundation LLM on Netflix-specific data and objectives, then adds a catalog-aware scoring head. netflixtechblog

User history + context + item metadata
                 |
                 v
        [ Verbalized context ]
                 |
                 v
        [ Foundation LLM backbone ]
                 |
                 v
        [ Catalog-aware scoring head ]
                 |
                 v
        In-catalog item scores
                 |
                 v
        Personalized ranking

At inference time, GenRec feeds verbalized context into the model and applies the catalog-aware scoring head. It does not decode assistant messages. The conversational format is primarily a training-time device to preserve language understanding. netflixtechblog

Two-phase training

GenRec uses a two-phase framework. netflixtechblog

Phase Purpose Update frequency
Phase 1 Adapt an open-source LLM on proprietary corpora to create a domain-aware backbone Relatively infrequent
Phase 2 Post-train the backbone on ranking-specific data and objectives More frequent

Netflix members generate hundreds of billions of interaction events across surfaces, including views, plays, durations, thumbs up or down, add-to-list actions, and abandons. These logs are converted into single-turn or multi-turn conversations between a user and a recommender. netflixtechblog

Context engineering

Naively verbalizing every interaction would exceed the token budget. Netflix treats the context window as a new feature budget and applies context engineering. netflixtechblog

The approach is:

  • Prioritize recent, high-signal history.
  • Compress or drop older history.
  • Structure prompts to maximize shared prefixes.
  • Enable better prefix caching.
  • Preserve ranking quality while reducing serving cost. netflixtechblog

In experiments, Netflix reduced context tokens to roughly one-third of the original budget with negligible degradation in offline ranking metrics. Because serving cost is approximately proportional to context length, serving cost fell similarly. netflixtechblog

Training objectives

GenRec uses a multi-objective loss combining: netflixtechblog

  • A recommendation ranking objective.
  • Language-modeling objectives.
  • Alignment through reward-weighted training.

The ranking objective uses cross-entropy over the catalog or candidate set. Positives are derived from high-value engagements, such as sufficiently long plays or strong explicit feedback, with thresholds and denoising logic. netflixtechblog

The language-modeling objective preserves general language understanding and keeps open the possibility of text-generation use cases such as recommendation explanations. netflixtechblog

Reward-weighted alignment

Training only on raw interaction sequences can cause undesirable behavior, such as over-favoring binge-watching or over-focusing on one content type. GenRec weights the ranking loss using signals from separate reward models. netflixtechblog

\[\mathcal{L}_{weighted} = w_i \cdot \mathcal{L}_{ranking}^{(i)}\]

where:

  • $w_i$ is a scalar reward-derived weight for example $i$.
  • $\mathcal{L}_{ranking}^{(i)}$ is the ranking loss for that example.

High-value engagements receive larger weights; low-value engagements are down-weighted. Netflix describes this as simpler and more cost-efficient than full reinforcement learning, while noting that RL-style methods such as GRPO produced additional gains but were deferred due to cost. netflixtechblog

Catalog-aware scoring

GenRec’s architecture follows its foundation LLM: a decoder-only transformer trained with next-token-prediction-style objectives, augmented with a catalog-aware ranking head. The scoring head scores only in-catalog items. netflixtechblog

For very large catalogs, sampled softmax or candidate sets can make training and inference efficient. This constrains recommendations to the catalog while supporting efficient scoring over large candidate sets. netflixtechblog

Results

Netflix reports: netflixtechblog

Evaluation Result
Offline ranking GenRec outperformed the production ranker despite fewer input signals and labeled examples
Data efficiency About 40 times fewer Phase-2 labeled examples
Offline MRR About +1.6% improvement
Online test Statistically significant short-term and long-term gains
Traffic coverage About 10% of Netflix traffic
Test duration About 4 weeks

These results apply to Netflix’s production baseline, traffic, catalog, and evaluation setup. They demonstrate the potential of LLM-backed rankers, not a universal guarantee that an LLM ranker will outperform every existing recommender. netflixtechblog

The broader shift

Netflix frames GenRec as a shift from feature engineering to context engineering. netflixtechblog

Traditional RecSys LLM-native RecSys
Dense feature vectors Verbalized textual context
Hand-crafted features Context construction from logs and metadata
Task-specific architectures Shared foundation backbone
Sparse IDs and custom objectives Data, verbalization, objectives, and rewards
Classic RecSys infrastructure LLM-style GPU infrastructure, batching, and caching

The prompt becomes a new kind of feature vector. Modeling effort shifts from designing features to deciding which signals to include, how far back in time to go, and how to compress history within a token budget. netflixtechblog


Part 5: Cross-Cutting Design Patterns

Pattern 1: Separate hard constraints from soft relevance

A semantic model should not be responsible for enforcing every business rule.

User query
     |
     +-- hard constraints --> deterministic filters
     |
     +-- semantic intent ---> vector retrieval
     |
     +-- ranking signals ---> learned ranker

Search-expert demonstrates this clearly: structured extraction enables hard filtering before semantic ranking. sarthakai.substack

Pattern 2: Move expensive reasoning offline

A large model can explore, plan, and optimize during training. The deployed model should be as small and fast as the quality bar allows.

Retrieve-for-Train uses offline reinforcement learning to discover good fan-out behavior, then distills it into a 53.9M-parameter diffusion retriever. research

Pattern 3: Use catalog-aware constraints

LLMs can hallucinate out-of-catalog items. Recommendation and search systems should constrain outputs to valid, available, and business-approved candidates.

GenRec uses a catalog-aware scoring head that scores only in-catalog items. netflixtechblog

Pattern 4: Treat context as a budget

Long histories improve potential signal but increase cost. Context engineering is the process of choosing, compressing, ordering, and prioritizing context within a token budget.

Netflix reduced context tokens to about one-third of the original budget with negligible offline ranking degradation. netflixtechblog

Pattern 5: Optimize sets, not just items

A good result slate is not merely a list of individually relevant items. It should be diverse, complementary, coherent, and grounded.

Retrieve-for-Train optimizes set-level properties such as diversity, alignment, and groundedness using a composite reward. research


Part 6: Architecture Comparison

System Primary task Core mechanism Key innovation Main trade-off
Search-expert Query understanding Natural language to structured filters Small fine-tuned model for constrained extraction Requires high-quality domain-specific training data
Retrieve-for-Train Set-valued retrieval RL-trained fan-out distilled into diffusion retriever Single-pass set-level retrieval More complex training pipeline
GenRec Recommendation ranking LLM backbone plus catalog-aware scoring head Verbalized context and reward-weighted ranking Higher serving cost and context-management complexity

When to use each pattern

Need Recommended pattern
Enforce price, color, rating, or availability constraints Structured extraction plus hard filtering
Improve semantic relevance after filtering Vector or hybrid retrieval
Produce diverse, complementary result slates Set-level retrieval and fan-out
Reduce inference-time reasoning cost Offline RL plus distillation
Rank a large catalog with rich user history LLM-backed ranker with catalog-aware scoring
Control recommendation cost Context engineering and candidate-set scoring
Avoid out-of-catalog hallucination Catalog-aware scoring head

Part 7: Evaluation

Retrieval and search metrics

Metric Measures
Recall@K Whether relevant items appear in the top K
Precision@K Whether top K results are relevant
MRR Average reciprocal rank of the first relevant result
NDCG@K Ranked relevance quality
Constraint satisfaction Whether results satisfy explicit user constraints
Perfect@K Whether every result in top K satisfies all applicable constraints
Diversity Semantic breadth of the result set
Coverage Whether the result set covers distinct facets

Search-expert’s benchmark emphasizes constraint satisfaction and Perfect@6, which are useful when user queries contain non-negotiable filters. sarthakai.substack

Recommendation metrics

Metric Measures
MRR Quality of the first relevant recommendation
NDCG Ranked relevance quality
Recall@K Coverage of relevant items
Engagement rate Immediate interaction
Long-term retention Sustained user value
Catalog coverage Breadth of recommended inventory
Business-mix compliance Whether content-type or policy constraints are respected

GenRec optimizes for expected long-term member utility rather than only short-term engagement. netflixtechblog

Offline versus online evaluation

Offline metrics are necessary but insufficient. A model can improve offline ranking metrics while producing worse long-term user outcomes because of feedback loops, popularity bias, or exposure bias.

GenRec was validated with both offline ranking metrics and a large-scale online A/B test covering about 10% of Netflix traffic for roughly four weeks. netflixtechblog


Part 8: Limitations and Open Questions

Query understanding

  • Structured extraction models can fail on unseen fields, novel phrasing, or underrepresented domains.
  • A small model may not generalize across many verticals without domain-specific data.
  • Hard filters can reduce recall if query understanding is wrong.
  • Multilingual and code-switched queries require dedicated evaluation.

Search-expert’s author notes that the current model covers 10 domains and identifies smaller models, training from scratch, more domains, and a reranking layer as future directions. sarthakai.substack

Set-valued retrieval

  • Set-level rewards are harder to define than pointwise relevance.
  • Diversity objectives can conflict with alignment and groundedness.
  • Reward hacking is a real risk when optimizing against database geometry.
  • Diffusion-based retrieval requires appropriate embedding backbones and evaluation infrastructure.

Google Research found that removing the diversity term allowed the fan-out model to collapse into degenerate strings that exploited vector coordinates. The Vendi Score acted as a counter-anchor. research

LLM-native recommendation

  • LLM rankers can be expensive at scale.
  • Context length drives both quality and serving cost.
  • Raw interaction data can reinforce popularity bias or undesirable behavior.
  • Reward-weighted training is simpler than full RL but may not capture all long-term objectives.
  • Catalog constraints are essential to prevent out-of-catalog hallucination.

Netflix explicitly notes that off-the-shelf LLMs often over-recommend popular content, hallucinate out-of-catalog items, ignore business constraints, and provide limited personalization. netflixtechblog


Part 9: Practical Design Checklist

  • Extract hard constraints before semantic retrieval.
  • Use deterministic filters for price, availability, region, rating, and policy rules.
  • Use vector or hybrid retrieval for semantic relevance.
  • Use a reranker for final ordering.
  • Optimize result sets for diversity and complementarity, not only individual relevance.
  • Keep expensive reasoning offline when possible.
  • Distill complex behavior into a small, fast serving model.
  • Constrain recommendation outputs to the valid catalog.
  • Verbalize only high-signal context within a token budget.
  • Use reward weighting to align ranking with long-term value.
  • Evaluate constraint satisfaction, ranking quality, calibration, latency, cost, and online business metrics.
  • Run online experiments before replacing a mature production system.

Resources


Final Technical Takeaways

  • Central mechanism: Modern retrieval systems combine query understanding, hard filtering, semantic retrieval, and learned ranking into one pipeline.
  • Main architectural insight: Do not ask one model to do everything. Use structured extraction for constraints, retrieval for candidate generation, and ranking for final ordering.
  • Important efficiency insight: Expensive reasoning can be moved offline and distilled into a much smaller inference model; Retrieve-for-Train distills RL-trained fan-out behavior into a 53.9M-parameter diffusion retriever with a reported 12–20 times speedup. research
  • Important relevance insight: Vector similarity alone does not enforce hard constraints; structured pre-filtering plus semantic ranking can materially improve constraint satisfaction. sarthakai.substack
  • Important recommendation insight: LLMs can act as rankers, but they need catalog-aware scoring, business constraints, and carefully engineered context to avoid hallucination and popularity bias. netflixtechblog
  • Main trade-off: More context, more reasoning, and larger models can improve quality, but they increase latency, cost, and operational complexity.
  • Broader engineering implication: Treat the prompt, context, candidate set, and reward signal as first-class system components—not merely as implementation details around a model.

This site uses Just the Docs, a documentation theme for Jekyll.