Language Models as Semantic Indexers

Bowen Jin, Hansi Zeng, Guoyin Wang, Xiusi Chen, Tianxin Wei, Ruirui Li, Zhengyang Wang, Zheng Li, Yang Li, Hanqing Lu, Suhang Wang, Jiawei Han, Xianfeng Tang

TL;DR

The paper introduces LMINDEXER, a self-supervised framework that trains generative language models to directly assign hierarchical, discrete "semantic IDs" to documents and items. By replacing the traditional two-step pipeline (embed then cluster) with an end-to-end reconstruction objective, LMINDEXER avoids information loss and generates higher-quality IDs. These improved representations significantly boost performance on downstream tasks like recommendation, product search, and document retrieval.

The Problem with Current Semantic IDs

In information retrieval and recommendation systems, assigning unique IDs to items or documents is standard practice. Recently, researchers have explored Semantic IDs—discrete sequences of tokens that directly encode the meaning and hierarchical category of an item into the ID string itself (e.g., [Furniture, Chair, Office]).

Currently, generating these IDs relies on a disjointed two-step process:

  1. Extract dense embeddings using an off-the-shelf encoder (like BERT).
  2. Use clustering (like Hierarchical Clustering) or quantization (like rq-VAE) to create discrete IDs.

This pipeline causes two major issues. First, because the two steps are optimized separately, there is a loss of nuanced semantic details. Second, there is a distribution mismatch: standard text embeddings are typically distributed uniformly in latent space, but semantic IDs require a hierarchical, coarse-to-fine distribution.

Training an end-to-end model to output discrete, sequential IDs without explicit labeled pairs (document $\rightarrow$ ID) is notoriously difficult due to the lack of differentiable supervision signals. LMINDEXER was designed to tackle this exact bottleneck.

Methods: An End-to-End Self-Supervised Approach

LMINDEXER uses a sequence-to-sequence generative language model (based on T5) trained entirely via self-supervision.

LMIndexer Architecture

The architecture consists of two main components:

  • Semantic Indexer: An encoder-decoder that reads a document and generates a sequence of discrete IDs using codebook lookups.
  • Reconstructor: A shallow Transformer that tries to rebuild the original text solely from those discrete IDs (plus some masked context hints).

Because the codebook lookup is a discrete argmax operation (which isn't differentiable), the authors use a straight-through estimator to allow gradients to flow back to the indexer. To make this self-supervised setup actually work, they introduce several clever training techniques:

  • Progressive Training: The model learns the ID sequence auto-regressively, locking in coarse-grained prefix IDs before learning fine-grained suffix IDs.
  • Contrastive Loss: Forces documents that share the same prefix ID to diverge at the next ID position. This prevents "posterior collapse," where the model lazily assigns the exact same ID to everything.
  • Commitment Loss: Prevents the model from catastrophically forgetting earlier ID positions when training subsequent ones.

Downstream Applications and Datasets

Once trained, the Semantic Indexer can be plugged directly into various retrieval pipelines.

Downstream Tasks: Recommendation and Retrieval

The authors evaluated LMINDEXER across three distinct tasks using five datasets:

  • Recommendation & Product Search: Amazon Review datasets across three domains (Amazon-Beauty, Amazon-Sports, Amazon-Toys).
  • Document Retrieval: Natural Questions (NQ320k), MS MARCO (a 1M document subset), and a merged TREC-DL 1M dataset.

Key Insights

  • End-to-end beats two-step: Forcing a model to compress document semantics into discrete tokens so that the document can be reconstructed yields much better hierarchical representations than simply clustering pre-trained dense embeddings.
  • A "weak" reconstructor is a feature, not a bug: The authors deliberately use a shallow (1-layer) reconstructor. If the reconstructor is too deep and powerful, it memorizes the data and ignores the IDs. A weak reconstructor forces the Semantic Indexer to do the heavy lifting and pack maximum semantic meaning into the IDs.
  • Warm-ups are critical to avoid collapse: Without carefully warming up the reconstructor and the codebooks independently before joint training, the model suffers from "reconstructor collapse" (noisy gradients ruin the indexer) or "posterior collapse" (the indexer generates homogeneous, useless IDs).

Key Results

LMINDEXER consistently outperformed baseline semantic indexers (like rq-VAE and Hierarchical Clustering) across the board:

  • ID Quality: LMINDEXER's IDs align much better with human-labeled categories. On the Amazon-Beauty dataset, it achieved an Adjusted Mutual Information (AMI) score of 0.3563, compared to 0.3100 for the best baseline.
  • Recommendation: Achieved a Recall@5 of 0.0415 on Amazon-Beauty, crushing the rq-VAE baseline (0.0136) and traditional sequential models like BERT4Rec.
  • Product Search: Reached an NDCG@5 of 0.3187 on Amazon-Beauty, outperforming the rq-VAE indexer (0.2710).
  • Document Retrieval: On NQ320k, it achieved a Recall@1 of 0.6631, beating rq-VAE (0.6480) and traditional BM25 (0.2970).

Limitations and Future Work

While highly effective, the authors acknowledge a few limitations. First, on massive, open-domain corpora (like the MS MARCO 1M dataset), traditional dual-encoder dense retrieval models (like DPR) still slightly outperform semantic indexers (MRR@10 of 0.5561 for DPR vs. 0.5485 for LMINDEXER). This leaves room for future work to scale semantic indexers to compete with state-of-the-art dense retrieval on massive datasets.

Additionally, while the contrastive loss heavily reduces ID duplication (multiple documents getting the exact same ID), it doesn't guarantee perfectly unique IDs for every single document without appending an arbitrary final token to break ties. Future work could explore more rigorous ways to guarantee collision-free semantic hashing.

Summary updated

BibTeX
@inproceedings{jin2024language,
  author = {Bowen Jin and Hansi Zeng and Guoyin Wang and Xiusi Chen and Tianxin Wei and Ruirui Li and Zhengyang Wang and Zheng Li and Yang Li and Hanqing Lu and Suhang Wang and Jiawei Han and Xianfeng Tang},
  title = {{Language Models as Semantic Indexers}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=sYeioWoF9u},
}
Figure