Source-linked AI summary

ActionPiece: Contextually Tokenizing Action Sequences for Generative Recommendation

Yupeng Hou, Jianmo Ni, Zhankui He, Noveen Sachdeva, Wang-Cheng Kang, Ed H. Chi, Julian McAuley, Derek Zhiyuan Cheng

arXiv:2502.13581v3cs.IRcs.LG

TL;DR

Generative recommendation traditionally assigns context-independent tokens to actions, despite actions taking different meanings from their surrounding sequences. ActionPiece tokenizes sequences of unordered item-feature sets by context-aware feature merging and permutation-based segmentation. The paper presents this as a context-aware action tokenizer with efficient construction and inference, while identifying future extensions to other set-sequence tasks.

  • Problem

    Existing generative recommendation methods tokenize each action independently, assigning identical actions fixed tokens without representing contextual relationships.

    Source: §1 · p. 1
  • Method

    ActionPiece merges feature patterns based on weighted co-occurrences within and across adjacent unordered feature sets, then applies set permutation regularization to generate semantically equivalent segmentations.

    Source: §1 · p. 2, §3.1 · p. 3
  • Results

    ActionPiece enables the same action to receive different tokens according to surrounding context, while its permutation-based inference remains latency-comparable to baseline methods through parallel processing.

    Source: §3.4 · p. 6
  • Takeaways & Limitations

    ActionPiece provides a context-aware tokenizer for generative recommendation that represents actions as sequences of feature sets rather than independently fixed action tokens.

    Source: §3.1 · p. 3, §5 · p. 9

    The paper identifies future work in aligning ActionPiece with other modalities and extending it to audio modeling, sequential decision-making, and time-series forecasting.

    Source: §5 · p. 9

Abstract

from arXiv · show

Generative recommendation (GR) is an emerging paradigm where user actions are tokenized into discrete token patterns and autoregressively generated as predictions. However, existing GR models tokenize each action independently, assigning the same fixed tokens to identical actions across all sequences without considering contextual relationships. This lack of context-awareness can lead to suboptimal performance, as the same action may hold different meanings depending on its surrounding context. To address this issue, we propose ActionPiece to explicitly incorporate context when tokenizing action sequences. In ActionPiece, each action is represented as a set of item features. Given the action sequence corpora, we construct the vocabulary by merging feature patterns as new tokens, based on their co-occurrence frequency both within individual sets and across adjacent sets. Considering the unordered nature of feature sets, we further introduce set permutation regularization, which produces multiple segmentations of action sequences with the same semantics. Our code is available at: https://github.com/google-deepmind/action_piece.

1. Introduction

Generative recommendation tokenizes actions into autoregressively generated tokens, but existing action-independent tokenization misses contextual meanings. ActionPiece addresses this gap by tokenizing feature-set action sequences contextually while accounting for unordered features.

  • Generative recommendation tokenizes user actions into discrete tokens and autoregressively generates them as recommendations.The shared vocabulary supports scalability and memory efficiency without scaling with the item pool size.Source: §1 · p. 1
  • The same action can carry different meanings across sequences because surrounding items may share attributes such as brand, color, or price range.Source: §1 · p. 1
  • Existing methods tokenize each action independently, so their tokens do not explicitly encode context and instead rely on the autoregressive model to learn contextual generalization.Source: §1 · p. 1
  • ActionPiece builds a vocabulary by repeatedly merging frequently co-occurring feature-token pairs, using different weights for pairs within one set versus across adjacent sets.Source: §1 · p. 2
  • Because action features are unordered sets, ActionPiece applies set permutation regularization to create multiple semantically equivalent tokenizations for training.Randomly permuting features within each set provides data variations and supports ensembling.Source: Figure 1 · p. 1, §1 · p. 2

2. Related Work

Generative recommendation replaces item-sized embedding tables with shared-vocabulary token generation, while language-model tokenizers provide context-aware merging precedents. ActionPiece’s construction follows this merging analogy but operates on sequences of unordered action-feature sets.

ActionPiece method

  • ActionPiece’s comparison framework distinguishes tokenization methods by whether they are contextual and whether their item features or semantic IDs are unordered.Source: Table 1 · p. 2

Generative recommendation

  • Generative recommendation tokenizes items with a shared vocabulary and autoregressively generates recommendation tokens, offering memory-efficiency and scalability benefits.Source: §2 · p. 2

