Merge and Branch: Efficient Tree-Structured Supervised Fine-Tuning of LLMs for Recommendation
Organizations: Georgia Institute of Technology, Atlanta, GA, USA
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.
Figures & tables
| Method | Fwd. | Bwd. | Cache | SFT | Beam |
|---|---|---|---|---|---|
| SGLang ( Zheng et al., 2024b ) | |||||
| DeFT ( Yao et al., 2025 ) | |||||
| Tree Training ( Wang et al., 2026 ) | |||||
| AtSpeed ( Lin et al., 2025b ) | |||||
| UniSGR ( Sun et al., 2026 ) | |||||
| M&B |
| 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% |
| 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 | |
| Latency (ms/request) | Memory (GiB) | |||||
|---|---|---|---|---|---|---|
| Causal | Tree | Improv. | Causal | Tree | Improv. | |
| 64 | 86.04 | 77.12 | 10.4% | 4.02 | 3.31 | 17.6% |
| 128 | 86.41 | 76.33 | 11.7% | 4.70 | 3.32 | 29.4% |
| 256 | 86.33 | 77.06 | 10.7% | 6.07 | 3.34 | 45.0% |
| 512 | 87.31 | 78.04 | 10.6% | 8.86 | 3.39 | 61.8% |
| 1024 | 91.13 | 76.44 | 16.1% | 14.43 | 3.46 | 76.0% |
Appendix figures & tables5 assets
Supplementary material from the paper’s appendix.
Appendix
| 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 |
| Input | M | FB | SB | Recall@5 | NDCG@5 | Recall@10 | NDCG@10 | Time (ms) | Memory (GB) |
|---|---|---|---|---|---|---|---|---|---|
| SID | 0.0555 | 0.0390 | 0.0786 | 0.0464 | 279.92 | 42.96 | |||
| Text | 0.0584 | 0.0413 | 0.0837 | 0.0494 | 3611.06 ∗ | 99.19 ∗ | |||
| SID + Text | 0.0594 | 0.0421 | 0.0842 | 0.0500 | 3674.85 ∗ | 99.19 ∗ | |||
| SID + Text | 0.0546 | 0.0375 | 0.0808 | 0.0459 | 289.57 | 44.16 | |||
| SID + Text | 0.0554 | 0.0381 | 0.0819 | 0.0466 | 295.12 | 45.19 | |||
| SID + Text | 0.0719 | 0.0505 | 0.0982 | 0.0589 | 313.78 | 47.27 |
| Compression | Len. | Recall@5 | NDCG@5 | Recall@10 | NDCG@10 | Time (ms) | Memory (GB) |
|---|---|---|---|---|---|---|---|
| Raw input | 666.6 | 0.0711 | 0.0494 | 0.0976 | 0.0579 | 3650.01 ∗ | 99.58 ∗ |
| Mean pooling | 31.3 | 0.0711 | 0.0495 | 0.0970 | 0.0578 | 185.66 | 30.58 |
| Merger, | 31.3 | 0.0726 | 0.0505 | 0.1000 | 0.0593 | 192.34 | 31.59 |
| Merger, | 38.5 | 0.0728 | 0.0509 | 0.1000 | 0.0596 | 227.53 | 36.82 |
| Merger, | 52.8 | 0.0729 | 0.0511 | 0.0998 | 0.0598 | 340.68 | 47.27 |
| Merger, | 81.4 | 0.0724 | 0.0509 | 0.0992 | 0.0596 | 464.41 | 68.19 |
| Layout | Loss | Recall@5 | NDCG@5 | Recall@10 | NDCG@10 |
|---|---|---|---|---|---|
| Causal | Uniform | 0.0716 | 0.0494 | 0.0993 | 0.0583 |
| Tree | Uniform | 0.0716 | 0.0492 | 0.0989 | 0.0580 |
| Causal | Weighted | 0.0719 | 0.0504 | 0.0993 | 0.0592 |
| Tree | Weighted | 0.0726 | 0.0505 | 0.1000 | 0.0593 |
| Setting | Recall@5 | NDCG@5 | Recall@10 | NDCG@10 |
|---|---|---|---|---|
| Next-item only | 0.0497 | 0.0337 | 0.0747 | 0.0417 |
| +FB , | 0.0527 | 0.0355 | 0.0786 | 0.0439 |
| +FB , | 0.0517 | 0.0348 | 0.0776 | 0.0432 |
| +FB , | 0.0485 | 0.0325 | 0.0732 | 0.0404 |
| +SB , | 0.0703 | 0.0495 | 0.0976 | 0.0583 |
| +SB , | 0.0725 | 0.0510 | 0.0981 | 0.0592 |
Large Language Model-Based Recommendation
Large language model-based recommendation uses language models to personalize ranking, retrieval, and conversational suggestions from text and behavior.
See all 213 papers