Papers › Out-of-Distribution Detection with Deep Nearest Neighbors

Out-of-Distribution Detection with Deep Nearest Neighbors

13 Apr 2022arXiv:2204.06507archive 2025-07-28

Yiyou Sun, Yifei Ming, Xiaojin Zhu, Yixuan Li

Out-of-distribution (OOD) detection is a critical task for deploying machine learning models in the open world. Distance-based methods have demonstrated promise, where testing samples are detected as OOD if they are relatively far away from in-distribution (ID) data. However, prior methods impose a strong distributional assumption of the underlying feature space, which may not always hold. In this paper, we explore the efficacy of non-parametric nearest-neighbor distance for OOD detection, which has been largely overlooked in the literature. Unlike prior works, our method does not impose any distributional assumption, hence providing stronger flexibility and generality. We demonstrate the effectiveness of nearest-neighbor-based OOD detection on several benchmarks and establish superior performance. Under the same model trained on ImageNet-1k, our method substantially reduces the false positive rate (FPR@TPR95) by 24.77% compared to a strong baseline SSD+, which uses a parametric approach Mahalanobis distance in detection. Code is available: https://github.com/deeplearning-wisc/knn-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="2204.06507")

Code

Syntology Ran 30 of 38 code samples harvested from 2 repositories linked to this paper; 8 have no recorded run. Of those that ran: 4 ran · honoured contract; 5 ran · violated contract; 6 ran · our draft was wrong; 15 ran · fixture could not drive it.

By repository: official repository: 19 samples from 1 repository, 16 ran; community (archive-listed): 19 samples from 1 repository, 14 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

deeplearning-wisc/knn-ood officialmentioned in papermentioned on GitHubpytorch report
ArthurHoa/deep-eknn mentioned on GitHubpytorch 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

38 samples harvested; 30 ran; 4 honoured the contract we drafted; 8 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.

4ran · honoured contract
5ran · violated contract
6ran · our draft was wrong
15ran · fixture could not drive it
8unverified

Licence: 38 of the 38 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 2 repositories linked to this paper, official or community; each sample names its own and says which. “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.

