{"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/cornstack-high-quality-contrastive-data-for","title":"CoRNStack: High-Quality Contrastive Data for Better Code Retrieval and Reranking","arxiv_id":"2412.01007","date":"2024-12-01","proceeding":null,"authors":["Tarun Suresh","Revanth Gangi Reddy","Yifei Xu","Zach Nussbaum","Andriy Mulyar","Brandon Duderstadt","Heng Ji"],"abstract":"Effective code retrieval plays a crucial role in advancing code generation, bug fixing, and software maintenance, particularly as software systems increase in complexity. While current code embedding models have demonstrated promise in retrieving code snippets for small-scale, well-defined tasks, they often underperform in more demanding real-world applications such as bug localization within GitHub repositories. We hypothesize that a key issue is their reliance on noisy and inconsistent datasets for training, which impedes their ability to generalize to more complex retrieval scenarios. To address these limitations, we introduce CoRNStack, a large-scale, high-quality contrastive training dataset for code that spans multiple programming languages. This dataset is curated using consistency filtering to eliminate noisy positives and is further enriched with mined hard negatives, thereby facilitating more effective learning. We demonstrate that contrastive training of embedding models using CoRNStack leads to state-of-the-art performance across a variety of code retrieval tasks. Furthermore, the dataset can be leveraged for training code reranking models, a largely underexplored area compared to text reranking. Our finetuned code reranking model significantly improves the ranking quality over the retrieved results. Finally, by employing our code retriever and reranker together, we demonstrate significant improvements in function localization for GitHub issues, an important component of real-world software development.","url_abs":"https://arxiv.org/abs/2412.01007v3","url_pdf":"https://arxiv.org/pdf/2412.01007v3.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":"cornstack-high-quality-contrastive-data-for","repo_url":"https://github.com/gangiswag/cornstack","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":0,"framework":"none","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[{"task_slug":"bug-fixing","task_name":"Bug fixing"},{"task_slug":"code-generation","task_name":"Code Generation"},{"task_slug":"reranking","task_name":"Reranking"},{"task_slug":"retrieval","task_name":"Retrieval"},{"task_slug":"text-reranking","task_name":"Text Reranking"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2412.01007","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2412.01007"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+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/gangiswag/cornstack","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"unverified":14},"by_repo_kind":{"official":{"samples":14,"ran":0,"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":0,"samples":[{"code_sha256_prefix":"c69d01c2084ebd2a","entry":"convert_nl2code_examples_to_features","repo":"gangiswag/cornstack","repo_kind":"official","path":"src/create/utils.py","file_url":"https://github.com/gangiswag/cornstack/blob/HEAD/src/create/utils.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":"c69d01c2084ebd2a"}},{"code_sha256_prefix":"6f9605ad563fe8e2","entry":"convert_solutions_dict","repo":"gangiswag/cornstack","repo_kind":"official","path":"src/evaluations/eval_localization.py","file_url":"https://github.com/gangiswag/cornstack/blob/HEAD/src/evaluations/eval_localization.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":"6f9605ad563fe8e2"}},{"code_sha256_prefix":"f1736b2867021430","entry":"create_structure","repo":"gangiswag/cornstack","repo_kind":"official","path":"src/get_repo_structure/get_repo_structure.py","file_url":"https://github.com/gangiswag/cornstack/blob/HEAD/src/get_repo_structure/get_repo_structure.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":"f1736b2867021430"}},{"code_sha256_prefix":"f86d9af6bb4990db","entry":"evaluate_results","repo":"gangiswag/cornstack","repo_kind":"official","path":"src/rerank.py","file_url":"https://github.com/gangiswag/cornstack/blob/HEAD/src/rerank.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":"f86d9af6bb4990db"}},{"code_sha256_prefix":"f39c013c44ae666e","entry":"get_project_structure_from_scratch","repo":"gangiswag/cornstack","repo_kind":"official","path":"src/get_repo_structure/get_repo_structure.py","file_url":"https://github.com/gangiswag/cornstack/blob/HEAD/src/get_repo_structure/get_repo_structure.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":"f39c013c44ae666e"}},{"code_sha256_prefix":"04d54a12d25d3ae7","entry":"get_top_docs","repo":"gangiswag/cornstack","repo_kind":"official","path":"src/evaluations/eval_swebench.py","file_url":"https://github.com/gangiswag/cornstack/blob/HEAD/src/evaluations/eval_swebench.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":"04d54a12d25d3ae7"}},{"code_sha256_prefix":"2b0d2c14b7cc8d61","entry":"ingest_files","repo":"gangiswag/cornstack","repo_kind":"official","path":"src/create/swebench.py","file_url":"https://github.com/gangiswag/cornstack/blob/HEAD/src/create/swebench.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":"2b0d2c14b7cc8d61"}},{"code_sha256_prefix":"066de324a66b8e18","entry":"is_test","repo":"gangiswag/cornstack","repo_kind":"official","path":"src/create/swebench.py","file_url":"https://github.com/gangiswag/cornstack/blob/HEAD/src/create/swebench.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":"066de324a66b8e18"}},{"code_sha256_prefix":"f2c4e9391d254c7e","entry":"parse_patch","repo":"gangiswag/cornstack","repo_kind":"official","path":"src/get_repo_structure/get_patch_info.py","file_url":"https://github.com/gangiswag/cornstack/blob/HEAD/src/get_repo_structure/get_patch_info.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":"f2c4e9391d254c7e"}},{"code_sha256_prefix":"94dc3cbe589f0afa","entry":"parse_python_file","repo":"gangiswag/cornstack","repo_kind":"official","path":"src/get_repo_structure/get_repo_structure.py","file_url":"https://github.com/gangiswag/cornstack/blob/HEAD/src/get_repo_structure/get_repo_structure.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":"94dc3cbe589f0afa"}},{"code_sha256_prefix":"57f9d3d6cb7bc783","entry":"patch_to_dict","repo":"gangiswag/cornstack","repo_kind":"official","path":"src/get_repo_structure/get_patch_info.py","file_url":"https://github.com/gangiswag/cornstack/blob/HEAD/src/get_repo_structure/get_patch_info.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":"57f9d3d6cb7bc783"}},{"code_sha256_prefix":"a4312a4596349487","entry":"read_jsonl","repo":"gangiswag/cornstack","repo_kind":"official","path":"src/evaluations/eval_localization.py","file_url":"https://github.com/gangiswag/cornstack/blob/HEAD/src/evaluations/eval_localization.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":"a4312a4596349487"}},{"code_sha256_prefix":"d276dddd6eaf20be","entry":"split_github_patch","repo":"gangiswag/cornstack","repo_kind":"official","path":"src/get_repo_structure/get_patch_info.py","file_url":"https://github.com/gangiswag/cornstack/blob/HEAD/src/get_repo_structure/get_patch_info.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":"d276dddd6eaf20be"}},{"code_sha256_prefix":"323b01ced4cb3d3f","entry":"topk_accuracy","repo":"gangiswag/cornstack","repo_kind":"official","path":"src/evaluations/eval_localization.py","file_url":"https://github.com/gangiswag/cornstack/blob/HEAD/src/evaluations/eval_localization.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":"323b01ced4cb3d3f"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}