This is the code repository for our ECIR2025 reproducibility paper 《Reproducing HotFlip for Corpus Poisoning Attacks in Dense Retrieval 》.
datasets/ contains the datasets files used in the experiments.results/ contains the results of the experiments.scripts/ contains the scripts to run the experiments.utils/ contains the utility functions used in the experiments.The datasets used in the experiments are from the BEIR library. The datasets are stored in the datasets/ folder. These datasets will download automatically when you run the code.
Things need for the experiments in RQ1:
embedding_index.py is used to index the embeddings of the corpus, and save the retrieval results by BEIR.hotflip_raw.py is used to generate the adversarial examples by hotflip (Zhong et al., 2023).hotflip_attack_ours.py is used to generate the adversarial examples by hotflip (Zhong et al., 2023) with our pipeline optimizing strategy (Mean embedding).evaluate_attack.py is used to evaluate the attack performance of the adversarial examples. The retrieval results are saved in results/.attack_results_statistics.py is used to calculate the statistics of the attack results.Things need for the experiments in RQ2:
evaluate_attack.py is used to evaluate the attack performance of the adversarial examples. The retrieval results are saved in results/.transfer_attack_statical.py is used to calculate the statistics of the attack results of black-box attacks.Things need for the experiments in RQ3:
hotflip_ours_attack_corpus.py is used for the corpus poisoning attack with our pipeline optimizing strategy (Mean embedding).sbatch scripts/embedding_index.sh to get the retrieval results of the all datsaets with all retrievers. The retrieval results are saved in results/beir_result.sbatch scripts/generate_hotflip_multi_raw.sh to generate the adversarial examples by hotflip (Zhong et al., 2023). The adversarial examples are saved in results/hotflip_raw-generate.sbatch scripts/generate_hotflip_multi.sh to generate the adversarial examples by hotflip (Zhong et al., 2023) with our pipeline optimizing strategy (Mean embedding). The adversarial examples are saved in results/hotflip-generate.sbatch scripts/evaluate_attack.sh to evaluate the attack performance of the adversarial examples. The results are saved in results/attack_results.python attack_results_statistics.py to calculate the statistics of the attack results.sbatch scripts/transfer_attack.sh. The retrieval results are saved in results/attack_results/hotflip and results/attack_results/hotflip_raw.python transfer_attack_statical.py --method hotflip_raw and python transfer_attack_statical.py --method hotflip to calculate the statistics of the attack results of black-box attacks. Remember to change the method to hotflip_raw and hotflip respectively. And change seed_list = [1999] only for k_list=[10] in the evaluation hotflip_raw method.sbatch scripts/attack_corpus_ous.sh to generate the adversarial passages for the corpus poisoning attack. The results are saved in results_corpus_attack/hotflip-generate.If you find this code useful, I would greatly appreciate it if you could cite our paper:
@inproceedings{li2025reproducinghotflip,
title={Reproducing HotFlip for Corpus Poisoning Attacks in Dense Retrieval},
author={Yongkang Li and Panagiotis Eustratiadis and Evangelos Kanoulas},
booktitle = {Advances in Information Retrieval - 47th European Conference on Information
Retrieval, {ECIR} 2025, Lucca, Italy, April 6-10, 2025, Proceedings,
Part {IV}},
series = {Lecture Notes in Computer Science},
volume = {15575},
pages = {95--111},
publisher = {Springer},
year = {2025},
url = {https://doi.org/10.1007/978-3-031-88717-8\_8},
doi = {10.1007/978-3-031-88717-8\_8},
}
16 commits
Python
94.1%
Shell
5.9%
This is the code repository for our ECIR2025 reproducibility paper 《Reproducing HotFlip for Corpus Poisoning Attacks in Dense Retrieval 》.
datasets/ contains the datasets files used in the experiments.results/ contains the results of the experiments.scripts/ contains the scripts to run the experiments.utils/ contains the utility functions used in the experiments.The datasets used in the experiments are from the BEIR library. The datasets are stored in the datasets/ folder. These datasets will download automatically when you run the code.
Things need for the experiments in RQ1:
embedding_index.py is used to index the embeddings of the corpus, and save the retrieval results by BEIR.hotflip_raw.py is used to generate the adversarial examples by hotflip (Zhong et al., 2023).hotflip_attack_ours.py is used to generate the adversarial examples by hotflip (Zhong et al., 2023) with our pipeline optimizing strategy (Mean embedding).evaluate_attack.py is used to evaluate the attack performance of the adversarial examples. The retrieval results are saved in results/.attack_results_statistics.py is used to calculate the statistics of the attack results.Things need for the experiments in RQ2:
evaluate_attack.py is used to evaluate the attack performance of the adversarial examples. The retrieval results are saved in results/.transfer_attack_statical.py is used to calculate the statistics of the attack results of black-box attacks.Things need for the experiments in RQ3:
hotflip_ours_attack_corpus.py is used for the corpus poisoning attack with our pipeline optimizing strategy (Mean embedding).sbatch scripts/embedding_index.sh to get the retrieval results of the all datsaets with all retrievers. The retrieval results are saved in results/beir_result.sbatch scripts/generate_hotflip_multi_raw.sh to generate the adversarial examples by hotflip (Zhong et al., 2023). The adversarial examples are saved in results/hotflip_raw-generate.sbatch scripts/generate_hotflip_multi.sh to generate the adversarial examples by hotflip (Zhong et al., 2023) with our pipeline optimizing strategy (Mean embedding). The adversarial examples are saved in results/hotflip-generate.sbatch scripts/evaluate_attack.sh to evaluate the attack performance of the adversarial examples. The results are saved in results/attack_results.python attack_results_statistics.py to calculate the statistics of the attack results.sbatch scripts/transfer_attack.sh. The retrieval results are saved in results/attack_results/hotflip and results/attack_results/hotflip_raw.python transfer_attack_statical.py --method hotflip_raw and python transfer_attack_statical.py --method hotflip to calculate the statistics of the attack results of black-box attacks. Remember to change the method to hotflip_raw and hotflip respectively. And change seed_list = [1999] only for k_list=[10] in the evaluation hotflip_raw method.sbatch scripts/attack_corpus_ous.sh to generate the adversarial passages for the corpus poisoning attack. The results are saved in results_corpus_attack/hotflip-generate.If you find this code useful, I would greatly appreciate it if you could cite our paper:
@inproceedings{li2025reproducinghotflip,
title={Reproducing HotFlip for Corpus Poisoning Attacks in Dense Retrieval},
author={Yongkang Li and Panagiotis Eustratiadis and Evangelos Kanoulas},
booktitle = {Advances in Information Retrieval - 47th European Conference on Information
Retrieval, {ECIR} 2025, Lucca, Italy, April 6-10, 2025, Proceedings,
Part {IV}},
series = {Lecture Notes in Computer Science},
volume = {15575},
pages = {95--111},
publisher = {Springer},
year = {2025},
url = {https://doi.org/10.1007/978-3-031-88717-8\_8},
doi = {10.1007/978-3-031-88717-8\_8},
}
16 commits
Python
94.1%
Shell
5.9%