Retrieval Augmented Generation with Collaborative Filtering for Personalized Text Generation

Teng Shi, Jun Xu, Xiao Zhang, Xiaoxue Zang, Kai Zheng, Yang Song, Han Li

Abstract

Standard personalized Retrieval-Augmented Generation (RAG) typically relies on a single user's historical data to guide Large Language Models (LLMs). This "ego-history" approach often lacks sufficient context for high-quality personalization. We introduce CFRAG (Collaborative Filtering RAG), a framework that breaks these silos by retrieving relevant documents from the histories of similar users. By integrating contrastive learning to identify user neighbors and fine-tuning retrievers based on direct LLM feedback, CFRAG aligns retrieval utility with generation quality. Our evaluations on the Language Model Personalization (LaMP) benchmark demonstrate that CFRAG significantly outperforms existing RAG baselines across multiple text generation tasks.

Introduction: The Limitations of Ego-History

While LLMs have revolutionized natural language processing, they often struggle with personalization, providing "one-size-fits-all" responses. Current personalized RAG methods attempt to solve this by injecting a user's past behaviors—such as previous tweets, reviews, or academic titles—into the model's prompt. However, these methods face two critical challenges:

  1. The "Ego-History" Limitation: Relying solely on one user's history is restrictive. In traditional recommendation systems, collaborative filtering ("users who liked X also liked Y") provides powerful predictive signals. CFRAG applies this logic to text generation: "users who write like X might also mention Y." Collaborative information provides a richer context that a single user's history might lack.
  2. The Relevance-Utility Gap: Most retrievers prioritize semantic similarity—how much a document "looks like" a query. However, semantic similarity does not always equate to utility for the LLM. A document might be similar but fail to provide the specific information needed for a high-quality, personalized response.
Comparison of standard RAG vs. CFRAG. Standard RAG (top) fails to identify specific entities like "Donald Trump" due to sparse user history, while CFRAG (bottom) leverages similar users to provide the necessary context.

The CFRAG Framework

To address these gaps, we propose a three-stage framework designed to harness collaborative wisdom for personalized generation.

The three-stage CFRAG framework: (1) User Retrieval via contrastive learning, (2) Personalized Document Retrieval, and (3) Document Reranking with LLM feedback.

1. User Retrieval via Contrastive Learning

Since explicit labels for "similar users" are rarely available in text datasets, we employ self-supervised contrastive learning. We generate multiple "views" of a user's history through data augmentation techniques like masking, cropping, or reordering. An encoder is trained to ensure that different views of the same user are close in the embedding space, while views of different users are distant. This allows the system to efficiently identify the top-$m$ "neighbors" for any target user.

2. Personalized Retriever with LLM Feedback

Once similar users are identified, the system retrieves the top-$k$ documents from their collective histories. The retrieval process uses a hybrid score combining traditional semantic relevance with a "preference score" that reflects the user's general profile. Crucially, the retriever is fine-tuned using LLM feedback. By calculating the KL divergence between the retriever's scores and the actual quality of the LLM's output (measured by metrics like ROUGE), the system learns to prioritize documents that are most useful for generation.

3. Personalized Reranker

The final stage involves a cross-encoder reranker that evaluates the pool of documents gathered from all similar users. Like the retriever, the reranker is also fine-tuned using LLM feedback to ensure the final prompt contains the most "generative-friendly" context.

Experimental Results

We evaluated CFRAG on the Language Model Personalization (LaMP) benchmark, covering tasks such as scholarly title generation (LaMP-1 & 5), movie tagging (LaMP-2), and news headline generation (LaMP-4). Using Llama3-8B-Instruct and Qwen2-7B-Instruct as backbone models, CFRAG achieved state-of-the-art performance across all datasets.

Key findings include:

  • The Neighbor Boost: Ablation studies confirmed that removing the "User Retrieval" module—effectively reverting to standard RAG—leads to a significant performance drop.
  • Optimal Crowd Size: The most effective results were achieved by retrieving information from 4-6 similar users. Too few users limited the collaborative benefit, while too many introduced noise.
  • Utility over Similarity: Training retrievers on downstream task performance (LLM feedback) proved superior to training on simple vector similarity.

Conclusion and Future Directions

CFRAG demonstrates that "collaborative wisdom" is a powerful tool for personalizing LLMs. By looking beyond a single user's history and aligning retrieval with generation utility, we can produce text that is significantly more accurate and personalized.

Future work will focus on reducing the computational overhead associated with generating LLM feedback and addressing privacy concerns. Using other users' historical data requires robust anonymization to ensure that private information is not inadvertently leaked during the generation process. Additionally, exploring the joint fine-tuning of both the collaborative retriever and the LLM itself remains a promising avenue for further research.

Summary updated

BibTeX
@inproceedings{shi2025retrieval,
  author = {Teng Shi and Jun Xu and Xiao Zhang and Xiaoxue Zang and Kai Zheng and Yang Song and Han Li},
  title = {{Retrieval Augmented Generation with Collaborative Filtering for Personalized Text Generation}},
  booktitle = {International ACM SIGIR Conference on Research and Development in Information Retrieval},
  year = {2025},
}
Figure