Manuscript Offprint
arXiv:2610.37973Merge and Branch: Efficient Tree-Structured Supervised Fine-Tuning of LLMs for Recommendation
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
LLM-based generative recommendation reads long, text-rich interaction histories but generates only short semantic identifiers (SIDs). This asymmetry makes supervised fine-tuning inefficient: encoding the history is expensive, yet each history usually provides supervision for only one target. We present Merge and Branch (M&B) to reduce input cost and learn more from each encoded history. Merge compresses each historical item's SID and text into a small number of learned tokens. Branch uses the compressed history to predict multiple target SIDs. To share history computation while keeping these targets independent, M&B organizes each example as a shallow, wide tree. We develop tree FlashAttention to execute this layout efficiently, processing the shared history once and propagating gradients from every branch for end-to-end training. A tree-structured key/value cache extends history sharing to constrained decoding. Experiments on public benchmarks show that M&B outperforms strong recommendation baselines while substantially improving training and decoding efficiency.
1 Introduction
Generative recommendation retrieves catalog items by predicting their semantic identifiers (SIDs) from a user's interaction history [28]. SIDs provide compact item representations, while item text, such as titles and categories, supplies additional content that large language models (LLMs) can use to interpret user preferences [10, 13, 41]. Incorporating this text, however, creates an imbalance between input cost and supervision: a model may process thousands of history tokens to predict a next-item SID of only a few tokens. This raises a practical question: how can we reduce the cost of processing each history while learning more from it?
Reducing input cost calls for a compact representation that retains SID and textual information as well as the sequence of interactions. Learning more from each history also requires looking beyond the next item, which provides only one observation of a user's preferences. Additional future interactions in the training sequence offer further observed targets. A trained teacher recommender can also propose synthetic targets, transferring collaborative information through its item predictions. These additional targets should each be predicted from the observed history, without requiring other target items at inference. Naively training a separate example for every target satisfies this requirement but repeatedly processes the same history. We therefore seek a training structure that shares the history across predictions while keeping the targets separate.
To address the challenges, we propose Merge and Branch (M&B), which combines a compact history with multiple independent target branches (Figure 1). Merge compresses each historical item's SID and text into a small number of learned tokens.
Yao Xie
Georgia Institute of Technology
Atlanta, GA, USA

Figure 1: Generative recommendation paradigms. M&B pairs compact SID-text inputs with independent SID targets.
SID-conditioned queries select content within each item, and the resulting tokens remain in chronological order so that the LLM can model dependencies across interactions. Branch uses this compact history to predict the next item, additional observed future items, and teacher-proposed synthetic targets. Each target attends to the shared history and its own preceding SID tokens, forming a shallow tree in which targets cannot read one another. Losses from all branches jointly train the history representation and the LLM.
Efficient execution is essential to realizing the benefit of this structure. We develop tree FlashAttention (tree FA) with forward and backward kernels that support the branch visibility pattern without materializing a dense attention matrix. The kernels compute the shared history once and accumulate gradient contributions from every branch. The same sharing principle extends to constrained beam search. Beam hypotheses use the same history but differ in their generated SIDs, so our tree-structured key/value (KV) cache stores the history once and maintains separate states for each hypothesis.
Experiments on three Amazon domains show that M&B outperforms the sequential and generative recommendation baselines in our evaluation. Ablations show that learning from multiple targets improves recommendation quality with compact history representations. Efficiency measurements demonstrate substantially lower training cost than processing uncompressed SID and text histories. Shared-prefix caching also reduces beam-search latency and memory usage, with the largest benefits at long contexts.
Our contributions are threefold:
- We introduce M&B, an LLM-based generative recommendation framework that reduces history input cost and learns from multiple targets through a shared history.
-
We design an interaction token merger and a multi-target training objective that combines observed and synthetic targets while keeping target predictions independent.
-
We develop tree FlashAttention with forward and backward support and a shared-prefix KV cache to execute multi-target training and constrained beam search efficiently.
LLM recommenders. LLM recommenders differ in how they incorporate item information and construct supervision. P5 and P5-CID formulate recommendation tasks with T5-family encoder-decoder models [10, 16], whereas TALLRec, LLaRA, and CoLLM adapt decoder-only LLMs for candidate-conditioned prediction or selection [3, 22, 40]. For retrieval from the full catalog, BIGRec grounds generated text in catalog items, LC-Rec and EAGER-LLM generate discrete identifiers, and SETRec generates sets of continuous item embeddings [2, 13, 23, 41]. GRAM incorporates collaborative information into item descriptions and fuses separately encoded prompts during decoding [19]. Richer supervision is also studied in language modeling through multi-token prediction [11]. GenRec addresses both input cost and supervision: it linearly merges historical SID embeddings and serializes target items into a page [44]. M&B instead compresses SID and text jointly through learned attention and keeps each target independent of the others. All target losses train the merger and LLM through one shared history.
Tree attention and KV caching. Prefix reuse reduces repeated computation in both inference and training. SGLang and ChunkAttention share KV states across requests with common prefixes [37, 42]. SpecInfer and Medusa use tree masks to verify speculative tokens, while DeFT develops IO-aware attention for tree-structured decoding [4, 27, 36]. In recommendation, AtSpeed verifies speculative beam candidates with a tree mask, and UniSGR's STARK reorganizes KV states for SID beam search [24, 30]. Training additionally requires gradients from every continuation to reach the shared prefix. Tree Training packs branching trajectories for shared forward and backward computation, while AReAL-DTA traverses rollout trees during policy training [31, 39]. M&B targets the shallow trees
Table 1: Support for tree-structured training and decoding. Fwd./Bwd.: FA-style forward/backward kernels, excluding dense masks and path traversal approaches.
| Method | Fwd. | Bwd. | Cache | SFT | Beam |
|---|---|---|---|---|---|
| SGLang [42] | ✓ | ||||
| DeFT [36] | ✓ | ✓ | |||
| Tree Training [31] | ✓ | ✓ | ✓ | ||
| AtSpeed [24] | ✓ | ||||
| UniSGR [30] | ✓ | ✓ | ✓ | ||
| M&B | ✓ | ✓ | ✓ | ✓ | ✓ |
formed by long recommendation histories and short SID branches. Building on FlashAttention [8], its tree kernels support multi-target fine-tuning, and its KV cache applies the same visibility structure to constrained beam search. Table 1 compares these capabilities.
3 Merge and Branch
3.1 Problem Formulation and Overview
For a user , let denote the observed item history, accompanied by item text and any available interaction metadata. Each catalog item has a fixed-length semantic identifier . The model recommends an item by generating its identifier autoregressively from the observed history.
M&B addresses long inputs through interaction token merging and limited supervision through multi-target training (Figure 2). The merger maps each historical item's SID and text embeddings to soft tokens, forming a compact prefix of length . For multi-target training, we attach one SID sequence per target to this prefix. A pretrained LLM processes the prefix and target branches with tree attention at every layer, so each target can read the history without reading other targets. The merger and LLM learn jointly from these predictions. At inference, the same structure lets beam hypotheses share the history's KV cache.
3.2 Interaction Token Merging
Item text supplies useful content but can dominate the history's token count. We compress each interaction independently to shorten the history while keeping the sequence of items explicit. A single merger, shared across items, maps the valid SID and text embeddings to soft tokens , where is the LLM hidden size. The outputs remain in chronological order: the merger selects information within each item, and the LLM models dependencies across items.
SID anchor. An item's SID identifies it in the catalog, while its text describes its content. We first combine the SID embeddings into an anchor for the compressed representation:

