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

Your Finetuned Large Language Model is Already a Powerful Out-of-distribution Detector

About

We revisit the likelihood ratio between a pretrained large language model (LLM) and its finetuned variant as a criterion for out-of-distribution (OOD) detection. The intuition behind such a criterion is that, the pretrained LLM has the prior knowledge about OOD data due to its large amount of training data, and once finetuned with the in-distribution data, the LLM has sufficient knowledge to distinguish their difference. Leveraging the power of LLMs, we show that, the likelihood ratio can serve as an effective OOD detection criterion. Moreover, we apply the proposed LLM-based likelihood ratio to detect OOD questions in question-answering (QA) systems, which can be used to improve the performance of specialized LLMs for general questions. Given that likelihood can be easily obtained by the loss functions within contemporary neural network frameworks, it is straightforward to implement this approach in practice. Since both the pretrained LLMs and its various finetuned models are widely available from online platforms such as Hugging Face, our proposed criterion can be effortlessly incorporated for OOD detection without the need for further training. We conduct comprehensive evaluation across on multiple settings, including far OOD, near OOD, spam detection, and QA scenarios, to demonstrate the effectiveness of the method. Code can be found at https://github.com/andiac/LLMOODratio

Andi Zhang, Tim Z. Xiao, Weiyang Liu, Robert Bamler, Damon Wischik• 2024

Related benchmarks

TaskDatasetResultRank
Near-OOD DetectionROSTD
AUROC97.26
4
Near-OOD DetectionSNIPS
AUROC97.98
4
Near-OOD DetectionCLINC150
AUROC86.61
4
Out-of-Distribution Detection20NG (ID) vs SST-2 (OOD)
AUROC0.9988
4
Out-of-Distribution Detection20NG (ID) vs MNLI (OOD)
AUROC0.9989
4
Out-of-Distribution Detection20NG (ID) vs RTE (OOD)
AUROC0.9991
4
Out-of-Distribution Detection20NG (ID) vs IMDB (OOD)
AUROC99.78
4
Near-OOD DetectionAGNews one-vs-all runs
AUROC (c3)0.75
4
Showing 8 of 8 rows

Other info

Follow for update