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

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

22 May 2023arXiv:2305.13282archive 2025-07-28

Rheeya Uppaal, Junjie Hu, Yixuan Li

Out-of-distribution (OOD) detection is a critical task for reliable predictions over text. Fine-tuning 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 near-perfect OOD detection performance (with 0% FPR95 in many cases), strongly outperforming its fine-tuned counterparts. We show that using distance-based detection methods, pre-trained 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 at https://github.com/Uppaal/lm-ood.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2305.13282")

Code

Syntology Ran 1 of 10 code samples harvested from 1 repository linked to this paper; 9 have no recorded run. Of those that ran: 1 ran · fixture could not drive it.

By repository: official repository: 10 samples from 1 repository, 1 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

uppaal/lm-ood officialmentioned in paperpytorchMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

10 samples harvested; 1 ran; 0 honoured the contract we drafted; 9 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

1ran · fixture could not drive it
9unverified

Licence: 0 of the 10 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from Uppaal/lm-ood. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

get_auroc Uppaal/lm-ood/evaluation.py official repository ran · fixture could not drive it fingerprinted MIT (permissive) · ace38fb975eb5cfa · report
collate_fn Uppaal/lm-ood/utils/startup.py official repository unverified MIT (permissive) · e27e3e8767d93f9e · report
compute_loss Uppaal/lm-ood/model.py official repository unverified MIT (permissive) · d4befec42a19db00 · report
compute_metrics Uppaal/lm-ood/utils/trainer_utils.py official repository unverified MIT (permissive) · b43faec17e425ded · report
describe_training_method Uppaal/lm-ood/run_ood_detection.py official repository unverified MIT (permissive) · 92188b9962a95088 · report
get_sent_embeddings Uppaal/lm-ood/model.py official repository unverified MIT (permissive) · 08fed2404d724a96 · report
load_model Uppaal/lm-ood/utils/model_utils.py official repository unverified MIT (permissive) · 48775127b9ab8dbe · report
load_tokenizer Uppaal/lm-ood/utils/model_utils.py official repository unverified MIT (permissive) · bb9cc88f0bea27c4 · report
merge_keys Uppaal/lm-ood/evaluation.py official repository unverified MIT (permissive) · 0ae01890dc1a0be1 · report
resolve_path Uppaal/lm-ood/download_models.py official repository unverified MIT (permissive) · 5aa8c0ddf6cf12c2 · report

Tasks

Out of Distribution (OOD) Detection

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections