TL;DR
Running personalized Large Language Models (LLMs) directly on edge devices is heavily constrained by small context windows and limited memory. This paper introduces a clustering-driven memory compression framework that groups similar past user interactions together and merges them before prompting the LLM. This approach slashes the required memory token budget by 50% compared to direct concatenation while actually improving personalization accuracy.
What Problem Does This Paper Address?
To deliver high-quality personalization (like writing in a user's specific style or remembering past preferences), LLMs need access to historical user data. The standard approach is simple: retrieve relevant past interactions and paste (concatenate) them directly into the prompt context window.
However, for on-device LLMs (typically small 1B–3B parameter models running on smartphones), this strategy quickly breaks down. These models have tight context windows (often 1,024 to 2,048 tokens). Naively concatenating history rapidly exhausts this space. While you can compress memories by simply averaging their vector representations, doing so blends completely different topics together. This creates "semantic conflicts" that degrade the model's generation quality. The authors set out to find a middle ground: a method that reduces token overhead without muddying the semantic waters.
Methods
The authors propose a multi-step pipeline designed to compress user history intelligently before it reaches the LLM:
- Retrieval & Tokenization: For a given user prompt, the system retrieves the top $N$ most relevant historical documents using BM25. Each document is individually compressed into a fixed number of memory tokens ($Dm$) using a specialized, parameter-efficient compressor (a frozen LLM combined with trained LoRA adapters).
- K-Means Clustering: Instead of treating all memories equally, the system applies K-Means clustering to group the $N$ memory representations into $K$ distinct clusters based on semantic similarity.
- Intra-Cluster Merging: Within each cluster, the memory tokens are averaged. Because the memories in a single cluster are already semantically similar, averaging them reduces redundancy without causing destructive semantic conflict.
- Concatenation: The final, merged cluster tokens are concatenated together and appended to the user's prompt.
Datasets
The framework was evaluated using the LaMP (Language Model Personalization) benchmark, focusing on three distinct tasks:
- Personalized news headline generation
- Personalized tweet paraphrasing
- Personalized movie tagging
These tasks are ideal for testing personalization because success relies heavily on capturing the unique stylistic nuances and vocabulary choices of individual users.
Key Insights and Ideas
- Avoiding Semantic Dilution: The core "aha moment" is that averaging text embeddings only hurts performance when the underlying texts are heterogeneous. By segregating memories into homogeneous clusters first, averaging acts as a clean deduplication mechanism rather than a destructive blurring tool.
- A Tunable Efficiency Knob: The number of clusters ($K$) acts as a direct control knob for engineers. You can scale $K$ up or down to dynamically balance the device's available context budget against the desired personalization quality. As shown in the paper's analysis, increasing the number of clusters consistently yields better performance up to a saturation point.
Key Results
The method was validated across multiple small LLMs, including Qwen2.5 1.5B, Gemma3 1B, and StableLM2 1.6B, using the ROUGE-L metric to evaluate text generation quality.
- Token Savings: The clustering approach achieved its best results using only 512 tokens, representing a 50% reduction in context consumption compared to the direct concatenation baseline (1,024 tokens).
- Performance Boost: Despite using half the tokens, the clustering method consistently outperformed or matched direct concatenation across all models and tasks. For instance, on the movie tagging task, the clustering method achieved an average ROUGE-L score of 40.07%, compared to 36.42% for concatenation and 37.44% for naive averaging.
Limitations and Future Work
While the paper demonstrates clear efficiency gains, a few areas remain open for exploration:
- Hyperparameter Tuning: The choice of $K$ (number of clusters) is currently fixed globally per task. A more robust production system might benefit from dynamically adjusting $K$ based on the variance or volume of a specific user's history.
- Compute Overhead: Performing K-Means clustering on-device adds a small computational step during inference. Although K-Means is lightweight, the authors do not deeply quantify the exact latency or battery impact of running this clustering step on edge hardware.
Summary updated