Tokenization for language modeling

  • Language-model tokenizers construct vocabularies by iteratively merging frequent token pairs or pruning tokens to optimize likelihood.Source: §2 · p. 2

ActionPiece method

  • ActionPiece vocabulary construction initializes tokens from item features and iteratively selects the highest-weight co-occurring pair to merge until reaching a target vocabulary size.Source: §2 · p. 3

Tokenization for language modeling

  • Existing action tokenizers resemble context-independent word-level tokenizers, whereas ActionPiece targets context-aware subaction-level tokenization.Source: §2 · p. 3

3. Method

ActionPiece tokenizes chronological sequences of unordered item-feature sets with context-aware tokens. It constructs a vocabulary from weighted within-set and adjacent-set co-occurrences, then uses set permutations for semantically equivalent segmentations and inference-time ensembling.

Problem formulation

  • Each action is an unordered feature set, while the sequence of actions remains chronologically ordered across sets.The tokenizer must therefore preserve order between sets without imposing an order within each set.Source: §3.1 · p. 3
  • ActionPiece maps an action sequence of feature sets to tokens that a generative recommendation model autoregressively generates for next-item prediction.The tokenized sequence may contain more tokens than actions, and generated tokens are parsed into the next-item prediction.Source: §3.1 · p. 3, §3 · p. 3

Vocabulary construction

  • ActionPiece initializes one-feature tokens and iteratively merges frequently co-occurring pairs into a target-size vocabulary.Tokens can represent feature subsets, individual features, complete items, or features spanning multiple items.Source: §3.2.1 · p. 3, §3.2 · p. 3
  • Co-occurrence counting includes token pairs within one set and across adjacent sets, with weights adjusted for pair type and the sizes of the involved sets.The weighting scheme interprets set sequences through randomly permuted, flattened token sequences and accumulates pair weights across the corpus.Source: §3.2.1 · p. 4, Figure 2 · p. 4
  • A linked-list representation updates only affected nodes and neighbors after merges, reducing vocabulary-construction complexity to O(log Q log H · NLm2).Intermediate nodes handle tokens that combine features from multiple action sets.Source: §3.2.1 · pp. 4–5

Segmentation and inference

  • Set permutation regularization creates multiple semantically equivalent segmentations that support training augmentation and inference-time ensembling.The resulting ranking lists can be combined by averaging predicted-item scores; parallel processing keeps inference latency comparable to baseline methods despite additional FLOPs.Source: §3.2.2 · p. 5, §3.3.2 · p. 6, §3.4 · p. 6

4. Experiments

Experiments evaluate ActionPiece against sequential and generative recommendation baselines on three Amazon Reviews datasets, showing consistent gains and examining vocabulary size, segmentation, token utilization, and context-aware tokenization.

Overall Performance

  • Feature-enhanced methods generally outperform item ID-only methods, while generative models perform better among methods using item features.The results support incorporating item semantics and sub-item-level information into generative recommendation.Source: §4.2 · p. 7
  • ActionPiece consistently outperforms all baselines across three datasets, improving NDCG@10 over the strongest baseline by 6.00% to 12.82%.The comparison covers ID-based, feature-enhanced, and generative recommendation methods.Source: §4.2 · p. 7, Table 4 · p. 7

Ablation Study

  • Changing TIGER’s vocabulary size alone does not reproduce ActionPiece’s gains, as all tested variants perform worse than ActionPiece, including variants larger than its vocabulary.This indicates the improvement is not simply caused by scaling vocabulary size upward or downward.Source: §4.3 · pp. 7–8
  • Replacing set permutation regularization with naive segmentation during training or inference degrades performance, while applying it to TIGER alone is insufficient.For context-independent tokenization, permutation changes token order without changing token frequencies; ActionPiece instead derives context-dependent tokens.Source: §4.3 · p. 8
  • Varying vocabulary size reveals a trade-off: larger vocabularies improve recommendation performance and shorten sequences, whereas smaller ones improve memory efficiency.The study evaluates vocabulary sizes from N/A to 40k and uses normalized sequence length to measure tokenized sequence length.Source: §4.4.1 · p. 8