Figure 2: Overview of M&B. A lightweight cross-attention merges each interaction into soft tokens, which join the instruction and optional user profile to form the LLM prompt. Tree FlashAttention shares this prefix across independent primary, future, and synthetic SID branches during training, while KV caching reuses the prefix during beam search.
Here is the SID embedding at level , is the LLM token embedding table, and is RMSNorm. The mean gives a direct residual path, while concatenation lets the MLP distinguish SID levels and learn how they relate. When interaction metadata is available, the fusion step in Figure 2 adds learned action-type and time-bucket embeddings to before the following operations.
Content selection. We use cross-attention to select content from the item's SID and text tokens. Each shared learned offset combines with the SID anchor to form a query . Queries and keys have dimension , and values have dimension . Field embeddings distinguish SID and text fields, while sinusoidal encodings indicate token positions. Both are added only to the keys, guiding selection without changing the values. With field label for token and separate RMSNorm layers and , we compute
Because each query depends on the item's SID anchor, it can select different content across items despite sharing the learned offsets.
Residual output. We project the selected content with and add it to the anchor in the LLM hidden space:
This residual retains the anchor; learned offsets guide content selection but are not added to the output. We initialize and to zero, so training starts from the mean SID embedding plus any action-type and time-bucket embeddings and learns the corrections. Increasing yields more summaries with the same merger.
We replace each item's original fields in the prompt with , retaining item boundaries, the task instruction, and any user profile. Compared to Q-Former, which starts from shared learned query embeddings [20], our merger constructs its queries from the item's SID anchor and learned offsets. LONGER merges groups of adjacent interactions [5], while GenRec and Token Factory map item features to soft tokens [6, 44]. Our merger uses SID-conditioned queries to compress SID and text within each interaction. The LLM can thus model the item sequence without reading the full text.
3.3 Multi-Target Training
Supervision sources. A single next-item target captures only one observed preference for a history. Alongside the primary next item , we use additional future targets from the training sequence and synthetic targets from an established recommendation model, e.g., SASRec [17]. The former capture further observed preferences; the latter transfer the teacher's recommendations in a knowledge distillation flavor. The teacher's checkpoint can be selected by validation ranking performance and kept frozen during training. We retain observed target occurrences, including repeated items, and add synthetic targets not already among them, giving branches.
Training objective. For each target, the model predicts the SID from the shared prefix and that target's preceding SID tokens:
The softmax at level is over that level's SID codebook. The number of auxiliary targets can vary, but it should not determine their total influence on training. We therefore assign weights and to the two groups and distribute each weight uniformly over its available targets. For a nonempty group , let denote its mean loss:
(5)
Empty groups contribute no term, and sums the active group weights, including the primary weight of one. Minimizing the mean loss over histories trains the merger, token embeddings, and LLM jointly. The weights thus control each source's supervision strength separately from its target count.
Tree-structured training. Each target should be predicted from the observed history, not from other targets that are unavailable at inference. Processing targets separately satisfies this requirement but repeats the history computation; concatenating them with causal attention introduces dependencies between targets. We instead attach one teacher-forced SID branch per target to . Tree-structured training lets each branch read the entire prefix and its own preceding SID tokens, but not another branch. All branches share the LLM parameters and output projection.
Sharing computation also requires consistent positions and prediction locations. Each branch starts immediately after the history in positional space: its input tokens receive zero-based positions , regardless of their location in the packed sequence. The prefix's last hidden state predicts the first SID token of every target using one shared distribution. Within a branch, the state of predicts . Each target is thus treated as a continuation of the same history. We project only supervised states onto their SID codebooks and skip projection for other history states.
3.4 Tree FlashAttention
A dense implementation of tree attention would still store a quadratic attention matrix. Tree FlashAttention (tree FA) applies the tree structure through tiled attention and online softmax [8].
The packed sequence contains positions: one prefix followed by contiguous SID branches. Prefix tokens use causal attention; branch tokens see the prefix and the causal part of their own branch. For a branch token at packed index , let identify its branch and its offset. The allowed key indices are
where contains the causal part of that branch. Applying this rule at every layer prevents targets from affecting the prefix or one another. With matching position indices, each branch sees the same inputs as a separately executed continuation. Tokenwise projections, normalization, and feed-forward layers preserve this correspondence.
Forward pass. Prefix lengths, branch counts, and SID depth are enough to describe the layout, so the kernel does not need a dense mask. It evaluates the visibility rule within each tile, excluding sibling branches and padding before the softmax update. Each branch query normalizes jointly over the prefix and its own SID keys, preserving ordinary attention over the visible tokens. Running softmax statistics combine successive tiles without storing the attention matrix; the output and log-sum-exp are saved for backward. The kernel supports grouped-query attention and varying prefix lengths and branch counts across examples.
Backward pass. Because every branch uses the same prefix, its loss must contribute to the prefix's gradient. At one attention layer, partition the attention probabilities A into prefix rows p and branch rows j. If and are the corresponding output gradients, including the loss weights, the gradient of prefix values is
Prefix keys likewise receive contributions from prefix and branch queries through the softmax derivative. Tree FA reconstructs the probabilities tile by tile from the saved log-sum-exp and sums these contributions into the shared key/value gradients. Together with the query and residual paths, these gradients reach the merger through the shared prefix computation. Every target therefore trains the history representation while reusing its computation. Appendix A gives the online-softmax recurrence and full gradients.
Computational complexity. The main saving comes from computing the history once rather than once per target. For K targets of SID depth L and a prefix of length T, independent execution processes token positions; the tree processes . This shares prefix projections, feed-forward computation, and saved activations. The number of visible query-key pairs changes from
(8)
Only attention within the history is reused; each branch still reads the history. These counts describe visible pairs rather than hardware FLOPs, since tiles may include masked entries. In summary, token merging shortens the prefix, tree-structured training shares its computation across targets, and tree FA executes this layout without materializing a dense attention matrix.
3.5 Shared-Prefix Beam Search
Beam hypotheses differ in their generated SID tokens but share the same observed history. Duplicating that history's KV states for every beam is therefore unnecessary. We prefill once and retain its keys and values at every LLM layer. A tree-structured KV cache stores this prefix once and keeps separate SID states for each hypothesis. As in training, every active query reads the prefix and its own SID history under the same visibility and position rules.
Table 2: Dataset statistics. Len.: mean interactions per user; Density: observed fraction of user-item pairs.
| Dataset | # Users | # Items | # Inters. | Len. | Density |
|---|---|---|---|---|---|
| Beauty | 22,363 | 12,101 | 198,502 | 8.9 | 0.0734% |
| Sports | 35,598 | 18,357 | 296,337 | 8.3 | 0.0453% |
| Toys | 19,412 | 11,924 | 167,597 | 8.6 | 0.0724% |
Not every SID sequence identifies a catalog item, so a GPU-resident trie restricts each expansion to valid continuations. Beam scores accumulate log-probabilities normalized over the full level codebook; the trie excludes invalid extensions without renormalizing over its children. After selecting the surviving beams, the decoder gathers their SID states from the selected parents. Only these short branch states are copied; the shared prefix stays in place. All beams use the same LLM and level-specific SID projection.
Let denote beam capacity, distinct from the number of training targets . The cache holds at most token states per layer, rather than with duplicated histories, saving stored prefix states. Each hypothesis still computes attention to the history, but wider beams no longer require more copies of it. Training and decoding thus reuse the same tree structure: training combines gradients through a common history, while decoding retains that history as hypotheses change.
4 Experiments
We organize the experiments around four research questions:
-
RQ1: How does M&B compare with existing methods?
-
RQ2: How do token merging and auxiliary supervision affect recommendation accuracy?
-
RQ3: How efficient are training and decoding with M&B?
-
RQ4: How do backbone choice and pretraining settings affect convergence?
4.1 Public Benchmarks (RQ1)
Datasets. Following TIGER [28], we use three domains from the Amazon 2014 5-core reviews [12]: Beauty, Sports & Outdoors (Sports), and Toys & Games (Toys). We order each user's interactions chronologically. Table 2 summarizes the datasets.
Metrics and protocol. We report Recall and NDCG at cutoffs 5 and 10 over the full item catalog. Each test instance has one relevant item, so Recall@K equals Hit Rate@K; invalid or unresolved predictions count as misses. Following TIGER [28], we reserve each user's last interaction for testing and the penultimate interaction for validation, using the rest for training. Validation NDCG@10 selects the maximum history length from {20, 50} and each M&B run's checkpoint. The main benchmark uses the best of five M&B seeds by validation NDCG@10 for all four test metrics.
Implementation. We fine-tune Qwen3-1.7B jointly with the token merger. We quantize Sentence-T5-XXL item embeddings with a three-level RQ-VAE using 256 codes per level and append a deterministic collision suffix, yielding four-token SIDs. Item text comprises the title, category, and description. The main benchmark uses one merged token per historical item and beam width 50. Each
training example supervises the next item, at most one additional future item, and two synthetic targets proposed by a frozen SASRec teacher trained with cross-entropy and selected on validation data. The future and synthetic groups receive weights and . We train for four epochs in BF16 with AdamW and batch size 128, using learning rate for the backbone and merger and for the tied token embeddings. See Appendix B.2 for details.
Baselines. We compare three families: ID-based sequential models, SID-based generative models, and LLM-based recommenders.
-
SASRec [17] uses causal self-attention over item IDs to predict the next item. We train it with binary cross-entropy and one sampled negative per positive.
-
SASRec-CE [18] retains the SASRec architecture but uses cross-entropy over all item IDs. We also use SASRec-CE as M&B's frozen teacher to propose synthetic target items during training.
-
BERT4Rec [29] learns bidirectional representations of interaction sequences by predicting randomly masked items.
-
TIGER [28] quantizes Sentence-T5 item embeddings into hierarchical SIDs and trains a T5-style encoder–decoder to generate the next item's SID.
-
LETTER [32] learns item identifiers from semantics and SASRec collaborative embeddings, using a diversity objective to reduce code assignment bias. We use the LETTER variant built on TIGER's T5 architecture.
-
EAGER [34] shares an encoder between decoders for behavioral and semantic identifiers. It uses DIN behavioral embeddings and combines both decoders' predictions.
-
ETEGRec [25] tokenizes SASRec item embeddings and alternates optimization of the tokenizer and generative recommender, aligning item codes with user preferences.
-
P5-CID [16] uses collaborative item identifiers in T5-based P5 to formulate recommendation as text-to-text generation.
-
LC-Rec [41] aligns learned item indices and collaborative signals with an LLM for generation over the full catalog.
-
EAGER-LLM [13] incorporates DIN behavioral embeddings and semantic information into item indices and aligns these signals with a decoder-only LLM.
-
GRAM [19] adds SASRec information to item descriptions and fuses separately encoded prompts during decoding.
Results come from our runs, the original papers, or published reproductions. Appendix B records the sources and settings.
Results. We compare M&B with sequential and generative recommenders on three Amazon domains (Table 3). M&B consistently outperforms all baselines across all four metrics while compressing each item's SID and text into a single token. Notably, SASRec-CE provides a particularly strong baseline, matching or exceeding the other SID-based and LLM-based methods. Across all three domains and four metrics, M&B improves over the strongest baseline for each metric by 2.48%-16.19%. The following ablations examine in depth how input representation and multi-target supervision contribute to this performance.
4.2 Ablations (RQ2)
Components. We compare SID, text, and combined inputs, then add token merging and future and synthetic supervision to examine
Table 3: Next-item recommendation on Amazon. R/N: Recall/NDCG. Underline: best baseline; bold: best overall. Improv: relative gain over the strongest baseline.
| Family | Method | Beauty | Sports | Toys | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| R@5 | N@5 | R@10 | N@10 | R@5 | N@5 | R@10 | N@10 | R@5 | N@5 | R@10 | N@10 | ||
| ID-based | SASRec | 0.0537 | 0.0376 | 0.0788 | 0.0456 | 0.0293 | 0.0198 | 0.0432 | 0.0243 | 0.0661 | 0.0479 | 0.0860 | 0.0543 |
| SASRec-CE | 0.0680 | 0.0496 | 0.0932 | 0.0577 | 0.0375 | 0.0269 | 0.0537 | 0.0322 | 0.0745 | 0.0554 | 0.0988 | 0.0633 | |
| BERT4Rec | 0.0372 | 0.0260 | 0.0554 | 0.0319 | 0.0161 | 0.0106 | 0.0251 | 0.0135 | 0.0338 | 0.0242 | 0.0475 | 0.0286 | |
| SID-based | TIGER | 0.0454 | 0.0321 | 0.0648 | 0.0384 | 0.0264 | 0.0181 | 0.0400 | 0.0225 | 0.0521 | 0.0371 | 0.0712 | 0.0432 |
| LETTER | 0.0431 | 0.0286 | 0.0672 | 0.0364 | 0.0275 | 0.0180 | 0.0428 | 0.0229 | 0.0436 | 0.0294 | 0.0679 | 0.0372 | |
| EAGER | 0.0618 | 0.0451 | 0.0836 | 0.0525 | 0.0281 | 0.0184 | 0.0441 | 0.0236 | 0.0584 | 0.0464 | 0.0714 | 0.0505 | |
| ETEGRec | 0.0511 | 0.0342 | 0.0785 | 0.0430 | 0.0293 | 0.0187 | 0.0460 | 0.0241 | 0.0450 | 0.0302 | 0.0675 | 0.0374 | |
| LLM-based | P5-CID | 0.0465 | 0.0325 | 0.0668 | 0.0391 | 0.0295 | 0.0214 | 0.0420 | 0.0254 | 0.0223 | 0.0143 | 0.0357 | 0.0186 |
| LC-Rec | 0.0503 | 0.0352 | 0.0715 | 0.0420 | 0.0259 | 0.0175 | 0.0384 | 0.0216 | 0.0543 | 0.0385 | 0.0753 | 0.0453 | |
| EAGER-LLM | 0.0548 | 0.0369 | 0.0830 | 0.0459 | 0.0373 | 0.0251 | 0.0569 | 0.0315 | 0.0510 | 0.0349 | 0.0772 | 0.0433 | |
| GRAM | 0.0641 | 0.0451 | 0.0890 | 0.0531 | 0.0375 | 0.0256 | 0.0554 | 0.0314 | 0.0718 | 0.0516 | 0.0987 | 0.0603 | |
| M&B | 0.0729 | 0.0508 | 0.1004 | 0.0597 | 0.0436 | 0.0301 | 0.0608 | 0.0356 | 0.0792 | 0.0578 | 0.1047 | 0.0660 | |
| Improv. | 7.19% | 2.48% | 7.76% | 3.46% | 16.19% | 11.92% | 6.84% | 10.65% | 6.28% | 4.35% | 5.95% | 4.28% | |

