Better Generalization with Semantic IDs: A case study in Ranking for Recommendations

Anima Singh, Trung Vu, Raghunandan H. Keshavan, Nikhil Mehta, Xinyang Yi, Lichan Hong, Lukasz Heldt, Li Wei, Ed H. Chi, Maheswaran SathiamoorthyRecSys 2023

Introduction

In industry-scale recommender systems, such as those powering YouTube or Amazon, "Random Hashing" has traditionally been the standard for item identification. Under this paradigm, every item is assigned a unique, random ID string mapped to a row in a massive embedding table. While effective for memorizing user interactions with specific items, random IDs are inherently meaningless. They fail to capture relationships between similar items, leading to the "cold-start" problem where the model must learn from scratch for every new upload.

A recent study from Google DeepMind and YouTube researchers, "Better Generalization with Semantic IDs," proposes a shift toward "Semantic IDs" (SIDs). These IDs encode item content into compact, hierarchical sequences, allowing models to leverage similarity for better generalization, particularly on long-tail and new content.

Methodology

The researchers propose a two-stage framework to bridge the gap between high-precision memorization and content-based generalization.

Stage 1: From Pixels to Tokens (RQ-VAE)

To generate Semantic IDs, the system utilizes a Residual Quantized Variational AutoEncoder (RQ-VAE). This component takes a dense, 2048-dimensional content embedding (e.g., from a Video-BERT model) and compresses it into a short sequence of discrete integers.

RQ-VAE architecture for generating Semantic IDs

As shown in the architecture above, the sequence is hierarchical: the first integer represents a broad category, while subsequent integers provide increasing levels of specificity. This structure effectively organizes the video corpus into a prefix tree (trie), where shared prefixes indicate high content similarity.

Stage 2: Adapting for Ranking

To integrate SIDs into a ranking model, the authors explored two hashing methods:

  • N-gram based: Grouping fixed-length chunks of the SID sequence.
  • SentencePiece (SPM) based: Borrowing from LLM tokenization, the SentencePiece model dynamically learns "subwords" of SID sequences. This allows the model to balance memorizing popular items with falling back on broader prefixes for rare or new ones.

Results and Key Insights

The study was evaluated using YouTube production data involving billions of videos. The primary metrics were Click-Through Rate (CTR) AUC for overall performance and CTR/1D AUC to measure generalization on items introduced within the last 24 hours.

Performance comparison of SPM-SID vs Random Hashing across overall and cold-start metrics

Superior Generalization

As illustrated in the results, the SPM-based Semantic ID approach significantly outperforms the Random Hashing baseline in cold-start scenarios (CTR/1D). While random hashing provides near-zero gain for new items, SIDs allow the model to "understand" new videos by their similarity to known ones.

Quality and Efficiency

Unlike raw dense embeddings, which can sometimes degrade ranking precision, Semantic IDs maintained or improved overall model quality. Furthermore, SIDs allow for a 10-50x reduction in computational cost compared to end-to-end video encoders. The researchers also found that SIDs remain stable over time; an encoder trained six months prior performed as well as a freshly trained one.

Conclusion

Semantic IDs represent a significant step toward moving recommendation engines beyond simple memorization. By replacing random strings with content-aware tokens, models can achieve better generalization on the long tail without sacrificing the precision needed for popular content. Future work may involve joint training of the SID encoder and the ranking model, as well as expanding the approach to text-based and cross-lingual recommendations.

Summary updated

BibTeX
@inproceedings{singh2023better,
  author = {Anima Singh and Trung Vu and Raghunandan H. Keshavan and Nikhil Mehta and Xinyang Yi and Lichan Hong and Lukasz Heldt and Li Wei and Ed H. Chi and Maheswaran Sathiamoorthy},
  title = {{Better Generalization with Semantic IDs: A case study in Ranking for Recommendations}},
  booktitle = {RecSys},
  year = {2023},
  url = {https://openreview.net/forum?id=WSAZEqk3S1},
}
Figure