AI Infra
0%
Part 0 · Chapter 4

The Infrastructure Before This One

AuthorChangkun Ou
Reading time~15 min

Before generative models became a product category, machine learning already made high-volume decisions in search, advertising, recommendations, fraud detection, forecasting, and many other services. These systems built mature ways to retrieve candidates, manage features, deploy models, monitor drift, and run controlled experiments.

This chapter calls that body of work large-scale predictive ML. It is the closest operational predecessor to the generative stack, not a history of all earlier AI. The comparison answers three questions: which practices transferred, which ones had to change, and which systems remain outside this book's scope.

One request through the older stack

The scale was already substantial. In one Facebook production datacenter studied before the generative-model buildout, recommendation models accounted for more than 79% of AI inference cycles (Gupta et al. 2020). A separate study reported that recommendation consumed more than half of the company's AI training cycles (Acun et al. 2021). These figures describe Facebook's measured workloads, not every datacenter, but they show that production AI was already dominated by systems choosing what to display next.

A large recommender cannot carefully score every item for every request. The usual solution is a funnel:

  1. Candidate generation quickly reduces a large catalog to a manageable set.
  2. Ranking applies a richer model to that set and orders the results.
  3. Logging and experimentation record what was shown and what happened next.

YouTube's 2016 system is a well-documented example: a candidate model reduced millions of videos to hundreds, then a ranking model selected a few dozen for display (Covington et al. 2016). The exact architecture varies by product, but the reason for separating retrieval from ranking is stable. The expensive model only runs on a small candidate set.

Embedding retrieval gives the first stage a simple formula:

ai=euTei,Ck(u)=TopKiI(ai).a_i=e_u^{\mathsf T}e_i, \qquad C_k(u)=\operatorname{TopK}_{i\in\mathcal I}(a_i).

The ranker then computes

i^1,,i^m=SortiCk(u)rψ(u,i,zi).\hat{i}_1,\ldots,\hat{i}_m =\operatorname{Sort}_{i\in C_k(u)} r_\psi(u,i,z_i).

Here uu is the current user or request, ii is an item in catalog I\mathcal I, and eu,eiRde_u,e_i\in\mathbb{R}^d are dd-dimensional learned vectors called embeddings. Their dot product aia_i is the retrieval score. Ck(u)C_k(u) is the set of kk retrieved candidates. The second-stage model rψr_\psi, with parameters ψ\psi, uses request data and additional item features ziz_i to order mkm\leq k results.

Computing every aia_i is still too expensive for a very large catalog. Approximate nearest-neighbor (ANN) search avoids exhaustive scoring by trading some retrieval recall for lower latency and memory traffic. Systems such as FAISS support similarity search at billion-vector scale (Johnson et al. 2021), while HNSW organizes vectors as a navigable proximity graph and is widely implemented in search systems (Malkov and Yashunin 2020).

funnels cluster_rec recommendation cluster_rag retrieval-augmented generation R1 large item catalog R2 candidate retrieval embedding or term index R1->R2 R3 ranking richer features and model R2->R3 R4 ordered items and logged interactions R3->R4 G1 document chunks G2 retrieval embedding or term index G1->G2 G3 reranking and context construction G2->G3 G4 generated answer and evaluation signals G3->G4
Figure 4.1. Recommendation and retrieval-augmented generation share a narrowing pattern. The resemblance stops at the final operation and the feedback signal: one ranks items, while the other constructs context for generated output.

The figure shows a shared systems pattern, not an identical learning problem. A recommender ranker predicts or optimizes item outcomes. A retrieval-augmented generator uses retrieved evidence as input to an open-ended generation process. The retrieval machinery can transfer even though the final model, objective, and evaluation do not.

What transferred

Three parts of the older stack became foundations for generative systems.

Area Mature predictive-ML practice Adaptation in generative systems
Retrieval Embeddings, term indexes, approximate search, hybrid retrieval, and reranking Retrieve document chunks or tool results, then assemble context for a generator
Operations Reproducible data pipelines, versioned model artifacts, monitored inputs and outputs, staged rollouts, and rollback Version prompts, retrieval settings, tool schemas, and model combinations as one deployable system
Measurement Online controlled experiments, guardrail metrics, segment analysis, and long-horizon outcomes Combine task evaluations and safety checks with product experiments; do not treat immediate preference feedback as the complete objective