Figure 3: Component ablations on Beauty (). S+T: SID+Text; M: token merging; +FB/+SB: future/synthetic supervision; Full: both. Error bars: SD over five seeds.

(a) Accuracy
(b) Training efficiency
Figure 4: Token-budget ablation on Beauty. Reference lines: uncompressed SID+Text (smaller micro-batch, same effective batch). Error bars: SD over five seeds.
their contributions (Figure 3; Table 6). Combining SID and text is more effective than either input alone under next-item supervision,
but compression alone does not retain this advantage. Within the compact model, synthetic targets provide the largest gain, and adding future targets further improves recommendation accuracy.
Token merging. We vary the number of merged tokens per item, , while retaining all supervision sources (Figure 4; Table 7). Increasing raises sequence length and training cost without consistently improving accuracy. We use in the main benchmark to balance accuracy and efficiency.
Target layout. We compare causal and tree layouts under uniform and group weighting to separate the effects of target dependencies and loss weights (Figure 5). Uniform weighting assigns equal weight to all targets. Group weighting uses next-item weight 1 and future/synthetic group weights and , shared equally among valid targets within each group. Group weighting improves NDCG for both layouts, and the weighted tree layout achieves the highest mean scores. Thus, additional targets improve recommendation without requiring dependencies between them, while balancing their contributions matters for either layout.
4.3 Efficiency (RQ3)
End-to-end training. We measure training step time and peak memory for merged and uncompressed SID+Text histories on H200, using an effective batch size of 128 (Figure 4b). The uncompressed reference uses gradient accumulation. We average a stable 20-step window after warm-up for each of five seeds, excluding compilation. Compact histories reduce both costs, and adding auxiliary branches costs much less than processing the uncompressed history (Table 6). Measurement details are in Appendix B.3.
Attention implementation. We compare the runtime and peak memory of attention forward and backward passes across context lengths, using four independent branches of four tokens and batch size 128 (Figure 6). Standard attention uses the same tree mask;

