{"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/a-cosine-similarity-based-method-for-out-of","title":"A Cosine Similarity-based Method for Out-of-Distribution Detection","arxiv_id":"2306.14920","date":"2023-06-23","proceeding":null,"authors":["Nguyen Ngoc-Hieu","Nguyen Hung-Quang","The-Anh Ta","Thanh Nguyen-Tang","Khoa D Doan","Hoang Thanh-Tung"],"abstract":"The ability to detect OOD data is a crucial aspect of practical machine learning applications. In this work, we show that cosine similarity between the test feature and the typical ID feature is a good indicator of OOD data. We propose Class Typical Matching (CTM), a post hoc OOD detection algorithm that uses a cosine similarity scoring function. Extensive experiments on multiple benchmarks show that CTM outperforms existing post hoc OOD detection methods.","url_abs":"https://arxiv.org/abs/2306.14920v1","url_pdf":"https://arxiv.org/pdf/2306.14920v1.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":"a-cosine-similarity-based-method-for-out-of","repo_url":"https://github.com/Fsoft-AIC/CTM_OOD","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[{"task_slug":"out-of-distribution-detection","task_name":"Out-of-Distribution Detection"}],"methods":[{"method_slug":"hoc","method_name":"HOC"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":"https://syntology.ai/paper/2306.14920","atlas_url":"https://app.syntology.ai/?focus=2306.14920","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2306.14920"}},"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/Fsoft-AIC/CTM_OOD","reach":null}],"summary":{"ran":3,"ran_draft_wrong":2},"by_repo_kind":{"official":{"samples":5,"ran":5,"repositories":1}},"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":5,"samples":[{"code_sha256_prefix":"4f345573217a12a9","entry":"BaseDetector","repo":"Fsoft-AIC/CTM_OOD","repo_kind":"official","path":"core/detection/methods/post_hoc/ctm.py","file_url":"https://github.com/Fsoft-AIC/CTM_OOD/blob/HEAD/core/detection/methods/post_hoc/ctm.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"4f345573217a12a9"}},{"code_sha256_prefix":"4cdef9087c772540","entry":"CTMDetector","repo":"Fsoft-AIC/CTM_OOD","repo_kind":"official","path":"core/detection/methods/post_hoc/ctm.py","file_url":"https://github.com/Fsoft-AIC/CTM_OOD/blob/HEAD/core/detection/methods/post_hoc/ctm.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"4cdef9087c772540"}},{"code_sha256_prefix":"dd932737281e5d77","entry":"CalMeanClass","repo":"Fsoft-AIC/CTM_OOD","repo_kind":"official","path":"core/detection/methods/post_hoc/ctm.py","file_url":"https://github.com/Fsoft-AIC/CTM_OOD/blob/HEAD/core/detection/methods/post_hoc/ctm.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"dd932737281e5d77"}},{"code_sha256_prefix":"dacdb628d43ce1f8","entry":"list_feature_by_class","repo":"Fsoft-AIC/CTM_OOD","repo_kind":"official","path":"core/detection/methods/post_hoc/ctm.py","file_url":"https://github.com/Fsoft-AIC/CTM_OOD/blob/HEAD/core/detection/methods/post_hoc/ctm.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"dacdb628d43ce1f8"}},{"code_sha256_prefix":"bed403f50a747043","entry":"mean_and_normalize_list_features","repo":"Fsoft-AIC/CTM_OOD","repo_kind":"official","path":"core/detection/methods/post_hoc/ctm.py","file_url":"https://github.com/Fsoft-AIC/CTM_OOD/blob/HEAD/core/detection/methods/post_hoc/ctm.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"bed403f50a747043"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}