RAG system safety improvements impact performance under load
An experiment to improve the safety of a Retrieval Augmented Generation (RAG) system by verifying every sentence led to decreased throughput under heavy load.
A developer implemented a safety feature in a Retrieval Augmented Generation (RAG) system, ensuring every generated sentence is verified against its source before being presented to the user. While this improved safety, it resulted in a performance decrease under heavy load. The system's request delivery rate dropped from 67.4% to 62.8%.
The RAG system, named The Relay, sources answers exclusively from three research papers: "Attention Is All You Need," "Moshi," and "H-Net." It mandates citations for all claims and refuses to answer questions not covered by the papers. The system's workflow includes queuing, caching, retrieval, evidence checking, model calls, and per-sentence verification. To manage concurrent requests, a "SingleFlight" mechanism was introduced. This allows multiple identical requests to share a single model call, significantly reducing the number of model calls during bursts. The system can also identify and refuse irrelevant questions before engaging the language model, conserving resources.