Papers
Topics
Authors
Recent
Search
2000 character limit reached

VarLenRec: Adaptive Tokenization for Recommendations

Updated 4 July 2026
  • The paper presents a framework that allocates variable-length IDs to items, addressing the inefficiencies of fixed-length tokenization in recommendation systems.
  • It combines PIBA to weight encoding by popularity, HRQ to utilize hyperbolic geometry for residual quantization, and SLC for differentiable, content-adaptive length prediction.
  • Experiments demonstrate improved performance, reduced collisions, and faster inference compared to fixed-length methods, especially for diverse head–tail item distributions.

Searching arXiv for the VarLenRec paper and closely related generative recommendation/tokenization work to ground the article. VarLenRec is a framework for learning variable-length tokenization for generative recommendation. It is motivated by a basic design choice in generative recommendation: existing methods employ fixed-length tokenization for all items, implicitly assuming uniform encoding capacity regardless of item characteristics. The framework combines Popularity-Weighted Information Budget Allocation (PIBA), Hyperbolic Residual Quantization (HRQ), and a Soft Length Controller (SLC), and is integrated with a Transformer-based generative recommender through collision-safe decoding and length-bias correction (Wang et al., 18 May 2026).

1. Problem setting and motivating paradox

Generative recommendation reformulates recommendation as autoregressive next-token prediction over discrete item semantic identifiers (IDs). Each item ii is mapped to a sequence of discrete tokens ziz_i drawn from learned codebooks, and the model predicts the next item by generating its ID given the user’s past ID sequence. In prior quantization-based tokenizers, including RQ-VAE variants, the number of layers LL is fixed for all items, so every item receives the same encoding capacity (Wang et al., 18 May 2026).

VarLenRec is built around the observation that this assumption is suboptimal for long-tail catalogs. Popular items accumulate abundant collaborative signals and need little semantic detail, while tail items require richer content semantics to compensate for sparse interactions. The paper terms the resulting empirical pattern the Popularity-Length Paradox. When recommendation performance is evaluated by partitioning target items into Head (top 20%), Body (middle 60%), and Tail (bottom 20%) popularity groups and sweeping fixed ID lengths L{4,6,8,10}L \in \{4, 6, 8, 10\}, performance for head items decreases as LL grows, while performance for tail items increases with LL. The overall optimal fixed LL is a compromise that underperforms for every individual popularity group. This pattern is reported across Beauty, Sports, Toys, and Yelp (Wang et al., 18 May 2026).

A concise view of the framework is as follows.

Component Core mechanism Function
PIBA popularity-weighted information allocation induces a prior over ID lengths
HRQ hyperbolic residual quantization affords nonuniform capacity across code lengths
SLC differentiable length prediction trains variable-length IDs end-to-end

This decomposition reflects the paper’s central claim: adaptive encoding capacity is necessary because the information required to discriminate items is not uniform across the catalog. This suggests that fixed-length semantic IDs are not merely inefficient; they are structurally misaligned with the head–tail asymmetry in collaborative and content signals.

2. Popularity-Weighted Information Budget Allocation

PIBA formalizes how much information each item’s ID should carry as a function of its popularity, under a global budget constraint (Wang et al., 18 May 2026). Each item ii has normalized popularity pi0p_i \ge 0, with ipi=1\sum_i p_i = 1. The framework assumes that collaborative information grows submodularly with popularity,

ziz_i0

with ziz_i1 and ziz_i2.

Semantic information is modeled through residual quantization. The ziz_i3-th layer contributes diminishing returns of approximately ziz_i4 bits, with ziz_i5 for codebook size ziz_i6. The total semantic information is

ziz_i7

If ziz_i8 denotes the minimum information required to make an item discriminable, then the semantic ID must fill the gap

ziz_i9

Under a total length budget LL0,

LL1

a practical PIBA formulation maximizes total semantic information minus a linear length penalty while respecting both feasibility and budget constraints:

LL2

For items that bind the constraint LL3, the minimum feasible LL4 is optimal. The resulting KKT solution is

LL5

For LL6, this becomes the closed-form power law

LL7

with

LL8

The paper presents this as the principal theoretical result of PIBA: optimal ID length should scale as a negative power of popularity. Intuitively, the exponent LL9 emerges from balancing collaborative information, which is logarithmic in popularity, against semantic capacity, which is logarithmic in length.

PIBA also provides a prior over lengths. Popularity is measured from interaction counts L{4,6,8,10}L \in \{4, 6, 8, 10\}0 with smoothing,

L{4,6,8,10}L \in \{4, 6, 8, 10\}1

where L{4,6,8,10}L \in \{4, 6, 8, 10\}2 prevents zero-popularity instability. In practice, the paper reports that rank-based quantile mapping improves robustness:

L{4,6,8,10}L \in \{4, 6, 8, 10\}3

where L{4,6,8,10}L \in \{4, 6, 8, 10\}4 is the descending popularity rank and L{4,6,8,10}L \in \{4, 6, 8, 10\}5. This discrete prior is then used as supervision for SLC.