The operational inheritance is especially direct. Google's account of hidden technical debt showed that production failures often come from data dependencies, feedback loops, configuration, and surrounding code rather than from the model alone (Sculley et al. 2015). Uber's Michelangelo platform later standardized the full workflow: shared feature definitions, matching transformations for training and serving, versioned artifacts, deployment, and monitoring (Hermann and Del Balso 2017). TensorFlow Serving supplied versioned model loading, request batching, controlled rollout, and rollback (Olston et al. 2017). The objects changed in generative applications, but the need for lineage and safe rollout did not.

Measurement transferred with an important warning about time. Hohnhold et al. showed that users' future tendency to engage with ads depended on the relevance and landing-page quality of ads they had previously seen. Their long-term model led Google to increase the auction's emphasis on quality and cut mobile-search ad load by 50%, with neutral or positive long-run business impact (Hohnhold et al. 2015). In 2025, OpenAI rolled back a GPT-4o update that had become overly agreeable and wrote that it had focused too much on short-term feedback (OpenAI 2025). Clicks and thumbs-up signals are not the same mechanism. The shared lesson is narrower: immediate feedback can be a poor proxy for the outcome a product needs over time.

Offline improvement is not product improvement

The Netflix Prize remains a compact example of why production systems need more than an offline score. Netflix launched the competition in 2006 and offered one million dollars for a 10% improvement in rating-prediction accuracy. Two algorithms from the 2007 Progress Prize's 107-model ensemble were incorporated into the service. The additional methods in the later Grand Prize solution were not: Netflix reported that their accuracy gain did not justify the engineering work, while the product had also shifted from DVD rating prediction toward helping streaming viewers choose what to watch (Amatriain and Basilico 2012).

The episode separates three deployment gates:

  1. Offline quality: does a model improve the chosen test metric?
  2. Systems feasibility: can it meet cost, latency, reliability, and maintenance requirements?
  3. Product value: does the metric still represent the decision the product must make?

Later chapters apply the same distinction to benchmarks, model serving, and operational evaluation. A better offline number is evidence, not a deployment decision.

Why serving changed

The older operational discipline transferred, but its serving architecture was not a drop-in fit. The useful comparison is between representative workloads, not between all recommenders and all language models.

Dimension Embedding-heavy recommender Autoregressive language model
Main kernels Gather and pool selected embedding rows, then run dense interaction or ranking layers Prefill processes prompt tokens in parallel; decode repeatedly applies dense weights and attention one token at a time
Memory pressure Large embedding-table capacity, irregular accesses, sharding, and bandwidth; dense layers may still be compute-bound Weight bandwidth often limits low-batch decode; long contexts add growing KV-cache capacity and traffic
Request state Scoring replicas often fetch user and session features from shared stores, so state is external to the model server Each active generation retains attention state for its preceding tokens, usually on the accelerator
Output and latency A fixed-size score or ranked list, often under a tight request deadline A variable-length sequence, measured by time to first token and the cadence of later tokens
Scheduling consequence Independent requests can be routed freely and batched conventionally The scheduler must manage request affinity or state transfer, dynamic cache memory, and different sequence lengths

The first column describes models such as DLRM, which combine sparse categorical embeddings with dense interaction networks (Naumov et al. 2019). Which component dominates depends on the model, batch, and hardware. The second column also contains two regimes: prefill usually has higher arithmetic intensity, while decode at low or moderate batch sizes often moves model weights faster than it can reuse them (Pope et al. 2023).

The per-sequence attention state makes the serving difference concrete. Its approximate size is

MKV2LHKVdhSb.M_{\mathrm{KV}}\approx 2L H_{\mathrm{KV}}d_h S b.

Here MKVM_{\mathrm{KV}} is the key-value cache size in bytes, the factor 22 counts keys and values, LL is the number of transformer layers, HKVH_{\mathrm{KV}} is the number of key/value heads, dhd_h is each head's width, SS is the number of cached tokens, and bb is the number of bytes per stored element. The cache grows with every generated token. Grouped-query and multi-query attention reduce HKVH_{\mathrm{KV}}, but they do not remove the per-request state.

This growth forced new memory and scheduling mechanisms. PagedAttention maps non-contiguous cache blocks in a way analogous to virtual memory, reducing fragmentation and enabling sharing (Kwon et al. 2023). Iteration-level scheduling can then add and remove requests between decode steps. The older stack still contributes RPC, load balancing, batching, observability, staged deployment, and rollback; LLM serving adds a different state-management problem.

Constraint arrow

Hardware reflects the workload for which it was purchased. A fleet balanced for large sparse tables and irregular embedding lookups can run dense models, but it will not necessarily run autoregressive decode economically at large scale (Gupta et al. 2020; Pope et al. 2023). Generative serving increased the need for accelerator memory bandwidth, HBM capacity, and tightly coupled interconnects. Those lower-layer balances determine which batching and memory policies are viable in the serving layer that Chapter 62 and Chapter 31 examine later.