Token Utilization Rate w.r.t. Segmentation Strategy

  • Set permutation regularization raises token utilization from 56.89% under naive segmentation to 87.01% after the first training epoch, with further increases during training.The resulting augmentation improves utilization of ActionPiece tokens and is reported to enhance generalization and performance.Source: §4.4.2 · pp. 8–9

Inference-Time Ensembling

  • Inference-time ensembling with more segmented sequences improves performance, but gains slow at q=5 and q=7 as computational cost increases.The analysis varies q over N/A, 1, 3, 5, and 7.Source: §4.4.3 · p. 9

Case Study

  • ActionPiece can group features from adjacent items into one token, so the same action receives different tokens according to surrounding context.The case study identifies tokens containing features from one item, individual features, complete item features, or multiple adjacent items.Source: §4.5 · p. 9

5. Conclusion

ActionPiece tokenizes feature-set action sequences with context-sensitive merges and uses set permutation regularization to create semantically equivalent segments for training and inference.

  • ActionPiece assigns context-dependent tokens to the same actions by merging feature patterns within and across adjacent action sets.Vocabulary construction weights token-pair structures, including within-set and cross-set co-occurrences.Source: §5 · p. 9
  • Set permutation regularization produces multiple semantically equivalent token sequences that augment training and ensemble inference outputs.Source: §5 · p. 9
  • The authors plan to align ActionPiece tokens with other modalities and extend the tokenizer to set sequence modeling tasks such as audio and time series forecasting.Source: §5 · p. 9

Impact Statement

The paper presents ActionPiece as a context-aware tokenizer intended to improve generative recommendation and personalized preference understanding, with implications for recommender applications.

  • ActionPiece is introduced as a context-aware action sequence tokenizer intended to enhance generative recommendation.Source: Impact Statement · p. 9
  • The stated impact centers on more accurate understanding of user preferences in recommender systems used across e-commerce, entertainment, and social platforms.Source: Impact Statement · p. 9
  • The authors state that the work is not directly correlated with certain societal or ethical concerns.Source: Impact Statement · p. 9

Appendices

The appendices provide notation, detailed vocabulary-construction procedures, and the segmentation algorithm for set permutation regularization.

  • The appendices summarize the paper’s notation in Table 6.Source: A. Notations · p. 14
  • They detail vocabulary construction through iterative Count and Update operations corresponding to Algorithms 2 and 3.Source: B. Algorithmic Details · p. 14, §B.1 · p. 14
  • Algorithm 4 describes segmenting action sequences with set permutation regularization, which can be repeated for augmentation or ensemble inference.Source: §B.2 · p. 14

C. Efficient Vocabulary Construction Implementation

ActionPiece uses incrementally maintained data structures to construct its vocabulary efficiently, with iterative merging dominating the stated complexity and SPR generating alternative segmentations.

Efficient Vocabulary Construction Implementation

  • The Count procedure weights unordered within-set pairs and also processes ordered pairs across adjacent action nodes when constructing co-occurrence statistics.Source: C. Efficient Vocabulary Construction… · p. 15
  • Linked lists localize token-merge edits, heaps with lazy updates prioritize valid co-occurrence counts, and inverted indices retrieve affected sequences without full corpus scans.Source: §C.1 · p. 15
  • The Update procedure merges tokens within an action node or across adjacent nodes, creating an intermediate node for cross-node merges.Source: §C.2 · p. 16
  • Initialization counts within-set token pairs in O(NLm2) time, while iterative merging updates only involved sequences and their co-occurrences.Source: §C.2 · p. 16
  • O(log Q log H · NLm2) is the overall vocabulary-construction complexity, improving on the naive O(QNLm2) bound because iterative merging is updated incrementally.Source: §C.2 · p. 16
  • Set permutation regularization randomly permutes each feature set before applying learned BPE-style merge rules to produce segmented token sequences.Source: §C.2 · p. 17

E.1. Benefits of Set Permutation Regularization

Set permutation regularization (SPR) benefits ActionPiece by increasing token utilization, augmenting training sequences, and enabling inference-time ensembling.

Token utilization

  • SPR raises token utilization from 56.89% to 95.33% by the 5th epoch.It prevents each action’s features from always merging into the most compressed tokens, exposing both high- and low-level tokens during training and inference.Source: §E.1 · pp. 17–18

