Lune

ACL2023Top-tier venue

Is Fine-tuning Needed? Pre-trained Language Models Are Near Perfect for Out-of-Domain Detection

Rheeya Uppaal, Junjie Hu, Yixuan Li

Abstract

Out-of-distribution (OOD) detection is a critical task for reliable predictions over text. Finetuning with pre-trained language models has been a de facto procedure to derive OOD detectors with respect to in-distribution (ID) data. Despite its common use, the understanding of the role of fine-tuning and its necessity for OOD detection is largely unexplored. In this paper, we raise the question: is fine-tuning necessary for OOD detection? We present a study investigating the efficacy of directly leveraging pre-trained language models for OOD detection, without any model fine-tuning on the ID data. We compare the approach with several competitive fine-tuning objectives, and offer new insights under various types of distributional shifts. Extensive evaluations on 8 diverse ID-OOD dataset pairs demonstrate nearperfect OOD detection performance (with 0% FPR95 in many cases), strongly outperforming its fine-tuned counterparts. We show that using distance-based detection methods, pretrained language models are near-perfect OOD detectors when the distribution shift involves a domain change. Furthermore, we study the effect of fine-tuning on OOD detection and identify how to balance ID accuracy with OOD detection performance. Our code is publically available 1 .

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

8 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • How Does Unlabeled Data Provably Help Out-of-Distribution Detection? cites Energy-based Out-of-distribution Detection
  • How Does Unlabeled Data Provably Help Out-of-Distribution Detection? cites Out-of-Distribution Detection with Deep Nearest Neighbors
  • Out-of-Distribution Detection with Deep Nearest Neighbors cites Energy-based Out-of-distribution Detection
  • Out-of-Distribution Detection with Deep Nearest Neighbors cites Supervised Contrastive Learning
  • On Large Language Model Continual Unlearning cites SimCSE: Simple Contrastive Learning of Sentence Embeddings
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers8

  1. How Does Unlabeled Data Provably Help Out-of-Distribution Detection?Xuefeng Du, Zhen Fang, Ilias Diakonikolas, Yixuan LiICLR 2024 · 39 citations
  2. DoRA: Enhancing Parameter-Efficient Fine-Tuning with Dynamic Rank DistributionYulong Mao, Kaiyu Huang, Changhao Guan, Ganglin Bao et al.ACL 2024 · 15 citations
  3. MoE-RBench: Towards Building Reliable Language Models with Sparse Mixture-of-ExpertsGuanjie Chen, Xinyu Zhao, Tianlong Chen, Yu ChengICML 2024 · 8 citations
  4. Trust The TypicalDebargha Ganguly, Sreehari Sankar, Biyao Zhang, Vikash Singh et al.ICLR 2026 · 3 citations
  5. On Large Language Model Continual UnlearningChongyang Gao, Lixu Wang, Kaize Ding, Chenkai Weng et al.ICLR 2025 · 1 citation

Builds on22

  1. Supervised Contrastive LearningPrannay Khosla, Piotr Teterwak, Chen Wang, Aaron Sarna et al.NeurIPS 2020 · 7,049 citations
  2. SimCSE: Simple Contrastive Learning of Sentence EmbeddingsTianyu Gao, Xingcheng Yao, Danqi ChenEMNLP 2021 · 2,496 citations
  3. Energy-based Out-of-distribution DetectionWeitang Liu, Xiaoyun Wang, John D. Owens, Yixuan LiNeurIPS 2020 · 2,213 citations
  4. Fine-Tuning can Distort Pretrained Features and Underperform Out-of-DistributionAnanya Kumar, Aditi Raghunathan, Robbie Matthew Jones, Tengyu Ma et al.ICLR 2022 · 911 citations
  5. Out-of-Distribution Detection with Deep Nearest NeighborsYiyou Sun, Yifei Ming, Xiaojin Zhu, Yixuan LiICML 2022 · 789 citations

Related papers

  1. Contrastive Out-of-Distribution Detection for Pretrained TransformersWenxuan Zhou, Fangyu Liu, Muhao ChenEMNLP 2021 · 63 citations
  2. Holistic Sentence Embeddings for Better Out-of-Distribution DetectionSishuo Chen, Xiaohan Bi, Rundong Gao, Xu SunEMNLP Findings 2022 · 9 citations
  3. BARLE: Background-Aware Representation Learning for Background Shift Out-of-Distribution DetectionHanyu Duan, Yi Yang, Ahmed Abbasi, Kar Yan TamEMNLP Findings 2022 · 2 citations
  4. CED: Comparing Embedding Differences for Detecting Out-of-Distribution and Hallucinated TextHakyung Lee, Keon-Hee Park, Hoyoon Byun, Jeyoon Yeom et al.EMNLP Findings 2024 · 1 citation
  5. On Prefix-tuning for Lightweight Out-of-distribution DetectionYawen Ouyang, Yongchang Cao, Yuan Gao, Zhen Wu et al.ACL 2023 · 1 citation
Dusk over the sea between two cliffs drawn in fine vertical lines