← Blog/blog/tiger-semantic-id-space

The recommender’s four-trillion-ID claim is off by 1,000×

A conventional recommender retrieves products by comparing one user vector against a giant index of item vectors. TIGER tries something stranger: turn each product into a short sentence of integer tokens, then ask a transformer to generate the next product's sentence.

Those tokens form a Semantic ID. Similar products share early tokens, so “orange shoes, Brand Y” can borrow evidence from other shoes instead of starting as an isolated item number. This makes recommendation look like language generation and gives new products a route into the system through their content.

01

Compress a product from coarse to fine

TIGER begins with a 768-dimensional content embedding built from title, price, brand, and category. An encoder compresses it to 32 dimensions. Residual quantization then chooses the nearest vector from the first codebook, subtracts it, and asks the next codebook to describe what remains. Each chosen vector's index becomes one token.

def residual_quantize(vector, codebooks):
    residual = vector[:]
    codes = []
    for codebook in codebooks:
        code = min(range(len(codebook)), key=lambda k: squared_distance(residual, codebook[k]))
        residual = [r - q for r, q in zip(residual, codebook[code])]
        codes.append(code)
    return codes, residual

The live TypeScript uses the same loop; Python and C++ are faithful translations. Our two-dimensional codebooks are deterministic illustrations, not the paper's learned 32-dimensional vectors.

residual norm
Residual length after each codebook in the tested two-dimensional reconstruction. Each token describes what the previous, coarser token missed.
02

The hierarchy is the useful part

With separate codebooks, an ID such as (5, 25, 55) is a path: token 5 gives a broad neighborhood, token 25 refines it, and token 55 resolves a smaller residual. In the paper's Beauty visualization, the first token grouped broad categories such as hair or makeup while later tokens separated finer categories.

A transformer reads a user's sequence of Semantic IDs and autoregressively predicts the next ID one token at a time. Autoregressive means each predicted token becomes context for predicting the next. Beam search keeps several likely partial IDs alive until they resolve to candidate items.

Item representationRecall@5NDCG@5Recall@10NDCG@10
Random ID0.02960.02050.04340.0250
LSH Semantic ID0.03790.02590.05330.0309
RQ-VAE Semantic ID0.04540.03210.06480.0384
Amazon Beauty results reported in the paper's ID-generation ablation. RQ-VAE beats both random IDs and locality-sensitive hashing (LSH) at the same retrieval task.
03

Four trillion is actually four billion

The paper uses four tokens with 256 choices each and says this spans “approximately 4 trillion” IDs. The exact calculation is 256⁴ = 2³², or 4,294,967,296: about 4.3 billion. That is a three-order-of-magnitude arithmetic slip.

Base-10 log of the exact code-space capacity as 256-way tokens are added. Four levels reach 4.29 billion, not four trillion. The chart uses exact integer products from the tested core module.
04

Collisions reveal the non-semantic last token

Multiple products can quantize to the same three-token ID. TIGER fixes this after training by appending 0, 1, 2, and so on to colliding products. That suffix is an atomic tie-breaker, not learned meaning, and it requires a lookup table from IDs back to actual items. The method compresses the giant index; it does not make the catalog disappear entirely.

05

What I would probe next

  • Constrain beam search to valid prefixes instead of filtering only at the end.
  • Report collision rates and suffix dependence for new, long-tail products.
  • Measure serving latency against a tuned approximate-neighbor index.

To inspect the attention and autoregressive decoding underneath TIGER, poke at the interactive transformer page.

References

  1. Shashank Rajput, Nikhil Mehta, Anima Singh, Raghunandan H. Keshavan, Trung Vu, Lukasz Heldt, Lichan Hong, Yi Tay, Vinh Q. Tran, Jonah Samost, Maciej Kula, Ed H. Chi, Maheswaran Sathiamoorthy (2023). Recommender Systems with Generative Retrieval. NeurIPS 2023
  2. Doyup Lee et al. (2022). Autoregressive Image Generation using Residual Quantization. CVPR 2022