User-LLM: Efficient LLM Contextualization with User Embeddings

Lin Ning, Luyang Liu, Jiaxing Wu, Neo Wu, Devora Berlowitz, Sushant Prakash, Bradley Green, Shawn O'Banion, Jun XieWWW 2024 · DOI

Abstract

Large language models (LLMs) have achieved remarkable success across various domains, but effectively incorporating complex and potentially noisy user timeline data into LLMs remains a challenge. Current approaches often involve translating user timelines into text descriptions before feeding them to LLMs, which can be inefficient and may not fully capture the nuances of user behavior. Inspired by how LLMs are effectively integrated with images through direct embeddings, we propose User-LLM, a novel framework that leverages user embeddings to directly contextualize LLMs with user history interactions. These embeddings, generated by a user encoder pretrained using self-supervised learning on diverse user interactions, capture latent user behaviors and interests as well as their evolution over time. We integrate these user embeddings with LLMs through cross-attention, enabling LLMs to dynamically adapt their responses based on the context of a user's past actions and preferences. Our approach achieves significant efficiency gains by representing user timelines directly as embeddings, leading to substantial inference speedups of up to 78.1X. Comprehensive experiments on MovieLens, Amazon Review, and Google Local Review datasets demonstrate that User-LLM outperforms text-prompt-based contextualization on tasks requiring deep user understanding, with improvements of up to 16.33%, particularly excelling on long sequences that capture subtle shifts in user behavior. Furthermore, the incorporation of Perceiver layers streamlines the integration between user encoders and LLMs, yielding additional computational savings.

Introduction

To make an AI truly "personal," it needs to know your history: what movies you’ve liked, where you’ve eaten, or what you’ve bought. Currently, the standard way to give an LLM this context is to "textualize" it—converting a long timeline of events into a massive paragraph of text and stuffing it into the prompt. This approach suffers from a "Context Tax," where long histories consume the LLM's context window, making inference slow and computationally expensive. Moreover, converting raw behavioral data into natural language can be noisy and fail to capture subtle patterns in user interest evolution.

Comparison between traditional text-prompting and the User-LLM framework.

Methodology

The User-LLM framework treats a user’s interaction history as a distinct modality, similar to how models process images. Instead of text, it uses a Transformer-based encoder (specifically an Autoregressive Transformer) pretrained on raw user interaction sequences to distill a timeline into dense "user embeddings."

Detailed architecture of User-LLM, showing the autoregressive user encoder and the LLM decoder integration via a Perceiver resampler.

The integration follows these key components:

  • User Encoder: Distills timelines into dense embeddings using self-supervised pretraining.
  • Cross-Attention Fusion: Inspired by models like Flamingo, this allows the LLM to dynamically "look at" user history embeddings while generating responses.
  • Perceiver Resampler: Compresses long sequences of user embeddings into a fixed, small number of tokens (e.g., 16 or 32), ensuring efficiency regardless of history length.

Training involves a two-stage process: self-supervised pretraining of the user encoder on interaction data, followed by fine-tuning the LLM and encoder together to align the user and text modalities.

Experimental Results

Evaluated on MovieLens20M, Amazon Review, and Google Local Review datasets, User-LLM demonstrates significant advantages over traditional text-prompting:

  • Massive Speedups: User-LLM achieved up to a 78.1x reduction in FLOPs compared to text-prompting when dealing with long user histories (200+ items).
  • Improved Accuracy: On tasks like "Favorite Category Prediction," User-LLM outperformed text-based prompts by 16.33% on the Google Review dataset.
  • Token Efficiency: While a text prompt might require 2,500 tokens to describe a long history, User-LLM achieved better results using only 32 embedding tokens.
  • Model Sensitivity: Analysis revealed that the upper layers of the LLM attend more strongly to user embeddings, suggesting that user history provides high-level semantic context rather than low-level linguistic features.

Conclusion

User-LLM provides a scalable and efficient path for personalizing LLMs by treating user history as a first-class modality. By bypassing the "context tax" of textualization, it enables deeper personalization with significantly lower computational overhead and improved performance on complex user understanding tasks.

Summary updated

BibTeX
@inproceedings{ning2024user,
  author = {Lin Ning and Luyang Liu and Jiaxing Wu and Neo Wu and Devora Berlowitz and Sushant Prakash and Bradley Green and Shawn O'Banion and Jun Xie},
  title = {{User-LLM: Efficient LLM Contextualization with User Embeddings}},
  booktitle = {The Web Conference},
  year = {2024},
  doi = {10.1145/3701716.3715463},
}
Figure