Legommenders: A Comprehensive Content-Based Recommendation Library with LLM Support

Qijiong Liu, Lu Fan, Xiao-Ming Wu 0003

Introduction

Legommenders is an open-source library designed to bridge the gap between Large Language Models (LLMs) and content-based recommendation systems. By adopting a modular "snap-together" approach, it allows researchers to combine content encoders with recommendation logic seamlessly. Unlike previous frameworks, Legommenders supports end-to-end training and provides a vast library of over 1,000 model combinations.

Extracted table from page 2 of Legommenders: A Comprehensive Content-Based Recommendation Library with LLM Support

Addressing the Cold-Start Problem

Traditional recommendation systems often rely on "transductive learning," using static IDs for users and items. This approach fails in "cold start" scenarios where new users or items lack historical data. Content-based (inductive) models address this by analyzing item descriptions or user bios.

However, most existing libraries use a decoupled design, where pre-trained models generate embeddings that are subsequently frozen. These embeddings are often not aligned with the specific nuances of recommendation tasks. Legommenders tackles this by enabling end-to-end training, where content understanding and recommendation prediction are optimized jointly.

Modular Architecture

The library's core strength lies in its modularity, consisting of four primary components that can be interchanged like Lego bricks:

Extracted figure from page 1 of Legommenders: A Comprehensive Content-Based Recommendation Library with LLM Support
  1. Dataset Processor: Standardizes diverse raw data into a unified format using the UniTok library.
  2. Content Operator: Generates item embeddings using various architectures, ranging from CNNs and Attention mechanisms to LLMs like BERT and LLaMA.
  3. Behavior Operator: Fuses a user’s interaction history into a single representative embedding.
  4. Click Predictor: Computes the final probability of a user clicking an item using modules like Dot Product or DeepCTR.

Key Innovations

Joint Training with LoRA

To handle the computational demands of fine-tuning massive LLMs, Legommenders supports Low-Rank Adaptation (LoRA). This technique allows for efficient end-to-end training by updating only a small fraction of the LLM's parameters. This makes the process significantly faster than full fine-tuning while still leveraging the LLM's deep semantic knowledge.

Inference Caching

LLMs are computationally expensive during inference. To speed up evaluation, Legommenders implements a clever caching pipeline that pre-computes and stores item and user embeddings. This avoids redundant calculations for repeated entities, resulting in a massive speed boost—up to 50x faster than standard evaluation pipelines.

Datasets and Benchmarking

The library supports 15 diverse datasets across multiple domains, including news (MIND, Eb-NerD), books (Goodreads), movies (MovieLens), and music (Amazon CDs). Additionally, the authors highlight the benefits of GPT-augmented datasets, where LLMs are used to generate enhanced features like summaries or category tags to improve recommendation quality.

Key Results and Insights

  • Alignment is Crucial: Jointly training a content encoder specifically for the recommendation task consistently outperforms using "frozen" embeddings from general-purpose models.
  • LLM Performance: On the MIND news dataset, models using LLM-based content operators (such as the "DIRE" model using Llama1) significantly outperformed traditional CNN or Attention-based models, achieving an AUC of 68.50 compared to ~61-62 for standard baselines.
  • Scalability: By treating components as interchangeable operators, the library allows for the creation of over 1,000 distinct models, 95% of which have never been formally tested before.

Conclusion

Legommenders lowers the barrier for integrating LLMs into recommendation pipelines. By providing a flexible, efficient, and end-to-end trainable framework, it paves the way for more sophisticated and context-aware recommendation systems. Future work will likely expand support for multi-modal models and further optimize the training pipeline for researchers with limited GPU resources.