Improving LLMs for Recommendation with Out-Of-Vocabulary Tokens

Ting-Ji Huang, Jia-Qi Yang, Chunxu Shen, Kai-Qi Liu, De-Chuan Zhan, Han-Jia Ye

TL;DR

Large Language Models (LLMs) often struggle with recommendation tasks because they represent items using standard "in-vocabulary" tokens (like "item 123"), which carry distracting semantic baggage. This paper introduces META ID, a framework that creates custom Out-of-Vocabulary (OOV) tokens based on user-item interaction graphs, allowing LLMs to better "memorize" collaborative relationships while maintaining the "diversity" needed to distinguish between millions of items.

What Problem Does This Paper Address?

When we ask an LLM to "recommend an item for User A," we face a fundamental mapping problem. How do we represent "User A" or "Item B" to a model originally trained on natural language text and code?

Most current approaches use In-Vocabulary (IV) tokens:

  1. Titles/Attributes: (e.g., "Blue Nike Running Shoes") — These can be wordy and prone to "hallucination," where the model recommends a description that doesn't actually exist in the catalog.
  2. Numeric IDs: (e.g., "item 2024") — This is problematic because the tokens "20" and "24" already have established meanings. The model might incorrectly assume "item 2024" is semantically related to "item 2025" just because they share digits, even if the actual products are completely unrelated (e.g., a toaster and a tennis racket).
Instruction format comparing In-Vocabulary and OOV tokens

The authors argue that these IV tokens lack the expressive power to capture collaborative filtering signals (who likes what) and create "semantic conflicts" that hinder the model's performance.

Methods: The META ID Framework

The authors propose META ID (META-path-guided IDentifier), which builds a bridge between traditional graph-based recommendation and LLMs:

  1. Meta-path-based Embedding: They construct a user-item interaction graph and sample "meta-paths" (specifically $U-I-U$ paths, representing users who bought the same items). They use a skip-gram model to learn vector representations for every user and item based on these paths.
  2. Hierarchical OOV Token Generation: To avoid creating a unique token for every single item (which would explode the vocabulary size), they use a two-tier clustering approach:
  3. Coarse-grained: They cluster the embeddings using K-Means and assign a "Cluster Token" ($\langle CT_i \rangle$).
  4. Fine-grained: Within each cluster, they assign an "In-cluster Token" ($\langle CI_i \rangle$) based on the item's distance to the centroid.
  5. An item ID ultimately looks like: [Item] [Cluster_Token] [In-cluster_Token].
  6. LLM Integration: These new OOV tokens are added to the LLM's vocabulary. Crucially, they initialize the new token embeddings using the cluster centroids from the graph model, giving the LLM a "warm start" on the collaborative relationships before fine-tuning even begins.

Key Insights and Ideas

The authors introduce two new metrics to evaluate token representations: Diversity Score (DS) (how well the model distinguishes items) and Memorization Score (MS) (how well it captures item-item similarities).

Comparison of DS/MS metrics and T-SNE visualizations
  • The DS/MS Tradeoff: They found that standard IV tokens (Numeric IDs) have high MS but terrible DS—they all "clump together" in the model's latent space. OOV tokens provide the "blank slate" needed for high diversity while maintaining memorization.
  • Semantic Interference is Real: T-SNE visualizations show that standard numeric IDs shrink into a tiny portion of the embedding space. In contrast, META IDs utilize the space much more effectively, allowing for clearer distinction between items.
  • Attention Matters: By visualizing attention maps, the authors found that standard IDs lead to "diffuse" attention. META IDs, however, allow the LLM to focus specifically on the relevant user and item tokens, leading to more precise generation.

Key Results

The META ID framework was evaluated on three real-world datasets from the Amazon Product Reviews collection (Sports & Outdoors, Beauty, Toys & Games) using T5-small and LLaMA2-7b as backbones.

  • Superior Performance: META ID consistently outperformed state-of-the-art baselines (like P5, TIGER, and CID) across all datasets. For example, on the Sports dataset for sequential recommendation, META ID (T5) achieved an H@5 of 0.0322, significantly beating TIGER's 0.0264.
  • Adaptability: Beyond just picking items, the OOV tokens improved "soft" tasks. In Explanation Generation, META ID achieved higher BLEU scores, meaning the model's justifications for its recommendations were more aligned with real human reviews.
  • Efficiency: Despite adding tokens, the inference time remains low (e.g., ~74ms per user for sequential recommendation on the Toy dataset).

Limitations and Future Work

  • The Cold Start Problem: META ID relies on historical interaction data to generate embeddings and clusters. If a new item appears with zero history, the system cannot easily generate a meaningful META ID for it.
  • Static Vocabulary: The current implementation uses a fixed database of IDs. In a production environment with millions of new items daily, a more dynamic or deeply hierarchical tokenization strategy would be required.
  • Clustering Sensitivity: While K-Means worked best in their tests, the performance is sensitive to the number of clusters ($G$). Finding the optimal balance for vocabulary size versus granularity remains a manual tuning task.

Summary updated

BibTeX
@inproceedings{huang2025improving,
  author = {Ting-Ji Huang and Jia-Qi Yang and Chunxu Shen and Kai-Qi Liu and De-Chuan Zhan and Han-Jia Ye},
  title = {{Improving LLMs for Recommendation with Out-Of-Vocabulary Tokens}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=cerqDkPLx7},
}
Figure