What remains outside this book's scope

Production ML is not a sequence in which every tree model is eventually replaced by a neural network. Gradient-boosted decision trees remain strong for many tabular problems, and XGBoost's success came partly from systems work on sparse data, cache use, and out-of-core execution (Chen and Guestrin 2016). A 2022 benchmark found tree ensembles ahead of tested deep networks on 45 curated medium-size tabular datasets (Grinsztajn et al. 2022).

The boundary is moving, but the evidence is scoped. TabPFN, a transformer pretrained on synthetic tabular tasks, outperformed tuned tree baselines in the authors' evaluations of datasets with at most 10,000 samples and 500 features (Hollmann et al. 2025). The paper also says that behavior beyond those limits needs further study and reports slower per-example inference than CatBoost in a 10,000-row example. Model family is therefore a workload choice, not a progress ladder. This book follows the lifecycle of generative models; tabular prediction, fraud models, forecasting, and classical learning-to-rank remain adjacent production systems rather than hidden chapters of that lifecycle.

Where the stacks are beginning to combine

Recommendation is also adopting generative methods. TIGER assigns each item a short semantic identifier and trains a transformer to decode the identifier of the next item (Rajput et al. 2023). In the evaluated sequential-recommendation pipeline, decoding replaces approximate-nearest-neighbor lookup. A learned codebook, identifier-to-item mapping, and beam search remain outside the model, and the published experiments do not establish web-scale production replacement.

HSTU provides stronger production evidence but supports a narrower conclusion than “the funnel is gone.” Its authors report a 1.5-trillion-parameter generative recommender deployed on several surfaces of a large platform, a 12.4% improvement on one disclosed online metric, and an empirical power-law relation between quality and training compute across three orders of magnitude (Zhai et al. 2024). The same paper retains multiple retrieval generators and separate ranking experiments over candidate sets. Generative models are replacing or augmenting components of the older stack; the evidence does not yet show that one architecture removes every stage.

Closed-loop data is another point of contact. In simulations, Chaney et al. showed that training on interactions produced under earlier recommendations can increase behavioral homogeneity without increasing utility (Chaney et al. 2018). The mechanism is specific: the deployed policy changes which human interactions become observable training data. That is different from inserting model-generated samples into a training corpus, although both cases require engineers to ask who produced the next dataset and under which policy.

What's contested

It remains uncertain how much of a production retrieve-then-rank funnel generative recommendation can replace. A useful answer needs matched evidence on recommendation quality, tail latency, hardware cost, catalog freshness, policy enforcement, deletions, observability, and reliability. TIGER supplies a research result on small public domains; HSTU supplies company-reported online results for particular platform surfaces. Neither establishes a universal architecture. The evidence currently supports hybrid coexistence, with the boundary likely to differ by catalog size, update rate, and product constraints.

The boundary for the rest of the book

The comparison can now be stated without treating every resemblance as an inheritance.

Status What belongs there
Inherited Embedding and term retrieval, artifact versioning, monitoring, staged rollout, rollback, controlled experiments, and long-horizon metrics
Adapted Feature pipelines became broader context pipelines; retrieval feeds a generator rather than only a ranker; evaluation must cover open-ended behavior
Workload-specific Accelerator-resident KV state, token-by-token scheduling, variable output length, and generative safety evaluation
Outside scope The broader predictive-ML lifecycle for tabular models, fraud, forecasting, advertising, and classical search or recommendation

The rest of the book follows a generative capability from compute and data, through training and adaptation, into serving, evaluation, governance, and operation. Earlier predictive systems will reappear when they provide a method or a warning, but they are neighboring infrastructure, not an earlier chapter of the same model lifecycle.

