{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/nearest-neighbor-guidance-for-out-of-1","title":"Nearest Neighbor Guidance for Out-of-Distribution Detection","arxiv_id":"2309.14888","date":"2023-09-26","proceeding":null,"authors":["Jaewoo Park","Yoon Gyo Jung","Andrew Beng Jin Teoh"],"abstract":"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}.","url_abs":"https://arxiv.org/abs/2309.14888v1","url_pdf":"https://arxiv.org/pdf/2309.14888v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"nearest-neighbor-guidance-for-out-of-1","repo_url":"https://github.com/jingkang50/openood","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"nearest-neighbor-guidance-for-out-of-1","repo_url":"https://github.com/roomo7time/nnguide","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"out-of-distribution-detection","task_name":"Out-of-Distribution Detection"}],"methods":[{"method_slug":"base","method_name":"BASE"}],"datasets_introduced":[],"methods_introduced":[],"results":[{"leaderboard":"/sota/out-of-distribution-detection-on-imagenet-1k-1","task":"Out-of-Distribution Detection","dataset":"ImageNet-1K vs ImageNet-O","model":"NNGuide-ViM (ViT-B/16)","rank_in_archive_order":1,"of":3,"metrics":{"AUROC":"92.96","FPR95":"33.10"},"uses_additional_data":true},{"leaderboard":"/sota/out-of-distribution-detection-on-imagenet-1k-12","task":"Out-of-Distribution Detection","dataset":"ImageNet-1k vs Curated OODs (avg.)","model":"NNGuide (RegNet)","rank_in_archive_order":1,"of":16,"metrics":{"AUROC":"95.42","FPR95":"17.97"},"uses_additional_data":false},{"leaderboard":"/sota/out-of-distribution-detection-on-imagenet-1k-12","task":"Out-of-Distribution Detection","dataset":"ImageNet-1k vs Curated OODs (avg.)","model":"NNGuide (ResNet50 w/ ReAct)","rank_in_archive_order":2,"of":16,"metrics":{"AUROC":"95.45","FPR95":"19.72"},"uses_additional_data":false},{"leaderboard":"/sota/out-of-distribution-detection-on-imagenet-1k-11","task":"Out-of-Distribution Detection","dataset":"ImageNet-1k vs OpenImage-O","model":"NNGuide (RegNet)","rank_in_archive_order":1,"of":7,"metrics":{"AUROC":"97.73","FPR95":"10.79","Latency, ms":"31.00"},"uses_additional_data":false},{"leaderboard":"/sota/out-of-distribution-detection-on-imagenet-1k-11","task":"Out-of-Distribution Detection","dataset":"ImageNet-1k vs OpenImage-O","model":"NNGuide (ResNet50 w/ ReAct)","rank_in_archive_order":5,"of":7,"metrics":{"AUROC":"92.49","FPR95":"35.1","Latency, ms":"11.10"},"uses_additional_data":false},{"leaderboard":"/sota/out-of-distribution-detection-on-imagenet-1k-9","task":"Out-of-Distribution Detection","dataset":"ImageNet-1k vs Places","model":"NNGuide (RegNet)","rank_in_archive_order":3,"of":25,"metrics":{"AUROC":"91.87","FPR95":"31.47"},"uses_additional_data":true},{"leaderboard":"/sota/out-of-distribution-detection-on-imagenet-1k-8","task":"Out-of-Distribution Detection","dataset":"ImageNet-1k vs SUN","model":"NNGuide (RegNet)","rank_in_archive_order":3,"of":22,"metrics":{"AUROC":"94.43","FPR95":"21.58"},"uses_additional_data":true},{"leaderboard":"/sota/out-of-distribution-detection-on-imagenet-1k-10","task":"Out-of-Distribution Detection","dataset":"ImageNet-1k vs Textures","model":"NNGuide (ResNet50 w/ ReAct)","rank_in_archive_order":8,"of":34,"metrics":{"AUROC":"96.11","FPR95":"17.27","Latency, ms":"11.10"},"uses_additional_data":false},{"leaderboard":"/sota/out-of-distribution-detection-on-imagenet-1k-10","task":"Out-of-Distribution Detection","dataset":"ImageNet-1k vs Textures","model":"NNGuide (RegNet)","rank_in_archive_order":9,"of":34,"metrics":{"AUROC":"95.82","FPR95":"17.00","Latency, ms":"31.00"},"uses_additional_data":true},{"leaderboard":"/sota/out-of-distribution-detection-on-imagenet-1k-3","task":"Out-of-Distribution Detection","dataset":"ImageNet-1k vs iNaturalist","model":"NNGuide (RegNet)","rank_in_archive_order":3,"of":28,"metrics":{"AUROC":"99.57","FPR95":"1.83","Latency, ms":"31.00"},"uses_additional_data":false},{"leaderboard":"/sota/out-of-distribution-detection-on-imagenet-1k-3","task":"Out-of-Distribution Detection","dataset":"ImageNet-1k vs iNaturalist","model":"NNGuide (ResNet50 w/ ReAct)","rank_in_archive_order":9,"of":28,"metrics":{"AUROC":"97.7","FPR95":"11.12","Latency, ms":"11.10"},"uses_additional_data":false}],"syntology":{"syntology_url":"https://syntology.ai/paper/2309.14888","atlas_url":"https://app.syntology.ai/?focus=2309.14888","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2309.14888"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/jingkang50/openood","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/roomo7time/nnguide","reach":null}],"summary":{"ran":4,"ran_fixture":2,"unverified":2},"by_repo_kind":{"official":{"samples":8,"ran":6,"repositories":2}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"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"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"c308d7f79dfb5ace","entry":"BasePostprocessor","repo":"jingkang50/openood","repo_kind":"official","path":"openood/postprocessors/nnguide_postprocessor.py","file_url":"https://github.com/jingkang50/openood/blob/HEAD/openood/postprocessors/nnguide_postprocessor.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"c308d7f79dfb5ace"}},{"code_sha256_prefix":"1e5c62cec24c56e4","entry":"NNGuidePostprocessor","repo":"jingkang50/openood","repo_kind":"official","path":"openood/postprocessors/nnguide_postprocessor.py","file_url":"https://github.com/jingkang50/openood/blob/HEAD/openood/postprocessors/nnguide_postprocessor.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"1e5c62cec24c56e4"}},{"code_sha256_prefix":"4f1cf6e198d885d2","entry":"get_rank","repo":"jingkang50/openood","repo_kind":"official","path":"openood/postprocessors/nnguide_postprocessor.py","file_url":"https://github.com/jingkang50/openood/blob/HEAD/openood/postprocessors/nnguide_postprocessor.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4f1cf6e198d885d2"}},{"code_sha256_prefix":"3305c78c72a2232b","entry":"is_main_process","repo":"jingkang50/openood","repo_kind":"official","path":"openood/postprocessors/nnguide_postprocessor.py","file_url":"https://github.com/jingkang50/openood/blob/HEAD/openood/postprocessors/nnguide_postprocessor.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"3305c78c72a2232b"}},{"code_sha256_prefix":"e3a7b669b8599e08","entry":"knn_score","repo":"jingkang50/openood","repo_kind":"official","path":"openood/postprocessors/nnguide_postprocessor.py","file_url":"https://github.com/jingkang50/openood/blob/HEAD/openood/postprocessors/nnguide_postprocessor.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e3a7b669b8599e08"}},{"code_sha256_prefix":"a8d49b0c1c2c5802","entry":"knn_score","repo":"roomo7time/nnguide","repo_kind":"official","path":"ood_detectors/nnguide.py","file_url":"https://github.com/roomo7time/nnguide/blob/HEAD/ood_detectors/nnguide.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"a8d49b0c1c2c5802"}},{"code_sha256_prefix":"95b2f6eda760158c","entry":"NNGuideOODDetector","repo":"roomo7time/nnguide","repo_kind":"official","path":"ood_detectors/nnguide.py","file_url":"https://github.com/roomo7time/nnguide/blob/HEAD/ood_detectors/nnguide.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"95b2f6eda760158c"}},{"code_sha256_prefix":"bb0a165703b4bc07","entry":"OODDetector","repo":"roomo7time/nnguide","repo_kind":"official","path":"ood_detectors/nnguide.py","file_url":"https://github.com/roomo7time/nnguide/blob/HEAD/ood_detectors/nnguide.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"bb0a165703b4bc07"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}