3. Hyperbolic Residual Quantization

Directly implementing variable-length allocation introduces a geometric difficulty: standard Euclidean residual quantization lacks geometric capacity to support diverse code lengths without distortion. In Euclidean space, ball volume grows polynomially, L{4,6,8,10}L \in \{4, 6, 8, 10\}6, whereas hierarchical item semantics exhibit exponential branch growth. As a result, longer residual stacks in Euclidean space must pack exponentially many fine-grained distinctions into polynomial capacity, leading to higher distortion and collisions for tail items (Wang et al., 18 May 2026).

HRQ addresses this by using hyperbolic geometry, specifically the Poincaré ball. For curvature L{4,6,8,10}L \in \{4, 6, 8, 10\}7 with L{4,6,8,10}L \in \{4, 6, 8, 10\}8, the L{4,6,8,10}L \in \{4, 6, 8, 10\}9-dimensional ball is

LL0

The framework uses hyperbolic distance, Möbius addition, and the exponential and logarithmic maps at the origin:

LL1

LL2

LL3

The geometric motivation is the exponential volume growth of hyperbolic space:

LL4

This provides natural stratification across radii: short codes are placed near the origin and correspond to coarse semantics, while long codes can expand toward the boundary and represent fine semantics.

The HRQ pipeline uses LL5 residual layers. An encoder maps content features LL6 to Euclidean LL7 via LL8, then projects them to the manifold:

LL9

At layer LL0, the nearest code in codebook LL1 is selected using hyperbolic distance,

LL2

and the residual is updated via Möbius subtraction,

LL3

The paper’s theoretical and empirical comparison is explicit. Hyperbolic embeddings preserve tree-like semantics with LL4 distortion, while Euclidean embeddings suffer LL5 distortion. Empirically, replacing hyperbolic HRQ with Euclidean RQ decreases Recall@10 by about LL6–LL7 on Beauty and Toys; collision rates increase. HRQ reduces collisions, for example from LL8 to LL9 on average, improves tail discrimination, and works synergistically with variable-length allocation (Wang et al., 18 May 2026).

In computational terms, tokenization per item is LL0, because each of LL1 layers performs nearest-code selection over LL2 codes in LL3 dimensions. Hyperbolic distance adds constant overhead via LL4 and LL5, and approximate nearest neighbor search is optional.

4. Soft Length Controller and optimization objective

SLC makes length prediction differentiable through continuous layer retention probabilities and regularizes them with PIBA-derived priors (Wang et al., 18 May 2026). For each layer LL6,

LL7

Prefix constraints are enforced by cumulative masks

LL8

so LL9 loosely represents the probability that layer ii0 is kept given all prior gates are open.

The gate is content-adaptive. At layer ii1, the current residual and selected code are projected to tangent space and passed to a small ii2 with sigmoid:

ii3

The gate closes early when residual semantics are already captured, and stays open for complex items.

PIBA supplies the supervisory prior. From popularity ii4, a discrete target length ii5 is computed via quantile mapping, and a binary target mask is formed as

ii6

The cumulative masks are regularized toward this target with cross-entropy:

ii7

HRQ and SLC are trained jointly with four losses. The reconstruction loss is

ii8

The quantization/commitment loss, using stop-gradient ii9 as in VQ-VAE, is

pi0p_i \ge 00

with pi0p_i \ge 01. The length cost is

pi0p_i \ge 02

The combined tokenizer objective is

pi0p_i \ge 03

At inference time, SLC uses pi0p_i \ge 04-thresholding, for example pi0p_i \ge 05, and the cumulative mask to select the truncation point:

pi0p_i \ge 06

The paper reports that calibration is minimal and pi0p_i \ge 07 is tuned on validation. A notable ablation is that using hard PIBA lengths without SLC underperforms by pi0p_i \ge 08–pi0p_i \ge 09, which indicates that the popularity prior alone is insufficient and that content-aware gating materially contributes to performance.

5. End-to-end architecture, training, and decoding

VarLenRec is an end-to-end pipeline from item features to a generative recommender (Wang et al., 18 May 2026). First, a content encoder maps item features, such as Sentence-T5 text embeddings, to the hyperbolic manifold. Second, HRQ with ipi=1\sum_i p_i = 10 residual layers and codebooks of size ipi=1\sum_i p_i = 11 performs layerwise hyperbolic quantization, while SLC predicts soft retention. Third, the tokenizer outputs variable-length discrete IDs as the selected code indices up to the learned truncation ipi=1\sum_i p_i = 12. Fourth, a Transformer/T5 decoder is trained on sequences of item IDs to predict next-item IDs.

The downstream generative objective is standard next-token loss:

ipi=1\sum_i p_i = 13

Training proceeds in two stages. In the HRQ+SLC stage, item features are encoded, quantized layer by layer, masked through cumulative gates, softly reconstructed, and optimized with Riemannian Adam. In the GR stage, token sequences are built from HRQ IDs, with collision resolution and EOS, and the LLM is trained with cross-entropy.

