OSCAR: Online Soft Compression And Reranking

Maxime Louis, Thibault Formal, Hervé Déjean, Stéphane ClinchantarXiv 2025 · DOI

Abstract

Retrieval-Augmented Generation (RAG) is essential for grounding Large Language Models (LLMs) in factual data, yet it introduces significant computational overhead as retrieved context grows. We present OSCAR (Online Soft Compression And Reranking), a framework that reduces RAG inference costs by 2–5× while maintaining high accuracy. OSCAR utilizes a lightweight, query-aware compressor to map long documents into a small set of dense "memory tokens" during inference. This approach bridges the gap between inefficient hard compression and query-agnostic offline soft compression. Our evaluations across multiple benchmarks demonstrate that OSCAR achieves substantial speedups and competitive accuracy, often outperforming traditional RAG baselines.

Introduction

The effectiveness of RAG is often limited by the "long context" problem: as more documents are retrieved to ensure factual coverage, the input prompt length increases, leading to quadratic growth in self-attention computation. Current mitigation strategies typically involve "hard compression" (text summarization or pruning) or "offline soft compression" (pre-computing embeddings). Hard compression often yields modest gains and can be slow, while offline soft compression fails to capture query-specific nuances, often missing critical "needles in the haystack."

OSCAR addresses these challenges through Online Soft Compression. By running a lightweight compressor model during the inference pass, OSCAR generates query-specific document representations that are both highly compressed and contextually relevant.

Methodology

The core of OSCAR is a dual-purpose compressor that performs both document compression and reranking in a single forward pass.

Online Soft Compression

Unlike previous methods that pre-calculate document embeddings, OSCAR's compressor takes both the user query and the retrieved document as input. It produces a fixed number of "memory tokens" (e.g., 8 tokens for a 128-token document, a 16× compression ratio). These tokens represent the document's information relative to the specific query, ensuring that the most relevant details are preserved for the generator LLM.

The OSCAR framework architecture illustrating the training (via distillation) and inference pipelines.

Architecture and Training

The authors explore two compressor variants:

  1. OSCAR-N-Layers: Uses the initial layers of the generator LLM itself.
  2. OSCAR-llama: Employs a smaller standalone model (e.g., Llama-3.2-1B).

Training is conducted via sequence-level distillation. A large "Teacher" model (e.g., Mistral-7B) generates answers using full-text contexts, and the OSCAR "Student" learns to replicate these outputs using only the compressed memory tokens.

Simultaneous Reranking

OSCAR integrates a reranking head into the compressor. By adding a special [RR] token, the model predicts a relevance score during the compression pass. This allows the system to rerank documents "for free," optimizing the context quality without additional computational stages.

Experimental Results

OSCAR was evaluated on a wide range of benchmarks, including Natural Questions (NQ), TriviaQA, ASQA, and HotpotQA, using backbones ranging from 1B to 24B parameters.

Efficiency and Accuracy

OSCAR consistently achieved inference speedups between 2.2× and 4.8×. Notably, efficiency gains scaled with the size of the generator model; for a Mistral-24B backbone, OSCAR reduced computational complexity by 5×. Despite the high compression rates (up to 128×), accuracy remained stable, and in some instances, OSCAR-llama exceeded the "no compression" baseline by filtering out irrelevant noise.

Performance vs. efficiency (T-FLOPs) trade-offs for OSCAR variants across various QA benchmarks.

Reranking Performance

The "free" reranker within OSCAR performed competitively with dedicated cross-encoders like DeBERTa-v3, significantly improving the quality of the top-k documents fed to the generator.

Conclusion

OSCAR represents a significant step forward in making RAG systems more efficient and scalable. By moving compression "online" and making it query-aware, it overcomes the primary limitations of existing context reduction techniques. Future work will focus on making the compressor backbone-agnostic and exploring dynamic token allocation to further optimize the balance between relevance and compute.

Summary updated

Abstract

Retrieval-Augmented Generation (RAG) enhances Large Language Models (LLMs) by integrating external knowledge, leading to improved accuracy and relevance. However, scaling RAG pipelines remains computationally expensive as retrieval sizes grow. To address this, we introduce OSCAR, a novel query-dependent online soft compression method that reduces computational overhead while preserving performance. Unlike traditional hard compression methods, which shorten retrieved texts, or soft compression approaches, which map documents to continuous embeddings offline, OSCAR dynamically compresses retrieved information at inference time, eliminating storage overhead and enabling higher compression rates. Additionally, we extend OSCAR to simultaneously perform reranking, further optimizing the efficiency of the RAG pipeline. Our experiments demonstrate state-of-the-art performance with a 2-5x speed-up in inference and minimal to no loss in accuracy for LLMs ranging from 1B to 24B parameters. The models are available at: https://huggingface.co/collections/naver/oscar-67d446a8e3a2551f57464295.
BibTeX
@misc{louis2025oscar,
  author = {Maxime Louis and Thibault Formal and Hervé Déjean and Stéphane Clinchant},
  title = {{OSCAR: Online Soft Compression And Reranking}},
  year = {2025},
  eprint = {2504.07109},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2504.07109},
}
Figure