โน๏ธย About | ๐ย More About CORNSTACK | ๐ย Quick Start | ๐ย Running Evaluation | ๐ย Running Reranker
The performance of code embedding models is highly contingent on the quality of the large-scale data used for contrastive training. Effective contrastive training hinges on satisfying two primary conditions:
Existing approaches heuristically source contrastive examples from large-scale open-source code data with limited filtering and mining, retaining irrelevant or incorrectly labeled <query, positive> pairs, which impair the modelsโ ability to learn robust and accurate representations. To address these challenges, we introduce curriculum-based hard negative mining and consistency filtering techniques and apply these techniques on the de-duplicated version of The Stack v2. More details on these specific curation techniques and how we use them to train embedding models and re-rankers in our paper coming soon!
Install the required dependencies:
pip install -r requirements.txt
To reproduce the performance of CodeRankEmbed on popular code retrieval benchmarks, run the following commands:
cd src/
python evaluation/eval_coir.py
cd src/
python create/csn.py
python evaluation/eval_csn.py
Ignore any errors when running python create/csn.py.
cd src/
python create/swebench.py
python evaluation/eval_swebench.py
python evaluation/eval_localization.py --level file #print out file localization top-k results
python evaluation/eval_localization.py --level function #print out function localization top-k results
Initialize and update the submodules:
# Initialize submodules
git submodule init
git submodule update
Note: You need to install the vLLM library (instructions here) which provides optimization for LLM inference.
To run the complete pipeline including retrieval and reranking:
cd src/
./run_pipeline.sh
The pipeline script supports several options:
--dataset_dir: Directory for datasets (default: ./datasets)--output_dir: Directory for outputs (default: ./outputs)--eval_dir: Directory for evaluation results (default: ./evaluations)--top_k: Number of candidates to rerank (default: 100)--window_size: Window size for reranking (default: 10)--step_size: Step size for reranking (default: 5)--skip_retriever: Skip retrieval step if you already have retrieval results (default: 1)The pipeline will:
Results will be saved in:
{output_dir}/code_datasets/{dataset_name}/{eval_dir}/eval_results/{dataset_name}_eval.jsonWe plan to release the full training and dataset curation code soon!
If this repo was useful to you, please consider citing our work:
@inproceedings{sureshcornstack,
title={CoRNStack: High-Quality Contrastive Data for Better Code Retrieval and Reranking},
author={Suresh, Tarun and Reddy, Revanth Gangi and Xu, Yifei and Nussbaum, Zach and Mulyar, Andriy and Duderstadt, Brandon and Ji, Heng},
booktitle={The Thirteenth International Conference on Learning Representations},
year={2025}
}
JavaScript
47.3%
Python
39.3%
HTML
11.3%
Shell
1.1%
โน๏ธย About | ๐ย More About CORNSTACK | ๐ย Quick Start | ๐ย Running Evaluation | ๐ย Running Reranker
The performance of code embedding models is highly contingent on the quality of the large-scale data used for contrastive training. Effective contrastive training hinges on satisfying two primary conditions:
Existing approaches heuristically source contrastive examples from large-scale open-source code data with limited filtering and mining, retaining irrelevant or incorrectly labeled <query, positive> pairs, which impair the modelsโ ability to learn robust and accurate representations. To address these challenges, we introduce curriculum-based hard negative mining and consistency filtering techniques and apply these techniques on the de-duplicated version of The Stack v2. More details on these specific curation techniques and how we use them to train embedding models and re-rankers in our paper coming soon!
Install the required dependencies:
pip install -r requirements.txt
To reproduce the performance of CodeRankEmbed on popular code retrieval benchmarks, run the following commands:
cd src/
python evaluation/eval_coir.py
cd src/
python create/csn.py
python evaluation/eval_csn.py
Ignore any errors when running python create/csn.py.
cd src/
python create/swebench.py
python evaluation/eval_swebench.py
python evaluation/eval_localization.py --level file #print out file localization top-k results
python evaluation/eval_localization.py --level function #print out function localization top-k results
Initialize and update the submodules:
# Initialize submodules
git submodule init
git submodule update
Note: You need to install the vLLM library (instructions here) which provides optimization for LLM inference.
To run the complete pipeline including retrieval and reranking:
cd src/
./run_pipeline.sh
The pipeline script supports several options:
--dataset_dir: Directory for datasets (default: ./datasets)--output_dir: Directory for outputs (default: ./outputs)--eval_dir: Directory for evaluation results (default: ./evaluations)--top_k: Number of candidates to rerank (default: 100)--window_size: Window size for reranking (default: 10)--step_size: Step size for reranking (default: 5)--skip_retriever: Skip retrieval step if you already have retrieval results (default: 1)The pipeline will:
Results will be saved in:
{output_dir}/code_datasets/{dataset_name}/{eval_dir}/eval_results/{dataset_name}_eval.jsonWe plan to release the full training and dataset curation code soon!
If this repo was useful to you, please consider citing our work:
@inproceedings{sureshcornstack,
title={CoRNStack: High-Quality Contrastive Data for Better Code Retrieval and Reranking},
author={Suresh, Tarun and Reddy, Revanth Gangi and Xu, Yifei and Nussbaum, Zach and Mulyar, Andriy and Duderstadt, Brandon and Ji, Heng},
booktitle={The Thirteenth International Conference on Learning Representations},
year={2025}
}
JavaScript
47.3%
Python
39.3%
HTML
11.3%
Shell
1.1%