Abstract
Large Language Models (LLMs) have transformed recommendation systems (LLMRec) by treating user history as a linguistic sequence. However, the computational cost of processing long user histories creates significant latency and memory bottlenecks. We introduce EARN (Efficient inference Acceleration for LLM-based Recommendation), a framework that optimizes generative recommendation by exploiting the unique layer-wise redundancy found in these tasks. By utilizing "register tokens" to compress user history early in the model and pruning the input prompt mid-model, EARN achieves up to 3.79x speedup and reduces memory usage by 80%, often while improving recommendation accuracy.
The Bottleneck: KV Cache in LLMRec
The primary challenge in deploying LLMs for recommendation is the KV Cache—the memory required to store previous token states to avoid redundant calculations during generation. In recommendation scenarios, user histories can span thousands of tokens, leading to massive memory pressure and slow inference. While general prompt compression methods exist, they often discard vital user interactions. EARN addresses this by identifying that recommendation tasks handle information differently than general natural language processing (NLP) tasks.
Methodology: Register Tokens and Mid-Model Pruning
EARN introduces a novel "mid-model pruning" strategy based on the observation that later layers in recommendation models are highly redundant. The framework operates through two main components:
- Register Tokens: Learnable "prefix" and "suffix" virtual tokens are added to the input. The Prefix Register captures task instructions, while the Suffix Register acts as a summary token, absorbing essential information from the preceding user interaction history.
- Layer-wise Pruning: Instead of processing the entire prompt through all layers, EARN performs full computation only for the first $k$ layers (typically the first quarter of the model). After layer $k$, the model discards the original user history tokens. For all subsequent layers, the model only computes the register tokens and newly generated tokens.
This approach effectively compresses long user histories into dense register tokens early in the inference pipeline, drastically reducing the computational load for the majority of the model's layers.
Key Insights: Sparsity Inversion
The core discovery driving EARN is Layer-wise Sparsity Inversion. In standard NLP tasks (like creative writing), early layers are relatively sparse, and later layers become denser as they synthesize complex information. In recommendation tasks, the opposite occurs: the first few layers perform the heavy lifting of preference extraction, while later layers become increasingly sparse and redundant.
Furthermore, the authors identified Dual Attention Sinks, where LLMs focus almost exclusively on the beginning (instructions) and the end (most recent items) of a prompt. EARN exploits this by placing registers at these specific "sink" positions to capture the most relevant signals.
Experimental Results
EARN was evaluated across three major benchmarks: Beauty, Games, and MovieLens-1M, using Llama-3 and Qwen-2.5 backbones.
- Efficiency: EARN achieved a 2.71x to 3.79x increase in inference throughput. It reduced KV Cache size by 66.7% to 80.8%, enabling significantly larger batch sizes.
- Accuracy: Surprisingly, EARN often outperformed standard full fine-tuning. For instance, on MovieLens with Llama, EARN improved Recall@10 from 0.0247 to 0.0259. The authors suggest that mid-model pruning acts as a "denoising filter," discarding irrelevant historical interactions that might otherwise confuse the model in deeper layers.
- Scalability: While standard models struggle with sequences up to 20k tokens, EARN's performance remains stable, providing even greater relative speedups as sequence length increases.
Conclusion and Future Work
EARN demonstrates that the specific information-processing patterns of recommendation tasks allow for aggressive model pruning that is not possible in general NLP. While the choice of the pruning layer ($k$) remains a critical hyperparameter, the framework offers a path toward real-time, high-accuracy generative recommendation. Future research may explore dynamic pruning, where the model automatically determines the optimal compression point based on the complexity of an individual user's history.
Summary updated