G_p deeplearning-wisc/knn-ood/util/score.py official repository ran · honoured contract fingerprinted no licence file found · pointer only · aafda009101cbfd4 · report
calc_loss deeplearning-wisc/knn-ood/util/score.py official repository ran · fixture could not drive it no licence file found · pointer only · 7d9344ac520f8918 · report
forward_fun deeplearning-wisc/knn-ood/util/score.py official repository ran · our draft was wrong no licence file found · pointer only · 9b68216c4f2d895c · report
get_Mahalanobis_score deeplearning-wisc/knn-ood/util/score.py official repository ran · our draft was wrong no licence file found · pointer only · 32ed88f27881480a · report
get_ModedMaha_score deeplearning-wisc/knn-ood/util/score.py official repository ran · fixture could not drive it no licence file found · pointer only · e3080865e3e46e82 · report
get_cos_score deeplearning-wisc/knn-ood/util/score.py official repository ran · our draft was wrong no licence file found · pointer only · 6c3b1825ad096dce · report
get_energy_score deeplearning-wisc/knn-ood/util/score.py official repository ran · our draft was wrong no licence file found · pointer only · 209469a90d2f8a72 · report
get_exlgst_score deeplearning-wisc/knn-ood/util/score.py official repository ran · our draft was wrong no licence file found · pointer only · 5560caaae9a95e1e · report
get_godin_score deeplearning-wisc/knn-ood/util/score.py official repository ran · fixture could not drive it no licence file found · pointer only · bc501b91abbe50d1 · report
get_gradient_score deeplearning-wisc/knn-ood/util/score.py official repository ran · fixture could not drive it no licence file found · pointer only · 3d782851b3c7d7e7 · report
get_infl_score deeplearning-wisc/knn-ood/util/score.py official repository ran · fixture could not drive it no licence file found · pointer only · 861d7015808075fb · report
get_lgst_score deeplearning-wisc/knn-ood/util/score.py official repository ran · our draft was wrong no licence file found · pointer only · 683101b9e3719e85 · report
get_mahalanobis_score deeplearning-wisc/knn-ood/util/score.py official repository ran · fixture could not drive it no licence file found · pointer only · 0d63630115fb978b · report
get_modedmaha_score deeplearning-wisc/knn-ood/util/score.py official repository ran · fixture could not drive it no licence file found · pointer only · 0b59395cfb5cb50d · report
get_msp_score deeplearning-wisc/knn-ood/util/score.py official repository ran · honoured contract no licence file found · pointer only · 6126345504c875f7 · report
get_odin_score deeplearning-wisc/knn-ood/util/score.py official repository ran · fixture could not drive it no licence file found · pointer only · 4f51a10a1b49685f · report
compute_deviations deeplearning-wisc/knn-ood/util/score.py official repository unverified no licence file found · pointer only · ba2203eb42a97fcf · report
get_gram_score deeplearning-wisc/knn-ood/util/score.py official repository unverified no licence file found · pointer only · 4c3cef6f0f0e686b · report
get_score deeplearning-wisc/knn-ood/util/score.py official repository unverified no licence file found · pointer only · b874b3a0ce06fd5f · report
btom ArthurHoa/deep-eknn/deep_eknn.py community (archive-listed) ran · honoured contract fingerprinted no licence file found · pointer only · d19bd686618a876f · report
btopl ArthurHoa/deep-eknn/deep_eknn.py community (archive-listed) ran · violated contract fingerprinted no licence file found · pointer only · 44a0bd7d7960c422 · report
decisionDST ArthurHoa/deep-eknn/deep_eknn.py community (archive-listed) ran · fixture could not drive it fingerprinted no licence file found · pointer only · 0b036e2cb2801ede · report
mtob ArthurHoa/deep-eknn/deep_eknn.py community (archive-listed) ran · violated contract fingerprinted no licence file found · pointer only · 0dee8a92419cff7b · report
mtobel ArthurHoa/deep-eknn/deep_eknn.py community (archive-listed) ran · fixture could not drive it fingerprinted no licence file found · pointer only · bc8c3813716a0475 · report
mtobetp ArthurHoa/deep-eknn/deep_eknn.py community (archive-listed) ran · fixture could not drive it fingerprinted no licence file found · pointer only · d666af0191f0d996 · report
mtonm ArthurHoa/deep-eknn/deep_eknn.py community (archive-listed) ran · fixture could not drive it fingerprinted no licence file found · pointer only · c8f5824b7a3abec9 · report
mtopl ArthurHoa/deep-eknn/deep_eknn.py community (archive-listed) ran · violated contract fingerprinted no licence file found · pointer only · b502b7ebecfb473e · report
mtoq ArthurHoa/deep-eknn/deep_eknn.py community (archive-listed) ran · violated contract fingerprinted no licence file found · pointer only · bbbc398d91edfdea · report
mtow ArthurHoa/deep-eknn/deep_eknn.py community (archive-listed) ran · honoured contract fingerprinted no licence file found · pointer only · e3776c1edecaa404 · report
qtom ArthurHoa/deep-eknn/deep_eknn.py community (archive-listed) ran · violated contract fingerprinted no licence file found · pointer only · d9c1685e770cd6de · report
qtow ArthurHoa/deep-eknn/deep_eknn.py community (archive-listed) ran · fixture could not drive it fingerprinted no licence file found · pointer only · de4f0891f2a2ecb3 · report
wtom ArthurHoa/deep-eknn/deep_eknn.py community (archive-listed) ran · fixture could not drive it fingerprinted no licence file found · pointer only · 9970a3a581cf0c70 · report
wtoq ArthurHoa/deep-eknn/deep_eknn.py community (archive-listed) ran · fixture could not drive it fingerprinted no licence file found · pointer only · 5ac9567da183a7fb · report
DST ArthurHoa/deep-eknn/deep_eknn.py community (archive-listed) unverified no licence file found · pointer only · 86c6428acf21785c · report
EKNN ArthurHoa/deep-eknn/deep_eknn.py community (archive-listed) unverified no licence file found · pointer only · c615b69c364d7bbd · report
LNS ArthurHoa/deep-eknn/deep_eknn.py community (archive-listed) unverified no licence file found · pointer only · df7da02ff75b6fbd · report
LNS_SSF ArthurHoa/deep-eknn/deep_eknn.py community (archive-listed) unverified no licence file found · pointer only · ed7b5ddceab83aeb · report
noise_imprecision ArthurHoa/deep-eknn/deep_eknn.py community (archive-listed) unverified no licence file found · pointer only · 422865e3a9dbb328 · report

Tasks

Out-of-Distribution Detection

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Out-of-Distribution Detection ImageNet-1k vs Places KNN (ResNet-50 SupCon) AUROC 84.62 #17 of 25 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs Places KNN (ResNet-50 SupCon) FPR95 60.02 #17 of 25 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs Places KNN (ResNet-50) AUROC 74.87 #23 of 25 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs Places KNN (ResNet-50) FPR95 77.09 #23 of 25 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs SUN KNN (ResNet-50 SupCon) AUROC 88.40 #15 of 22 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs SUN KNN (ResNet-50 SupCon) FPR95 48.91 #15 of 22 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs SUN KNN (ResNet-50) AUROC 80.10 #19 of 22 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs SUN KNN (ResNet-50) FPR95 69.53 #19 of 22 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs Textures KNN (ResNet-50) AUROC 97.18 #6 of 34 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs Textures KNN (ResNet-50) FPR95 11.56 #6 of 34 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs Textures KNN (ResNet-50 SupCon) AUROC 94.45 #11 of 34 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs Textures KNN (ResNet-50 SupCon) FPR95 16.97 #11 of 34 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs iNaturalist KNN (ResNet-50 SupCon) AUROC 94.72 #16 of 28 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs iNaturalist KNN (ResNet-50 SupCon) FPR95 30.83 #16 of 28 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs iNaturalist KNN (ResNet-50) AUROC 86.2 #22 of 28 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs iNaturalist KNN (ResNet-50) FPR95 59.08 #22 of 28 Archive leaderboard report

Ranks are positions in the archive's leaderboards as they stood at the 2025-07-28 snapshot. Results published since then are not among these rows, so a rank here is not a current standing.

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