RETRO-LI: Small-Scale Retrieval Augmented Generation Supporting Noisy Similarity Searches and Domain Shift Generalization

Gentiana Rashiti, Geethan Karunaratne, Mrinmaya Sachan, Abu Sebastian, Abbas Rahimi

Introduction

Retrieval Augmented Generation (RAG) has revolutionized the way Large Language Models (LLMs) interact with external knowledge, significantly reducing the frequency of "hallucinations" by providing models with a mechanism to look up facts in external databases. However, most state-of-the-art RAG implementations, such as DeepMind’s original RETRO, are designed for trillion-token datasets. This reliance on massive scale presents significant hurdles for specialized applications and high-speed hardware integration.

This paper introduces RETRO-LI (Retrieval-Enhanced Transformer-Little), a model designed to prove that RAG is not only viable but highly effective at a smaller scale. By utilizing superior semantic search and innovative noise-based regularization, RETRO-LI addresses the challenges of data sparsity and hardware latency, enabling robust performance even in the presence of physical noise from next-generation Analog In-Memory Computing (IMC).

The Challenges of Small-Scale RAG

Transitioning RAG from massive, general-purpose databases to small, niche ones introduces two primary problems:

  1. The Sparsity Problem: In a trillion-token database, finding a near-exact match for a query is statistically likely. In a small, specialized database, relevant context is harder to find. Standard keyword-based searches or simple BERT embeddings often fail to bridge the semantic gap when data is sparse.
  2. The Bottleneck Problem: Searching through billions of vectors creates a latency bottleneck. While libraries like FAISS optimize this process, emerging hardware like Analog In-Memory Computing (IMC) offers the potential for $O(1)$ constant-time searches. However, these physical systems introduce inherent noise into the retrieved results, which can degrade model performance.

Methodology: RETRO-LI Architecture

RETRO-LI is built upon a "RETRO-fitted" GPT-2 architecture, incorporating several key technical innovations to overcome the limitations of small-scale retrieval.

Semantic Search with SBERT

To solve the sparsity problem, the authors replaced standard BERT embeddings with Sentence-BERT (SBERT). Unlike standard BERT, SBERT is specifically fine-tuned for semantic similarity. This allows the model to find conceptually related neighbors even when exact textual matches are absent in the database.

Gaussian Noise Regularization

The paper’s most significant contribution is the use of Gaussian Noise Regularization during training. By injecting noise into the embeddings of retrieved neighbors, the model is forced to learn how to extract salient information from imperfect or "noisy" context. This serves a dual purpose: it prepares the model for the physical noise of IMC hardware and acts as a powerful regularizer for domain generalization.

Chunked Cross-Attention (CCA)

Following the core RETRO architecture, RETRO-LI processes input in 64-token chunks. It uses cross-attention mechanisms to integrate information from the retrieved neighbors, ensuring that the external context is effectively fused with the model's internal representations.

Experimental Results

SBERT vs. BERT

The shift to SBERT proved critical. On the WikiText-103 validation set, using SBERT embeddings reduced perplexity from 44.93 (using standard BERT) to 22.61 when retrieving three neighbors. This confirms that high-quality semantic retrieval is non-negotiable for small-scale RAG systems.

Robustness to Hardware Noise

To test the model's readiness for next-generation hardware, the authors simulated Analog IMC noise during inference. The regularized RETRO-LI model demonstrated remarkable resilience; even at extreme noise levels (relative standard deviation $\lambda_i = 1.0$), the model experienced less than 1% performance loss. This suggests that retrieval can be offloaded to high-speed, low-power analog hardware without sacrificing accuracy.

"Plug-and-Play" Domain Generalization

The authors evaluated RETRO-LI’s ability to handle domain shifts by swapping the retrieval database without retraining the model. Testing across diverse datasets—including BBC News, Reuters, legal contracts (Atticus), and historical documents (Founding Docs)—the regularized model consistently outperformed both non-retrieval baselines and RAG models trained without noise. This "plug-and-play" capability allows a model trained on Wikipedia to be immediately deployed in a legal or news environment with a simple database swap.

Conclusion and Future Work

RETRO-LI demonstrates that RAG is a viable strategy for small-scale, proprietary datasets. By treating retrieval noise as a feature rather than a bug, the authors have created a model that is both hardware-resilient and highly adaptable to new domains.

Future research directions include the implementation of "reflection tokens" to allow the model to decide dynamically when retrieval is necessary, thereby saving computation. Additionally, while the current results rely on IMC simulations, the authors aim to deploy RETRO-LI on physical analog AI hardware to further validate its efficiency. This work paves the way for "Private RAG," enabling organizations to leverage the power of retrieval-augmented models on sensitive, small-scale data using efficient, low-power hardware.

Summary updated

BibTeX
@inproceedings{rashiti2024retro,
  author = {Gentiana Rashiti and Geethan Karunaratne and Mrinmaya Sachan and Abu Sebastian and Abbas Rahimi},
  title = {{RETRO-LI: Small-Scale Retrieval Augmented Generation Supporting Noisy Similarity Searches and Domain Shift Generalization}},
  booktitle = {ECAI},
  year = {2024},
  doi = {10.3233/faia240837},
}
Figure