Papers › Nearest Neighbor Guidance for Out-of-Distribution Detection

Nearest Neighbor Guidance for Out-of-Distribution Detection

26 Sep 2023arXiv:2309.14888archive 2025-07-28

Jaewoo Park, Yoon Gyo Jung, Andrew Beng Jin Teoh

Detecting out-of-distribution (OOD) samples are crucial for machine learning models deployed in open-world environments. Classifier-based scores are a standard approach for OOD detection due to their fine-grained detection capability. However, these scores often suffer from overconfidence issues, misclassifying OOD samples distant from the in-distribution region. To address this challenge, we propose a method called Nearest Neighbor Guidance (NNGuide) that guides the classifier-based score to respect the boundary geometry of the data manifold. NNGuide reduces the overconfidence of OOD samples while preserving the fine-grained capability of the classifier-based score. We conduct extensive experiments on ImageNet OOD detection benchmarks under diverse settings, including a scenario where the ID data undergoes natural distribution shift. Our results demonstrate that NNGuide provides a significant performance improvement on the base detection scores, achieving state-of-the-art results on both AUROC, FPR95, and AUPR metrics. The code is given at \url{https://github.com/roomo7time/nnguide}.

PaperPDFConference PDFCodeCode 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="2309.14888")

Code

Syntology Ran 6 of 8 code samples harvested from 2 repositories linked to this paper; 2 have no recorded run. Of those that ran: 2 ran · fixture could not drive it; 4 ran with no contract checked.

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

jingkang50/openood officialmentioned in papermentioned on GitHubpytorchMIT report
roomo7time/nnguide officialmentioned in papermentioned 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

8 samples harvested; 6 ran; 0 honoured the contract we drafted; 2 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.

2ran · fixture could not drive it
4ran
2unverified

Licence: 0 of the 8 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.

BasePostprocessor jingkang50/openood/openood/postprocessors/nnguide_postprocessor.py official repository ran MIT (permissive) · c308d7f79dfb5ace · report
NNGuidePostprocessor jingkang50/openood/openood/postprocessors/nnguide_postprocessor.py official repository ran MIT (permissive) · 1e5c62cec24c56e4 · report
get_rank jingkang50/openood/openood/postprocessors/nnguide_postprocessor.py official repository ran · metamorphic tier: well formed MIT (permissive) · 4f1cf6e198d885d2 · report
is_main_process jingkang50/openood/openood/postprocessors/nnguide_postprocessor.py official repository ran · metamorphic tier: deterministic MIT (permissive) · 3305c78c72a2232b · report
knn_score jingkang50/openood/openood/postprocessors/nnguide_postprocessor.py official repository ran · fixture could not drive it MIT (permissive) · e3a7b669b8599e08 · report
knn_score roomo7time/nnguide/ood_detectors/nnguide.py official repository ran · fixture could not drive it Apache-2.0 (permissive) · a8d49b0c1c2c5802 · report
NNGuideOODDetector roomo7time/nnguide/ood_detectors/nnguide.py official repository unverified Apache-2.0 (permissive) · 95b2f6eda760158c · report
OODDetector roomo7time/nnguide/ood_detectors/nnguide.py official repository unverified Apache-2.0 (permissive) · bb0a165703b4bc07 · report

Tasks

Out-of-Distribution Detection

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Out-of-Distribution Detection ImageNet-1K vs ImageNet-O NNGuide-ViM (ViT-B/16) AUROC 92.96 #1 of 3 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1K vs ImageNet-O NNGuide-ViM (ViT-B/16) FPR95 33.10 #1 of 3 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs Curated OODs (avg.) NNGuide (RegNet) AUROC 95.42 #1 of 16 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs Curated OODs (avg.) NNGuide (RegNet) FPR95 17.97 #1 of 16 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs Curated OODs (avg.) NNGuide (ResNet50 w/ ReAct) AUROC 95.45 #2 of 16 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs Curated OODs (avg.) NNGuide (ResNet50 w/ ReAct) FPR95 19.72 #2 of 16 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs OpenImage-O NNGuide (RegNet) AUROC 97.73 #1 of 7 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs OpenImage-O NNGuide (RegNet) FPR95 10.79 #1 of 7 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs OpenImage-O NNGuide (RegNet) Latency, ms 31.00 #1 of 7 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs OpenImage-O NNGuide (ResNet50 w/ ReAct) AUROC 92.49 #5 of 7 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs OpenImage-O NNGuide (ResNet50 w/ ReAct) FPR95 35.1 #5 of 7 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs OpenImage-O NNGuide (ResNet50 w/ ReAct) Latency, ms 11.10 #5 of 7 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs Places NNGuide (RegNet) AUROC 91.87 #3 of 25 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs Places NNGuide (RegNet) FPR95 31.47 #3 of 25 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs SUN NNGuide (RegNet) AUROC 94.43 #3 of 22 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs SUN NNGuide (RegNet) FPR95 21.58 #3 of 22 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs Textures NNGuide (ResNet50 w/ ReAct) AUROC 96.11 #8 of 34 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs Textures NNGuide (ResNet50 w/ ReAct) FPR95 17.27 #8 of 34 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs Textures NNGuide (ResNet50 w/ ReAct) Latency, ms 11.10 #8 of 34 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs Textures NNGuide (RegNet) AUROC 95.82 #9 of 34 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs Textures NNGuide (RegNet) FPR95 17.00 #9 of 34 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs Textures NNGuide (RegNet) Latency, ms 31.00 #9 of 34 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs iNaturalist NNGuide (RegNet) AUROC 99.57 #3 of 28 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs iNaturalist NNGuide (RegNet) FPR95 1.83 #3 of 28 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs iNaturalist NNGuide (RegNet) Latency, ms 31.00 #3 of 28 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs iNaturalist NNGuide (ResNet50 w/ ReAct) AUROC 97.7 #9 of 28 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs iNaturalist NNGuide (ResNet50 w/ ReAct) FPR95 11.12 #9 of 28 Archive leaderboard report
Out-of-Distribution Detection ImageNet-1k vs iNaturalist NNGuide (ResNet50 w/ ReAct) Latency, ms 11.10 #9 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.

Methods

BASE

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