Table of Contents
Fetching ...

Code Search Debiasing:Improve Search Results beyond Overall Ranking Performance

Sheng Zhang, Hui Li, Yanlin Wang, Zhao Wei, Yong Xiu, Juhong Wang, Rongong Ji

TL;DR

This work identifies pervasive biases in state-of-the-art code search models, showing that performance varies with properties like code/query length and lexical overlap. It proposes a general, plug-in post-processing debiasing framework based on reranking that leverages training-query similarities and clustering to decide when reranking is needed, and then adjusts candidate scores with a bias-aware term $R = Score^{original}_{c} + P(T_{e} < T_{m})$. Through extensive experiments on the CoSQA dataset across six code search models, the framework yields consistent gains in $MRR$ and $HR@K$, and human evaluators favor debiased results for the majority of queries. The approach demonstrates that mitigating bias can concurrently improve overall ranking performance, offering a practical path to more reliable and inclusive code search systems. Future work includes exploring pre- and in-processing debiasing methods and broadening language and dataset coverage.

Abstract

Code search engine is an essential tool in software development. Many code search methods have sprung up, focusing on the overall ranking performance of code search. In this paper, we study code search from another perspective by analyzing the bias of code search models. Biased code search engines provide poor user experience, even though they show promising overall performance. Due to different development conventions (e.g., prefer long queries or abbreviations), some programmers will find the engine useful, while others may find it hard to get desirable search results. To mitigate biases, we develop a general debiasing framework that employs reranking to calibrate search results. It can be easily plugged into existing engines and handle new code search biases discovered in the future. Experiments show that our framework can effectively reduce biases. Meanwhile, the overall ranking performance of code search gets improved after debiasing.

Code Search Debiasing:Improve Search Results beyond Overall Ranking Performance

TL;DR

This work identifies pervasive biases in state-of-the-art code search models, showing that performance varies with properties like code/query length and lexical overlap. It proposes a general, plug-in post-processing debiasing framework based on reranking that leverages training-query similarities and clustering to decide when reranking is needed, and then adjusts candidate scores with a bias-aware term . Through extensive experiments on the CoSQA dataset across six code search models, the framework yields consistent gains in and , and human evaluators favor debiased results for the majority of queries. The approach demonstrates that mitigating bias can concurrently improve overall ranking performance, offering a practical path to more reliable and inclusive code search systems. Future work includes exploring pre- and in-processing debiasing methods and broadening language and dataset coverage.

Abstract

Code search engine is an essential tool in software development. Many code search methods have sprung up, focusing on the overall ranking performance of code search. In this paper, we study code search from another perspective by analyzing the bias of code search models. Biased code search engines provide poor user experience, even though they show promising overall performance. Due to different development conventions (e.g., prefer long queries or abbreviations), some programmers will find the engine useful, while others may find it hard to get desirable search results. To mitigate biases, we develop a general debiasing framework that employs reranking to calibrate search results. It can be easily plugged into existing engines and handle new code search biases discovered in the future. Experiments show that our framework can effectively reduce biases. Meanwhile, the overall ranking performance of code search gets improved after debiasing.
Paper Structure (10 sections, 5 figures, 4 tables)

This paper contains 10 sections, 5 figures, 4 tables.

Figures (5)

  • Figure 1: Examples of code search biases.
  • Figure 3: Mitigate biases using sequential reranking.
  • Figure 4: Mitigate biases using parallel reranking.
  • Figure 5: Changes of overall MRR after applying each reranker in sequential reranking.
  • Figure 6: Sequential reranking in different order.