From Searching for Users to LLMs: Optimizing RAG End-to-end via Online Contrastive Learning
Jiawei Zhou, Lei Chen
As retrieval-augmented generation (RAG) becomes widespread, the role of information retrieval shifts from retrieving information for user queries to retrieving contexts for LLMs, where relevance is difficult to define or annotate. In this paper, we empirically show that relevance learned in traditional IR settings often misaligns with the needs of RAG. To address this gap, we introduce OpenRAG, a RAG framework OPtimized ENd-to-end by tuning the retriever via online contrastive learning to capture complex relevance tailored for RAG. Extensive experiments across diverse tasks show that in RAG settings, OpenRAG improves performance by 5.2% over the original retriever and outperforms state-of-the-art retrievers by 4.9%. Our approach is both efficient and practical, requiring only 4 GPUs and completing training within a single day. Despite tuning only a 0.2B retriever, our approach consistently outperforms LLM-augmented retrieval on most tasks and even rivals the performance of fine-tuning an 8B LLM, making it a cost-effective alternative for improving RAG.