Further reading

  • Amatriain & Basilico, “Netflix Recommendations: Beyond the 5 Stars (Part 1)” (why the million-dollar ensemble never shipped), 2012. netflixtechblog.com
    Netflix incorporated two algorithms from the 2007 Progress Prize ensemble, but not the additional methods in the later Grand Prize solution because their marginal offline gain did not justify the engineering cost and the product had shifted toward streaming discovery.
  • Sculley et al., “Hidden Technical Debt in Machine Learning Systems” (the model is the small box in the diagram), 2015. papers.nips.cc
    Production ML debt often accumulates in glue code, configuration, undeclared consumers, and changing external dependencies rather than in the model alone.
  • McMahan et al., “Ad Click Prediction: a View from the Trenches” (MLOps a decade before the word), 2013. research.google
    Google's report on its production ad click-through predictor: FTRL online learning over billions of sparse features, plus the calibration, feature management, and monitoring discipline that kept it operable.
  • Covington et al., “Deep Neural Networks for YouTube Recommendations” (the canonical two-stage funnel), 2016. dl.acm.org
    YouTube documents a two-stage recommendation architecture in which a candidate model reduces millions of videos to hundreds before a ranking model selects a few dozen for display.
  • Cheng et al., “Wide & Deep Learning for Recommender Systems” (memorization plus generalization, shipped to Google Play), 2016. arXiv:1606.07792
    Jointly trains a wide linear model for memorization with a deep network for generalization, and reports the online A/B gains of shipping it to Google Play's app recommender.
  • Chen & Guestrin, “XGBoost: A Scalable Tree Boosting System” (the systems paper behind a decade of tabular wins), 2016. arXiv:1603.02754
    The systems design of gradient-boosted trees at scale: cache-aware layout, sparsity handling, and out-of-core computation, with the paper's own count that 17 of 29 published Kaggle winning solutions in 2015 used it.
  • Grinsztajn et al., “Why do tree-based models still outperform deep learning on typical tabular data?” (inductive bias, not tuning effort), 2022. arXiv:2207.08815
    Across 45 curated tabular datasets with 3,000 to 10,000 samples, tested tree ensembles outperform tested deep networks; the analysis highlights robustness to uninformative features and irregular target functions.
  • Hollmann et al., “Accurate predictions on small data with a tabular foundation model” (the foundation-model recipe reaches tabular data), 2025. nature.com
    TabPFN, a transformer pretrained on synthetic tabular tasks, outperforms tuned tree ensembles in the authors' evaluations of datasets with up to 10,000 samples and 500 features; behavior beyond those limits requires further study.
  • Naumov et al., “Deep Learning Recommendation Model for Personalization and Recommendation Systems” (read with Gupta et al. (2020) for the datacenter numbers), 2019. arXiv:1906.00091
    Meta's reference recommendation architecture combines categorical-feature embedding tables with dense interaction and multilayer-perceptron components, requiring both model and data parallelism.
  • Huang et al., “Embedding-based Retrieval in Facebook Search” (the production retrieval playbook RAG teams rediscovered), 2020. arXiv:2006.11632
    Facebook Search combines a two-tower embedding model, approximate search, term retrieval, and a training mix of easy and hard negatives; using only hard negatives reduced retrieval recall.
  • Malkov & Yashunin, “Efficient and Robust Approximate Nearest Neighbor Search Using Hierarchical Navigable Small World Graphs” (the index inside most vector databases, published years earlier), 2020. arXiv:1603.09320
    HNSW proposes a fully graph-based approximate nearest neighbor search index using a multi-layer proximity graph with logarithmic complexity scaling.
  • Kohavi, Ron; Tang, Diane; Xu, Ya. Trustworthy Online Controlled Experiments: A Practical Guide to A/B Testing (the measurement discipline the generative stack has not yet rebuilt). Cambridge University Press, 2020. experimentguide.com
    The reference on running online controlled experiments at scale, distilled from tens of thousands of experiments a year at Microsoft, Google, and LinkedIn; read the chapters on overall evaluation criteria and long-term metrics first.
  • Rajput et al., “Recommender Systems with Generative Retrieval” (TIGER: retrieval becomes decoding), 2023. arXiv:2305.05065
    TIGER quantizes item content embeddings into semantic IDs and trains a sequence model to decode the next item's ID, replacing approximate-nearest-neighbor lookup in its evaluated pipeline while retaining an external codebook and item mapping.
  • Zhai et al., “Actions Speak Louder than Words: Trillion-Parameter Sequential Transducers for Generative Recommendations” (the recsys stack adopts the LLM scaling recipe), 2024. arXiv:2402.17152
    The authors report a 1.5-trillion-parameter HSTU generative recommender deployed on several platform surfaces, a 12.4% gain on one disclosed online metric, and empirical power-law quality scaling across three orders of training compute; retrieval and ranking remain separate evaluated settings.
  • Stray et al., “What are you optimizing for? Aligning Recommender Systems with Human Values” (recommender objectives as a values-engineering problem), 2021. arXiv:2107.10939
    Frames engagement-optimized recommenders as an alignment problem deployed at planetary scale, and surveys concrete interventions for pointing them at human values instead of click proxies.

Comments

Log in to comment