The representative settings reported are: codebook size ipi=1\sum_i p_i = 14, maximum length ipi=1\sum_i p_i = 15, curvature ipi=1\sum_i p_i = 16, and gate threshold ipi=1\sum_i p_i = 17. Riemannian Adam is used for HRQ with learning rate ipi=1\sum_i p_i = 18 and batch size ipi=1\sum_i p_i = 19; Adam is used for GR with learning rate ziz_i00 and batch size ziz_i01; beam search size is ziz_i02 at inference.

Variable-length IDs create specific decoding issues, and the paper therefore emphasizes three mechanisms. First, collision handling reserves an auxiliary disambiguation range, for example IDs in ziz_i03, to append to colliding short IDs and avoid semantic interference. Second, trie-constrained decoding builds a prefix tree of all valid IDs to avoid hallucinations. Third, length bias correction rescales decoded candidates with the length-invariant odds ratio

ziz_i04

The inference procedure is therefore: run constrained beam search over a prefix trie of valid IDs, decode until EOS, rescore candidates to correct length bias, and map decoded IDs to items.

6. Experimental results, practical considerations, and limitations

The experiments are conducted on Amazon Beauty, Sports and Outdoors, Toys and Games, and Yelp, with users and items having fewer than ziz_i05 interactions dropped. The splits are leave-one-out: last item as test, second last as validation, and the rest as train. Evaluation uses Recall@K and NDCG@K for ziz_i06 under a full ranking protocol (Wang et al., 18 May 2026).

Baselines include sequential recommenders—HGN, GRU4Rec, BERT4Rec, SASRec, FMLP, ziz_i07-Rec, and HSTU—as well as fixed-length GR tokenizers such as TIGER and ETEGRec, and enhanced GR tokenizers such as LETTER-TIGER and LETTER-LCRec. Across all datasets, VarLenRec consistently improves over fixed-length GR baselines and traditional sequential recommenders. With LCRec backbones, VarLenRec achieves top performance on Beauty, Sports, and Toys; with TIGER backbones, it tops Yelp. The reported gains reach up to about ziz_i08 in NDCG@10, and are strongest on semantically diverse catalogs such as Beauty and Toys.

The ablation results isolate the role of each component. No single fixed ziz_i09 is optimal; adaptive lengths outperform all fixed choices ziz_i10. Replacing hyperbolic HRQ with Euclidean RQ reduces Recall@10 by about ziz_i11–ziz_i12 on Beauty and Toys. Removing ziz_i13 or ziz_i14 degrades results, and ziz_i15 prevents unnecessarily long IDs. Removing collision resolution, trie decoding, and length-normalized scoring leads to about an ziz_i16 Recall@10 drop. These findings indicate that VarLenRec is not only a variable-length tokenizer, but a coupled system whose theoretical allocation rule, geometry, gating, and decoding strategy interact.

The headline result for the motivating paradox is reported on Beauty at ziz_i17: VarLenRec simultaneously improves head ziz_i18, body ziz_i19, and tail ziz_i20 groups versus fixed-length TIGER. In efficiency terms, VarLenRec reduces training time by approximately ziz_i21 and inference time by approximately ziz_i22 versus TIGER, due to shorter IDs for popular items and early termination during decoding.

Several implementation details are emphasized. Stability on the Poincaré ball is maintained by setting ziz_i23 and enforcing a safety margin ziz_i24 from the boundary. Popularity smoothing ziz_i25 stabilizes ziz_i26, and rank-based mapping reduces sensitivity to outliers. The paper recommends tuning ziz_i27 and ziz_i28 per dataset. Riemannian Adam is used to keep codebook vectors on the manifold, with updates applied through the exponential map and projection back into the ball interior if parameters approach the boundary.

The stated limitations are tied to the assumptions of the framework. PIBA assumes collaborative information grows as ziz_i29; if popularity dynamics or interaction quality violate this submodular trend, the exponent may mis-specify length. The quality of the content encoder matters for tail items, because poor content features reduce the benefit of longer IDs. Curvature choice ziz_i30 and codebook size ziz_i31 interact with capacity, so mis-tuning may cause underfitting near the origin or crowding near the boundary. Proposed extensions include adaptive budgets over time, user-conditioned lengths, multimodal content, and category-aware priors (Wang et al., 18 May 2026).

The paper does not provide a public repository link at the time of writing. Its recommended setup is Sentence-T5 embeddings for item features; HRQ with ziz_i32, ziz_i33, and ziz_i34; a T5 decoder trained with Adam at learning rate ziz_i35; beam size ziz_i36; trie-constrained decoding with odds-rescoring; and popularity estimated from normalized interaction counts with small-ziz_i37 smoothing and rank-based quantile mapping. Within that formulation, VarLenRec presents variable-length tokenization as a principled allocation problem, a hyperbolic quantization problem, and a differentiable control problem, unified within generative recommendation.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to VarLenRec.