Data augmentation

  • SPR generates multiple semantically equivalent tokenizations for each action sequence, enriching the token patterns available during training.Without SPR, each sequence has one fixed tokenization; with SPR, permutation-based alternatives provide data augmentation.Source: §E.1 · p. 18

Ensemble

  • SPR also supports inference-time augmentation by ensembling rankings produced from multiple tokenizations.Different augmented token sequences can yield different next-item rankings, whose ensemble can improve recommendation performance.Source: §E.1 · p. 19

Comparison with feature crossing

  • ActionPiece performs data-level feature merging and outperforms flattened feature-input methods in recommendation quality and efficiency.HSTU and variant (2.1) have normalized sequence length values of 1, whereas ActionPiece produces more compact sequences.Source: §E.2 · p. 19

F. Datasets

The experiments use Sports and Beauty as established generative-recommendation benchmarks and introduce the larger CDs dataset to assess scalability, with standardized feature processing across methods.

Datasets

  • Sports and Beauty provide established benchmarks for comparison with existing generative-recommendation results.The study also introduces CDs, which contains about 4× more interactions than Sports for evaluating scalability.Source: F. Datasets · p. 19

Sequence preprocessing

  • Generative methods use sequences truncated to a maximum length of 20, while ID-based and Feature + ID baselines use a maximum length of 50.Users with fewer than 5 reviews are filtered out before truncation.Source: F. Datasets · p. 19

Item features

  • Item text features are formed by combining title, price, brand, feature, categories, and description before sentence embedding.The implementations use sentence-t5-base to encode the combined text.Source: F. Datasets · p. 19

Feature representations

  • UniSRec uses 768-dimensional sentence embeddings directly, whereas TIGER and SPM-SID use four residual-quantization codes with 256 candidates each plus an identification code.Other feature-based baselines and ActionPiece use optimized product quantization, generally with four codes and codebook size 256 per digit; VQ-Rec uses 32 codes.Source: F. Datasets · p. 19

G.3. Generative Recommendation Methods

The generative-recommendation comparison covers tokenization methods ranging from hierarchical item indexing and semantic IDs to flattened or SentencePiece-merged feature tokens.

Generative recommendation methods

  • P5-CID uses hierarchical clustering of user-item interaction Laplacian eigenvectors to assign multi-level item indices.It represents a hierarchical clustering-based action tokenization method.Source: §G.3 · p. 20
  • TIGER quantizes text features into semantic IDs and autoregressively generates them with beam search using beam size 50.The model predicts the next semantic ID and uses beam search to produce top-K recommendations.Source: §G.3 · p. 20
  • LMIndexer tokenizes item text, concatenates the resulting tokens into action sequences, and predicts semantic IDs with self-supervised objectives.Its reported Sports and Beauty results come from the original paper, and it is not reported on CDs because it does not converge there.Source: §G.3 · p. 20
  • HSTU discretizes raw item features into input tokens and arranges the same item features used by ActionPiece in a fixed order.SPM-SID instead applies SentencePiece to merge important semantic-ID patterns within each item before autoregressive generation with T5.Source: §G.3 · p. 20

H. Implementation Details

ActionPiece uses a compact T5-like encoder-decoder, trains generative models with tuned optimization and repeated seeds, and applies beam-search inference to augmented test cases.

Baseline implementation

  • Baseline implementations use published results for several methods and reproduce or tune other methods according to their original recommendations.BERT4Rec, SASRec, FDSA, and S3-Rec are implemented with RecBole, while other methods are implemented separately.Source: H. Implementation Details · p. 21

Model architecture

  • ActionPiece uses a four-layer encoder and decoder with six attention heads of dimension 64.On Sports and Beauty, its token embeddings have dimension 128, feed-forward layers dimension 1024, and 4.46M non-embedding parameters.Source: H. Implementation Details · p. 21

Training

  • Models train from scratch for up to 200 epochs with early stopping based on validation NDCG@10.Training uses batch size 256, learning-rate selection from three values, 10,000 warmup steps, dropout 0.1, and tuned weight decay.Source: H. Implementation Details · p. 21

Inference

  • During inference, ActionPiece autoregressively generates target-item token sequences and applies beam search to each augmented test case.The most probable prefixes are retained in the beam, while training labels use original item features without augmentation or token merging.Source: H. Implementation Details · p. 21
Loading 2502.13581v3…