Figure 5: Target layout and loss weighting on Beauty (). Each marker represents one of five seeds; Uniform/Weighted denote uniform/group weighting.

Figure 6: Attention forward–backward time and memory on H200 (). Means over five repeats; memory: peak allocated; OOM: out of memory. Causal FA uses a causal mask rather than a tree mask.
Causal FA provides a performance reference with a causal mask. Tree FA supports independent branches with modest runtime overhead and the same peak allocated memory as Causal FA. Avoiding a dense attention matrix also makes tree FA faster and more memory-efficient than standard attention at long contexts. Tree FA runs at the longest context, where standard attention runs out of memory.
Constrained decoding. We measure beam-search latency and peak memory across context lengths at beam width 100 (Table 4). We construct synthetic prefixes by resampling prepared history embeddings to the desired length, retaining the catalog constraints defined by the real trie. Both methods use the same checkpoint, prefixes, and decoding rules; the causal implementation copies prefix KV states for each beam, whereas our implementation stores the prefix KV states only once. Timing includes model prefill, all SID decoding steps, and beam updates; peak memory includes the model and cache. Memory savings grow with context length, and
Table 4: SID beam search on H200 ( beams, context length ). Causal: causal FA with duplicated per-beam KV caches; Tree: tree FA with a shared-prefix KV cache. Mean SD over five repeats; memory: total peak allocated. Improv: reduction relative to Causal.
| Latency (ms/request) | Memory (GiB) | |||||
|---|---|---|---|---|---|---|
| Causal | Tree | Improv. | Causal | Tree | Improv. | |
| 64 | 86.04 0.48 | 77.12 1.55 | 10.4% | 4.02 0.00 | 3.31 0.00 | 17.6% |
| 128 | 86.41 0.71 | 76.33 0.62 | 11.7% | 4.70 0.00 | 3.32 0.00 | 29.4% |
| 256 | 86.33 0.44 | 77.06 0.41 | 10.7% | 6.07 0.00 | 3.34 0.00 | 45.0% |
| 512 | 87.31 0.99 | 78.04 1.42 | 10.6% | 8.86 0.00 | 3.39 0.00 | 61.8% |
| 1024 | 91.13 0.39 | 76.44 0.33 | 16.1% | 14.43 0.00 | 3.46 0.00 | 76.0% |
| 2048 | 139.85 0.27 | 83.85 0.90 | 40.0% | 25.56 0.00 | 3.62 0.00 | 85.8% |
the longest contexts also show the largest speedup. The smaller speedup at short contexts is consistent with other model and search operations accounting for more of the runtime. Sharing the prefix cache is therefore especially useful for long histories. Appendix B.3 describes the implementation and differences in outputs.
4.4 Convergence (RQ4)
Backbones and pretraining. We compare backbones through their learning curves and remove pretraining or instructions from Qwen3-1.7B (Figure 7). Modern decoder-only LLMs, Qwen3 and LLaMA, converge faster than T5 in these experiments, reaching higher recommendation quality within fewer epochs. The TIGER-style T5 backbone continues to improve with a longer schedule, so a short training budget can understate its performance. Larger models do not always perform better: Qwen3-1.7B achieves the best test performance at selected checkpoints.
Qwen3 and LLaMA overfit late in training: training loss continues to fall while recommendation performance declines. Pretraining and instructions mainly accelerate early progress; removing either slows initial learning, but the gap narrows with further training. These trends favor selecting checkpoints by validation quality rather than training loss or a fixed epoch count.
To examine how the merger represents items beyond the training set, we visualize SID, text, and merged representations in a common t-SNE map fitted to text embeddings (Figure 8). Merged representations of items first seen in validation or test mix with training items rather than forming separate clusters by data split.

