Papers › CoRNStack: High-Quality Contrastive Data for Better Code Retrieval and Reranking

CoRNStack: High-Quality Contrastive Data for Better Code Retrieval and Reranking

1 Dec 2024arXiv:2412.01007archive 2025-07-28

Tarun Suresh, Revanth Gangi Reddy, Yifei Xu, Zach Nussbaum, Andriy Mulyar, Brandon Duderstadt, Heng Ji

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.

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="2412.01007")

Code

Syntology Ran 0 of 14 code samples harvested from 1 repository linked to this paper; 14 have no recorded run.

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

gangiswag/cornstack officialmentioned in paperApache-2.0 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

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

14unverified

Licence: 0 of the 14 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 gangiswag/cornstack. “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.

convert_nl2code_examples_to_features gangiswag/cornstack/src/create/utils.py official repository unverified Apache-2.0 (permissive) · c69d01c2084ebd2a · report
convert_solutions_dict gangiswag/cornstack/src/evaluations/eval_localization.py official repository unverified Apache-2.0 (permissive) · 6f9605ad563fe8e2 · report
create_structure gangiswag/cornstack/src/get_repo_structure/get_repo_structure.py official repository unverified Apache-2.0 (permissive) · f1736b2867021430 · report
evaluate_results gangiswag/cornstack/src/rerank.py official repository unverified Apache-2.0 (permissive) · f86d9af6bb4990db · report
get_project_structure_from_scratch gangiswag/cornstack/src/get_repo_structure/get_repo_structure.py official repository unverified Apache-2.0 (permissive) · f39c013c44ae666e · report
get_top_docs gangiswag/cornstack/src/evaluations/eval_swebench.py official repository unverified Apache-2.0 (permissive) · 04d54a12d25d3ae7 · report
ingest_files gangiswag/cornstack/src/create/swebench.py official repository unverified Apache-2.0 (permissive) · 2b0d2c14b7cc8d61 · report
is_test gangiswag/cornstack/src/create/swebench.py official repository unverified Apache-2.0 (permissive) · 066de324a66b8e18 · report
parse_patch gangiswag/cornstack/src/get_repo_structure/get_patch_info.py official repository unverified Apache-2.0 (permissive) · f2c4e9391d254c7e · report
parse_python_file gangiswag/cornstack/src/get_repo_structure/get_repo_structure.py official repository unverified Apache-2.0 (permissive) · 94dc3cbe589f0afa · report
patch_to_dict gangiswag/cornstack/src/get_repo_structure/get_patch_info.py official repository unverified Apache-2.0 (permissive) · 57f9d3d6cb7bc783 · report
read_jsonl gangiswag/cornstack/src/evaluations/eval_localization.py official repository unverified Apache-2.0 (permissive) · a4312a4596349487 · report
split_github_patch gangiswag/cornstack/src/get_repo_structure/get_patch_info.py official repository unverified Apache-2.0 (permissive) · d276dddd6eaf20be · report
topk_accuracy gangiswag/cornstack/src/evaluations/eval_localization.py official repository unverified Apache-2.0 (permissive) · 323b01ced4cb3d3f · report

Tasks

Bug fixingCode GenerationRerankingRetrievalText Reranking

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

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