Beyond Fixed Depths and Widths: Optimizing Textual Decoding Tries in LLM-based Generative Recommendation

Jingzhe Liu, Hanbing Wang, Jiliang Tang, Liam Collins, Tong Zhao, Neil Shah, Mingxuan JuarXiv 2026

TL;DR

Generative recommendation systems often struggle because their "decoding tries"—the roadmaps that guide an LLM to valid item IDs—are structurally inefficient. This paper introduces BONSAI, a framework that optimizes these tries by enforcing variable ID lengths and minimizing branching factors at early decision points, leading to a relative performance boost of up to 21.6% over state-of-the-art models.

What Problem Does This Paper Address?

Generative Recommendation (GR) is a shift away from traditional ranking. Instead of scoring items, an LLM autoregressively predicts an item’s "term ID" (like a title or a set of keywords). To ensure the LLM doesn't hallucinate non-existent items, researchers use a decoding trie: a prefix tree where every path from root to leaf represents a valid item.

The authors identify a major oversight in current GR research: while everyone focuses on making IDs more "semantic," they ignore the structure of the trie itself. Most existing methods force every item to have a fixed-length ID, which leads to two problems:

  1. Information Loss: Simple items are over-described, and complex items are over-compressed.
  2. Search Failure: If a trie has too many branches near the root (a high branching factor), the LLM’s beam search is likely to pick the wrong path early on, leading to a "cascading error" where the correct item is eliminated from the search space immediately.
Figure 3: Preliminary experiments on predicting the category of the next item under different search tree structures. As the branching factor increases, performance gradually declines.

Methods

The authors propose BONSAI (Branching-Optimized Node Structure for Adaptive Identifiers), which co-designs the textual IDs and the trie structure through a four-stage pipeline:

  1. Feature Filtering: An LLM (Qwen3-32B) extracts salient keywords from raw item metadata (e.g., "titanium," "backpack," "stove") while discarding generic filler words.
  2. Trie Construction via Recursive Set Cover: This is the core innovation. Instead of arbitrary ID assignment, BONSAI treats trie building as a minimum set cover problem. For any group of items, it finds the smallest set of features that can partition them into subsets. This mathematically guarantees the lowest possible branching factor at each level.
  3. Supervised Fine-Tuning (SFT): The backbone LLM is trained to map user history to these trie-aware IDs.
  4. Reinforcement Learning (RL): Using Group Relative Policy Optimization (GRPO), the model is further tuned to align with the actual decoding process. Since BONSAI allows an item to have multiple valid paths in the trie, RL helps the model learn to navigate all valid representations effectively.
Figure 5: Overview of BONSAI and its four main components: (a) feature filtering, which extracts recommendation-relevant terms; (b) trie construction, which builds a term-based trie using a minimum set cover strategy; (c) supervised learning, which trains the LLM backbone to acquire recommendation capability; and (d) reinforcement learning, which optimizes the model under real decoding constraints while aligning items with multiple possible IDs.

Datasets

The model was evaluated on three sub-datasets from the Amazon Review Datasets [25]:

  • Beauty
  • Sports and Outdoors
  • Toys and Games

Additionally, the authors used Amazon-M2, an industry-scale dataset, to test how the method scales with larger volumes of data.

Key Insights and Ideas

  • The "Shallow Branching" Rule: The success of constrained beam search depends critically on keeping the branching factor small at shallow levels. If the model has to choose between 1,000 branches at step one, it’s much more likely to fail than if it chooses between 10.
  • Variable Depth is Mathematically Superior: The authors provide theoretical proofs (Theorem 3) showing that forcing uniform ID lengths is suboptimal. Items naturally vary in "semantic richness" (as seen in Figure 4); their IDs should reflect that.
  • Structure > Semantics: Interestingly, the authors showed that even if you keep the same keywords but simply reorganize them using their minimum-set-cover strategy, performance improves. This suggests the trie structure itself is a major bottleneck in current generative recommenders.
Figure 2: The length distribution of item metadata in Amazon Review Datasets [25]. Semantic richness of different items varies largely both within and across datasets.

Key Results

  • State-of-the-Art Performance: BONSAI outperformed the strongest baselines (like GRLM and OneRec-Think) by 16.0% to 21.6% across various metrics (Recall@5, NDCG@10).
  • Cold-Start Robustness: Because the IDs are based on extracted textual features rather than abstract numerical codes, BONSAI showed a strong ability to recommend "cold-start" items that were never seen during training.
  • Efficiency: By minimizing the branching factor, the decoding process becomes more reliable without significantly increasing the number of total representations.
Figure 1: A segment of the trie for variable-length term IDs.

Limitations and Future Work

While BONSAI represents a significant step forward, the authors note a few areas for growth:

  • Feature Extraction: The current method relies on an LLM to extract keywords. Better, perhaps joint, methods for feature selection and trie optimization could yield further gains.
  • Multi-modality: The current trie is strictly textual. Extending these structural principles to include visual or audio features is a promising next step.
  • Depth-Width Trade-off: There is a natural tension between making a trie "deep" (long IDs) and "wide" (high branching). Finding the absolute optimal balance for different LLM backbone sizes remains an open question.

Summary updated

BibTeX
@misc{liu2026beyond,
  author = {Jingzhe Liu and Hanbing Wang and Jiliang Tang and Liam Collins and Tong Zhao and Neil Shah and Mingxuan Ju},
  title = {{Beyond Fixed Depths and Widths: Optimizing Textual Decoding Tries in LLM-based Generative Recommendation}},
  year = {2026},
  eprint = {2607.16633},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2607.16633},
}
Figure