(a) Training loss
(b) Test performance

Figure 7: Training curves on Beauty with different backbones. Vertical dashed lines mark the boundaries of epochs 1–4; markers denote validation-selected checkpoints.

(a) SID tokens

(b) Text tokens

(c) Merged tokens
Figure 8: Embedding distributions on Beauty. SID and merged embeddings are projected into the t-SNE space fitted to text embeddings. Colors indicate the data split where items first appear; Unseen denotes tokens absent from the data.
5 Conclusion
M&B makes LLM-based recommendation more efficient by reducing the cost of text-rich histories and learning from multiple targets. Public benchmarks demonstrate strong recommendation performance alongside substantial reductions in training and decoding cost. The ablations clarify an important finding: additional training targets improve recommendation, whereas allocating more tokens to each item does not consistently help. Sharing history computation makes this richer supervision possible at a small additional cost. These results show the value of learning more from each history, rather than simply increasing the amount of input processed by the model.
The current model assigns the same token budget to every item and predicts targets independently. Future work could allocate tokens according to the information each item provides. Jointly generating recommendation lists could also capture relationships among items and balance relevance with diversity.
References
[1] Andrea Bacciu, Federico Siciliano, Nicola Tonellotto, and Fabrizio Silvestri. 2023. Integrating Item Relevance in Training Loss for Sequential Recommender Systems. In Proceedings of the 17th ACM Conference on Recommender Systems. 1114–1119. doi:10.1145/3604915.3610643
[2] Keqin Bao, Jizhi Zhang, Wenjie Wang, Yang Zhang, Zhengyi Yang, Yanchen Luo, Chong Chen, Fuli Feng, and Qi Tian. 2025. A Bi-Step Grounding Paradigm for Large Language Models in Recommendation Systems. ACM Transactions on Recommender Systems 3, 4 (2025), 53:1–53:27. doi:10.1145/3716393
[3] Keqin Bao, Jizhi Zhang, Yang Zhang, Wenjie Wang, Fuli Feng, and Xiangnan He. 2023. TALLRec: An Effective and Efficient Tuning Framework to Align Large Language Model with Recommendation. In Proceedings of the 17th ACM Conference on Recommender Systems. 1007–1014. doi:10.1145/3604915.3608857
[4] Tianle Cai, Yuhong Li, Zhengyang Geng, Hongwu Peng, Jason D. Lee, Deming Chen, and Tri Dao. 2024. Medusa: Simple LLM Inference Acceleration Framework with Multiple Decoding Heads. In Proceedings of the 41st International Conference on Machine Learning (Proceedings of Machine Learning Research, Vol. 235). 5209–5235.
[5] Zheng Chai, Qin Ren, Xijun Xiao, Huizhi Yang, Bo Han, Sijun Zhang, Di Chen, Hui Lu, Wenlin Zhao, Lele Yu, Xionghang Xie, Shiru Ren, Xiang Sun, Yaocheng Tan, Peng Xu, Yuchao Zheng, and Di Wu. 2025. LONGER: Scaling Up Long Sequence Modeling in Industrial Recommenders. In Proceedings of the 19th ACM Conference on Recommender Systems. 247–256. doi:10.1145/3705328.3748065
[6] Xilun Chen, Shao-Chuan Wang, Baykal Cakici, Lukasz Heldt, Lichan Hong, Raghu Keshavan, Anirudh Nath, Li Wei, and Xinyang Yi. 2026. Token Factory: Efficiently Integrating Diverse Signals into Large Recommendation Models. In Proceedings of the 20th ACM Conference on Recommender Systems. 1534–1541. doi:10.1145/3773078.3831865
[7] Tri Dao. 2024. FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning. In International Conference on Learning Representations. https://openreview.net/forum?id=mZn2Xyh9Ec
[8] Tri Dao, Daniel Y. Fu, Stefano Ermon, Atri Rudra, and Christopher Ré. 2022. FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness. In Advances in Neural Information Processing Systems, Vol. 35. 16344–16359. doi:10.52202/068431-1189
[9] Jiaxin Deng, Shiyao Wang, Kuo Cai, Lejian Ren, Qigen Hu, Weifeng Ding, Qiang Luo, and Guorui Zhou. 2025. OneRec: Unifying Retrieve and Rank with Generative Recommender and Iterative Preference Alignment. arXiv:2502.18965 https://arxiv.org/abs/2502.18965
[10] Shijie Geng, Shuchang Liu, Zuohui Fu, Yingqiang Ge, and Yongfeng Zhang. 2022. Recommendation as Language Processing (RLP): A Unified Pretrain, Personalized Prompt & Predict Paradigm (P5). In Proceedings of the 16th ACM Conference on Recommender Systems. 299–315. doi:10.1145/3523227.3546767
[11] Fabian Gloeckle, Badr Youbi Idrissi, Baptiste Rozière, David Lopez-Paz, and Gabriel Synnaeve. 2024. Better & Faster Large Language Models via Multi-token Prediction. In Proceedings of the 41st International Conference on Machine Learning (Proceedings of Machine Learning Research, Vol. 235). PMLR, 15706–15734. https://proceedings.mlr.press/v235/gloeckle24a.html
[12] Ruining He and Julian McAuley. 2016. Ups and Downs: Modeling the Visual Evolution of Fashion Trends with One-Class Collaborative Filtering. In Proceedings of the 25th International Conference on World Wide Web. 507–517.
doi:10.1145/2872427.2883037
[13] Minjie Hong, Yan Xia, Zehan Wang, Jieming Zhu, Ye Wang, Sihang Cai, Xiaoda Yang, Quanyu Dai, Zhenhua Dong, Zhimeng Zhang, and Zhou Zhao. 2025. EAGER-LLM: Enhancing Large Language Models as Recommenders through Exogenous Behavior-Semantic Integration. In Proceedings of the ACM on Web Conference 2025. 2754–2762. doi:10.1145/3696410.3714933
[14] Yupeng Hou, Jiacheng Li, Ashley Shin, Jinsung Jeon, Abhishek Santhanam, Wei Shao, Kaveh Hassani, Ning Yao, and Julian McAuley. 2025. Generating Long Semantic IDs in Parallel for Recommendation. In Proceedings of the 31st ACM SIGKDD Conference on Knowledge Discovery and Data Mining V.2. ACM, 956–966. doi:10.1145/3711896.3736979
[15] Yupeng Hou, Jianmo Ni, Zhanhui Ke, Noeven Sachdeva, Wang-Cheng Kang, Ed H. Chi, Julian McAuley, and Derek Zhiyuan Cheng. 2025. ActionPiece: Contextually Tokenizing Action Sequences for Generative Recommendation. In Proceedings of the 42nd International Conference on Machine Learning (Proceedings of Machine Learning Research, Vol. 267). 24004–24024.
[16] Wenyue Hua, Shuyuan Xu, Yingqiang Ge, and Yongfeng Zhang. 2023. How to Index Item IDs for Recommendation Foundation Models. In Proceedings of the Annual International ACM SIGIR Conference on Research and Development in Information Retrieval in the Asia Pacific Region. 195–204. doi:10.1145/3624918.3625339
[17] Wang-Cheng Kang and Julian McAuley. 2018. Self-Attentive Sequential Recommendation. In 2018 IEEE International Conference on Data Mining, 197–206. doi:10.1109/ICDM.2018.00035
[18] Anton Klenitskiy and Alexey Vasilev. 2023. Turning Dross Into Gold Loss: Is BERT4Rec Really Better than SASRec?. In Proceedings of the 17th ACM Conference on Recommender Systems. 1120–1125. doi:10.1145/3604915.3610644
[19] Sunkyung Lee, Minjin Choi, Eunseong Choi, Hye-young Kim, and Jongwuk Lee. 2025. GRAM: Generative Recommendation via Semantic-Aware Multi-Granular Late Fusion. In Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers). 33294–33312. doi:10.18653/v1/2025.acl-long.1596
[20] Junnan Li, Dongxu Li, Silvio Savarese, and Steven Hoi. 2023. BLIP-2: Bootstrapping Language-Image Pre-training with Frozen Image Encoders and Large Language Models. In Proceedings of the 40th International Conference on Machine Learning (Proceedings of Machine Learning Research, Vol. 202). PMLR, 19730–19742. https://proceedings.mlr.press/v202/li23q.html
[21] Zihao Li, Aixin Sun, and Chenliang Li. 2024. DiffuRec: A Diffusion Model for Sequential Recommendation. ACM Transactions on Information Systems 42, 3 (2024), 661–6628. doi:10.1145/3631116
[22] Jiayi Liao, Sihang Li, Zhengyi Yang, Jiancan Wu, Yancheng Yuan, Xiang Wang, and Xiangnan He. 2024. LLaRA: Large Language-Recommendation Assistant. In Proceedings of the 47th International ACM SIGIR Conference on Research and Development in Information Retrieval. 1785–1795. doi:10.1145/3626772.3657690
[23] Xinyu Lin, Haihan Shi, Wenjie Wang, Fuli Feng, Qifan Wang, See-Kiong Ng, and Tat-Seng Chua. 2025. Order-Agnostic Identifier for Large Language Model-Based Generative Recommendation. In Proceedings of the 48th International ACM SIGIR Conference on Research and Development in Information Retrieval. 1923–1933. doi:10.1145/3726302.3730053
[24] Xinyu Lin, Chaoqun Yang, Wenjie Wang, Yongqi Li, Cunxiao Du, Fuli Feng, See-Kiong Ng, and Tat-Seng Chua. 2025. Efficient Inference for Large Language Model-Based Generative Recommendation. In The Thirteenth International Conference on Learning Representations.
[25] Enze Liu, Bowen Zheng, Cheng Ling, Lantao Hu, Han Li, and Wayne Xin Zhao. 2025. Generative Recommender with End-to-End Learnable Item Tokenization. In Proceedings of the 48th International ACM SIGIR Conference on Research and Development in Information Retrieval. 729–739. doi:10.1145/3726302.3729989
[26] Zhao Liu, Yichen Zhu, Yiqing Yang, Xiao Lv, Guoping Tang, Rui Huang, Qiang Luo, Ruiming Tang, and Guorui Zhou. 2026. DiffGRM: Diffusion-based Generative Recommendation Model. In Proceedings of the ACM Web Conference 2026. ACM, 5853–5864. doi:10.1145/3774904.3792156
[27] Xupeng Miao, Gabriele Oliaro, Zhihao Zhang, Xinhao Cheng, Zeyu Wang, Zhengxin Zhang, Rae Ying Yee Wong, Alan Zhu, Lijie Yang, Xiaoxiang Shi, Chunan Shi, Zhuoming Chen, Daiyaan Arfeen, Reyna Abhyankar, and Zhihao Jia. 2024. SpecInfer: Accelerating Large Language Model Serving with Tree-Based Speculative Inference and Verification. In Proceedings of the 29th ACM International Conference on Architectural Support for Programming Languages and Operating Systems, Volume 3. 932–949. doi:10.1145/3620666.3651335
[28] Shashank Rajput, Nikhil Mehta, Anima Singh, Raghunandan Hulika Keshavan, Trung Vu, Lukasz Heldt, Lichan Hong, Yi Tay, Vinh Q. Tran, Jonah Samost, Maciej Kula, Ed H. Chi, and Maheswaran Sathiamorthry. 2023. Recommender Systems with Generative Retrieval. In Advances in Neural Information Processing Systems, Vol. 36. 10299–10315. doi:10.52202/075280-0452
[29] Fei Sun, Jun Liu, Jian Wu, Changhua Pei, Xiao Lin, Wenwu Ou, and Peng Jiang. 2019. BERT4Rec: Sequential Recommendation with Bidirectional Encoder Representations from Transformer. In Proceedings of the 28th ACM International Conference on Information and Knowledge Management. 1441–1450. doi:10.1145/3357384.3357895
[30] Jiawei Sun, Jun Yang, Ziyue Guo, Dongyue Xu, Jianan Yan, Lifang Deng, and Xiaoyi Zeng. 2026. UniSGR: Unified Framework for Semantic ID Generation and Ranking. arXiv:2607.04068 https://arxiv.org/abs/2607.04068
[31] Jinghui Wang, Shaojie Wang, Yinghan Cui, Xuxing Chen, Chao Wang, Liang Huang, Xiaojiang Zhang, Junyi Peng, Li Wan, Haotian Zhang, and Bin Chen. 2026. Tree Training: Accelerating Agentic LLMs Training via Shared Prefix Reuse. arXiv:2511.00413v5 https://arxiv.org/abs/2511.00413v5
[32] Wenjie Wang, Honghui Bao, Xinyu Lin, Jizhi Zhang, Yongji Li, Fuli Feng, See-Kiong Ng, and Tat-Seng Chua. 2024. Learnable Item Tokenization for Generative Recommendation. In Proceedings of the 33rd ACM International Conference on Information and Knowledge Management. 2400–2409. doi:10.1145/3627673.3679569
[33] Wenjie Wang, Yiyan Xu, Fuli Feng, Xinyu Lin, Xiangnan He, and Tat-Seng Chua. 2023. Diffusion Recommender Model. In Proceedings of the 46th International ACM SIGIR Conference on Research and Development in Information Retrieval. ACM, 832–841. doi:10.1145/3539618.3591663
[34] Ye Wang, Jiahao Xun, Minjie Hong, Jieming Zhu, Tao Jin, Wang Lin, Haoyuan Li, Linjun Li, Yan Xia, Zhou Zhao, and Zhenhua Dong. 2024. EAGER: Two-Stream Generative Recommender with Behavior-Semantic Collaboration. In Proceedings of the 30th ACM SIGKDD Conference on Knowledge Discovery and Data Mining. 3245–3254. doi:10.1145/3637528.3671775
[35] Zhengyi Yang, Jiancan Wu, Zhicai Wang, Yancheng Yuan, Xiang Wang, and Xiangnan He. 2023. Generate What You Prefer: Reshaping Sequential Recommendation via Guided Diffusion. In Advances in Neural Information Processing Systems, Vol. 36. Curran Associates, Inc., 24247–24261. doi:10.52202/075280-1054
[36] Jinwei Yao, Kaiqi Chen, Kexun Zhang, Jiaxuan You, Binhang Yuan, Zeke Wang, and Tao Lin. 2025. DeFT: Decoding with Flash Tree-Attention for Efficient Tree-Structured LLM Inference. In The Thirteenth International Conference on Learning Representations.
[37] Lu Ye, Zao Yong Huang, and Yang Li. 2024. ChunkAttention: Efficient Self-Attention with Prefix-Aware KV Cache and Two-Phase Partition. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers). 11608–11620. doi:10.18653/v1/2024.acl-long.623
[38] Jiaqi Zhai, Lucy Liao, Xing Liu, Yueming Wang, Rui Li, Xuan Cao, Leon Gao, Zhaojie Gong, Fangda Gu, Jiayuan He, Yinghai Lu, and Yu Shi. 2024. Actions Speak Louter than Words: Trillion-Parameter Sequential Transducers for Generative Recommendations. In Proceedings of the 41st International Conference on Machine Learning (Proceedings of Machine Learning Research, Vol. 235). 58484–58509.
[39] Jiarui Zhang, Yuchen Yang, Ran Yan, Zhiyu Mei, Liyuan Zhang, Daifeng Li, Wei Fu, Jiaxuan Gao, Shusheng Xu, Yi Wu, and Binhang Yuan. 2026. AReal-DTA: Dynamic Tree Attention for Efficient Reinforcement Learning of Large Language Models. In Proceedings of the 43rd International Conference on Machine Learning (Proceedings of Machine Learning Research, Vol. 306). PMLR, 159938–159953. https://proceedings.mlr.press/v306/zhang26hr.html
[40] Yang Zhang, Fuli Feng, Jizhi Zhang, Keqin Bao, Qifan Wang, and Xiangnan He. 2025. CoLLM: Integrating Collaborative Embeddings Into Large Language Models for Recommendation. IEEE Transactions on Knowledge and Data Engineering 37, 5 (2025), 2329–2340. doi:10.1109/TKDE.2025.3540912
[41] Bowen Zheng, Yupeng Hou, Hongyu Lu, Yu Chen, Wayne Xin Zhao, Ming Chen, and Ji-Rong Wen. 2024. Adapting Large Language Models by Integrating Collaborative Semantics for Recommendation. In 2024 IEEE 40th International Conference on Data Engineering. 1435–1448. doi:10.1109/ICDE60146.2024.00118
[42] Lianmin Zheng, Liangsheng Yin, Zhiqiang Xie, Chuyue Sun, Jeff Huang, Cody Hao Yu, Shiyi Cao, Christos Kozyrakis, Ion Stoica, Joseph E. Gonzalez, Clark W. Barrett, and Ying Sheng. 2024. SGLang: Efficient Execution of Structured Language Model Programs. In Advances in Neural Information Processing Systems, Vol. 37. 62557–62583. doi:10.52202/079017-2000
[43] Yunqin Zhu, Chao Wang, Qi Zhang, and Hui Xiong. 2024. Graph Signal Diffusion Model for Collaborative Filtering. In Proceedings of the 47th International ACM SIGIR Conference on Research and Development in Information Retrieval. ACM, 1380–1390. doi:10.1145/3626772.3657759
[44] Yanyan Zou, Junbo Qi, Lunsong Huang, Yu Li, Kewei Xu, Jiahao Gao, Binglei Zhao, Xuanhua Yang, Sulong Xu, and Shengjie Li. 2026. GenRec: A Preference-Oriented Generative Framework for Large-Scale Recommendation. In Proceedings of the 49th International ACM SIGIR Conference on Research and Development in Information Retrieval. 5118–5123. doi:10.1145/3805712.3808437
A Tree FlashAttention Derivation
The following equations describe one attention head; in grouped-query attention, the key/value gradients are also summed over the query heads that share them. For a query row, let be the scaled query-key score in tile and its value. Invisible positions have score . Starting with , , and , the online softmax recurrence is
(9)
Tiles with no visible entries for the row leave its state unchanged. After the last tile , the output is , and the saved log-sum-exp is . Joint normalization across prefix and branch tiles gives a single softmax over the visible keys.
The backward pass recomputes the visible probabilities as . Let and define the score derivative
with outside the visibility set. At head dimension , block-wise accumulation gives
(11)
Branch keys and values receive contributions only from their own branch queries. The gradient matrix G stacks rows and already includes the normalized supervision weights. These formulas express the computation in blocks; the kernel reconstructs and consumes tile probabilities without storing the full A or D.
With matching positions and zero dropout, the packed graph has the same visible predecessors as independently executed branches. At each layer, its single prefix represents the identical prefix computation in those separate sequences; the accumulated adjoints collect every use of that computation. The graphs thus give the same weighted objective and gradients in exact arithmetic, but floating-point outputs need not be identical.
B Experimental Details
B.1 Baselines
SASRec, SASRec-CE, BERT4Rec, ETEGRec, LETTER on Sports and Toys, EAGER-LLM on Toys, and M&B are our runs. TIGER, LETTER on Beauty, EAGER, EAGER-LLM on Beauty and Sports, and GRAM are taken from their original papers. P5-CID and LC-Rec are taken from the published GRAM reproduction because their original evaluations do not cover the same three Amazon domains.
We reproduce LETTER on Sports and Toys with the official LETTER-TIGER implementation, ETEGRec on all three datasets with its alternating tokenizer-recommender procedure, and EAGER-LLM on Toys with its released implementation. We follow the recommended settings for each implementation.
SASRec uses binary cross-entropy with one uniformly sampled negative per positive item. SASRec-CE uses cross-entropy over the full item catalog, following prior work [18]. BERT4Rec uses masked-item prediction. All three models use Adam. We search history length in {20, 50}, hidden size/head count in {32/1, 64/2, 128/4, 256/8}, layers in {2, 4}, learning rate in , weight decay in , and dropout in . BERT4Rec additionally searches mask ratio in . For each dataset, we select the run with the highest validation NDCG@10 and report its test metrics.
B.2 M&B on Public Data
We fine-tune Qwen3 1.7B and use the frozen SASRec-CE checkpoint with the highest validation NDCG@10 to construct synthetic branches. Each historical item is represented by its SID, title, category, and description. The runs reported in the main benchmark use . SIDs are obtained from Sentence-T5-XXL content embeddings with a 3-level, 256-way RQ-VAE and one deterministic collision-suffix token, giving SID depth . The maximum input history length is 20. Each training window has the next observed item, at most one additional future item, and two synthetic targets. Windows with no additional future item are retained; no held-out item is used to fill a missing branch. We use group weights and , distributed over the valid branches in each group as in Section 3.3.
The token merger uses attention dimension and value dimension . The MLP in the SID anchor uses a hidden dimension of 512. Public benchmarks use SID and text inputs without action-type or time-bucket embeddings.
All runs use tree attention, bfloat16, AdamW, batch size 128, weight decay , 200 warmup steps, cosine decay, 4 epochs, and beam width 50. The backbone and token merger use learning rate , while the tied token embeddings use learning rate . We evaluate the model every 500 steps and at the end of each epoch. The final checkpoint is selected by validation NDCG@10.
B.3 Efficiency Measurement
All efficiency measurements use H200. Our attention benchmark follows FA-2 [7], using BF16, 16 query heads, 8 KV heads, head dimension 128, and four branches of four tokens each. Standard attention materializes the score matrix and applies the same tree mask as tree FA. Causal FA uses FA-2 with a causal mask at matching tensor shapes and total length . At batch size 128, we average 30 forward–backward iterations after warm-up in each of five repeats. Table 5 shows that tree FA uses the same peak allocated memory as causal FA, with negligible runtime overhead across the tested contexts. In contrast, the cost of standard attention with an explicit mask grows rapidly with context length.
Table 5: Attention forward–backward cost on H200 (). Mean ± SD over five repeats; memory: peak allocated; OOM: out of memory. Causal FA uses a causal mask.
| Context length | Time (ms) | Memory (GiB) | ||||
|---|---|---|---|---|---|---|
| Standard attention | Tree FA | Causal FA | Standard attention | Tree FA | Causal FA | |
| 64 | 1.564 ± 0.042 | 0.590 ± 0.001 | 0.545 ± 0.003 | 0.475 ± 0.000 | 0.502 ± 0.000 | 0.502 ± 0.000 |
| 128 | 2.112 ± 0.001 | 1.160 ± 0.002 | 0.980 ± 0.002 | 1.082 ± 0.000 | 0.878 ± 0.000 | 0.878 ± 0.000 |
| 256 | 5.925 ± 0.001 | 2.237 ± 0.002 | 1.872 ± 0.001 | 3.051 ± 0.000 | 1.505 ± 0.000 | 1.505 ± 0.000 |
| 512 | 19.277 ± 0.000 | 4.712 ± 0.003 | 4.080 ± 0.002 | 9.989 ± 0.000 | 2.759 ± 0.000 | 2.759 ± 0.000 |
| 1,024 | 71.106 ± 0.015 | 11.404 ± 0.132 | 10.513 ± 0.182 | 35.865 ± 0.000 | 5.268 ± 0.000 | 5.268 ± 0.000 |
| 2,048 | OOM | 33.205 ± 0.047 | 32.183 ± 0.065 | OOM | 10.286 ± 0.000 | 10.286 ± 0.000 |
For decoding, we use batch size one, beam width 100, and a Qwen3-1.7B model trained for four epochs with . Synthetic contexts of 64–2048 tokens are sampled from Beauty history embeddings; both methods use identical inputs and catalog constraints. CUDA-synchronized timing includes prefill and beam search, excluding shared input preparation and trie construction. Memory includes the model, inputs, cache, outputs, and workspace. We report mean and sample standard deviation over five repeats, averaging latency over eight prefixes per repeat. Table 4 measures beam-search efficiency. Numerical differences may change beam candidates; the timing comparison does not assume identical output lists.
For end-to-end training in Tables 6 and 7, we use tree FA, BF16, and a compiled backbone. Each configuration uses five independent runs and effective batch size 128. We average 20 optimizer steps after warm-up, excluding compilation and retaining the same
learning-rate schedule. Memory is peak allocated memory in decimal GB. We report the mean and sample standard deviation across the five runs. The component and token-budget ablation results show that auxiliary supervision improves the recommendation performance, whereas additional queries increase training cost without consistently improving accuracy.
B.4 Auxiliary Branch Counts and Weights
Table 9 studies future and synthetic supervision separately, each added to the next-item objective. FB×1 uses at most one available future item. SB×k uses synthetic branches sharing group weight , with future supervision disabled. A lighter future loss is more effective, while synthetic supervision benefits from a moderate weight: the best tested settings are and SB×2 with . Adding more synthetic branches at the same total weight improves Recall@10 but reduces NDCG@10, suggesting a trade-off between retrieval coverage and top-ranked relevance.
Table 6: Component ablations on Beauty (); notation follows Figure 3. Mean SD over five runs; bold: best accuracy. Time: optimizer-step latency; memory: peak allocated. *: micro-batch 16, accumulation 8.
| Input | M | FB | SB | Recall@5 | NDCG@5 | Recall@10 | NDCG@10 | Time (ms) | Memory (GB) |
|---|---|---|---|---|---|---|---|---|---|
| SID | |||||||||
| Text | |||||||||
| SID + Text | |||||||||
| SID + Text | ✓ | ||||||||
| SID + Text | ✓ | ✓ | |||||||
| SID + Text | ✓ | ✓ | |||||||
| SID + Text | ✓ | ✓ | ✓ |
Table 7: Token-budget ablation on Beauty with full supervision. Len.: mean input tokens. Conventions and * follow Table 6.
| Compression | Len. | Recall@5 | NDCG@5 | Recall@10 | NDCG@10 | Time (ms) | Memory (GB) |
|---|---|---|---|---|---|---|---|
| Raw input | 666.6 | ||||||
| Mean pooling | 31.3 | ||||||
| Merger, | 31.3 | ||||||
| Merger, | 38.5 | ||||||
| Merger, | 52.8 | ||||||
| Merger, | 81.4 |
Table 8: Target layout and loss weighting on Beauty (). Mean SD over five runs; bold: best results.
| Layout | Loss | Recall@5 | NDCG@5 | Recall@10 | NDCG@10 |
|---|---|---|---|---|---|
| Causal | Uniform | ||||
| Tree | Uniform | ||||
| Causal | Weighted | ||||
| Tree | Weighted |
Table 9: Number and weights of auxiliary branches on Beauty (). Mean SD over five runs. FB/SB: future/synthetic branches; shading: selected settings; bold: best results.
| Setting | Recall@5 | NDCG@5 | Recall@10 | NDCG@10 |
|---|---|---|---|---|
| Next-item only | ||||
| +FB×1, | ||||
| +FB×1, | ||||
| +FB×1, | ||||
| +SB×2, | ||||
| +SB×2, | ||||
| +SB×2, | ||||
| +SB×4, | ||||
| Full M&B |