Share your thoughts, 1 month free Claude Pro on usSee more
WorkDL logo mark

Knowing When Not to Answer: Lightweight KB-Aligned OOD Detection for Safe RAG

About

Retrieval-Augmented Generation (RAG) systems are increasingly deployed in high-stakes domains, where safety depends not only on how a system answers, but also on whether a query should be answered given a knowledge base (KB). Out-of-domain (OOD) queries can cause dense retrieval to surface weakly related context and lead the generator to produce fluent but unjustified responses. We study lightweight, KB-aligned OOD detection as an always-on gate for RAG systems. Our approach applies PCA to KB embeddings and scores queries in a compact subspace selected either by explained-variance retention (EVR) or by a separability-driven t-test ranking. We evaluate geometric semantic-search rules and lightweight classifiers across 16 domains, including high-stakes COVID-19 and Substance Use KBs, and stress-test robustness using both LLM-generated attacks and an in-the-wild 4chan attack. We find that low-dimensional detectors achieve competitive OOD performance while being faster, cheaper, and more interpretable than prompted LLM-based judges. Finally, human and LLM-based evaluations show that OOD queries primarily degrade the relevance of RAG outputs, showing the need for efficient external OOD detection to maintain safe, in-scope behavior.

Ilias Triantafyllopoulos, Renyi Qu, Salvatore Giorgi, Brenda Curtis, Lyle H. Ungar, Jo\~ao Sedoc• 2025

Related benchmarks

TaskDatasetResultRank
Out-of-Distribution DetectionSubstance Use (clean)
Accuracy97.6
16
Out-of-Distribution DetectionStackEx (clean)
Accuracy96.3
16
Out-of-Distribution DetectionC19 4chan (attack)
Accuracy77.1
16
Out-of-Distribution DetectionSU LLM (attack)
Accuracy93.8
16
Out-of-Distribution DetectionCOVID-19 (clean)
Accuracy98.5
16
Out-of-Distribution DetectionMSMARCO (clean)
Accuracy93.5
16
Out-of-Distribution DetectionC19 LLM-Att (attack)
Accuracy94.2
16
OOD DetectionGeneral 300 samples (test)
Latency (µs)17.7
7
Response Quality EvaluationID in-domain (150 samples)
Count134
4
Response Quality EvaluationOOD out-of-domain (150 samples)
Count102
4
Showing 10 of 10 rows

Other info

Follow for update