Skip to main content
QUICK REVIEW

[Paper Review] Neural Code Search Evaluation Dataset

Hongyu Li, Seohyun Kim|arXiv (Cornell University)|Aug 26, 2019
Natural Language Processing TechniquesComputer Science4 references23 citations
TL;DR

This paper introduces a benchmark evaluation dataset for neural code search, comprising 287 natural language queries from Stack Overflow paired with relevant code snippets from GitHub and ground-truth method-level matches. It evaluates two models (NCS and UNIF) using metrics like Answered@1, Answered@5, and MRR, with UNIF stackoverflow achieving the highest MRR of 0.465.

ABSTRACT

There has been an increase of interest in code search using natural language. Assessing the performance of such code search models can be difficult without a readily available evaluation suite. In this paper, we present an evaluation dataset consisting of natural language query and code snippet pairs, with the hope that future work in this area can use this dataset as a common benchmark. We also provide the results of two code search models ([1] and [6]) from recent work. The evaluation dataset is available at https://github.com/facebookresearch/Neural-Code-Search-Evaluation-Dataset

Motivation & Objective

  • To address the lack of a standardized benchmark for evaluating neural code search models.
  • To provide a reproducible, publicly available dataset of natural language queries and corresponding code snippet matches from real-world developer questions.
  • To enable systematic comparison of code search models using consistent evaluation metrics.
  • To release pre-evaluated results for two custom models (NCS and UNIF) to serve as baseline performance benchmarks.
  • To support future research in learning semantic mappings between natural language and code using a realistic, production-scale corpus.

Proposed method

  • Constructed a search corpus from 24,549 popular Android GitHub repositories, indexing 4.7 million method bodies by file path, method name, and line numbers.
  • Collected 287 Stack Overflow question-answer pairs with upvoted code answers, filtered for relevance, clarity, and code snippet matchability in the search corpus.
  • Used the Aroma code similarity tool with a threshold of 0.25 to automatically validate whether a method in the corpus correctly answers a query.
  • Built two models: NCS (unsupervised using word embeddings from the corpus) and UNIF (supervised with attention-based neural networks trained on GitHub and Stack Overflow data).
  • Applied post-rank re-ranking in NCS postrank to improve top-k results using similarity scores.
  • Reported performance using Answered@1, Answered@5, Answered@10, and Mean Reciprocal Rank (MRR) across all 287 queries.

Experimental results

Research questions

  • RQ1Can a standardized, publicly available dataset improve reproducibility and comparability in neural code search research?
  • RQ2How do unsupervised and supervised neural code search models perform on real-world developer queries from Stack Overflow?
  • RQ3To what extent does post-rank re-ranking improve the top-k retrieval performance of code search models?
  • RQ4What is the performance gap between models trained on GitHub-only data versus those fine-tuned on Stack Overflow answer pairs?
  • RQ5How well do automatic code similarity metrics (e.g., Aroma) correlate with human judgment in evaluating code search correctness?

Key findings

  • The UNIF stackoverflow model achieved the highest Mean Reciprocal Rank (MRR) of 0.465, outperforming all other models.
  • The NCS postrank model improved over the base NCS model, increasing Answered@1 from 33 to 85 and MRR from 0.189 to 0.400.
  • UNIF stackoverflow achieved 104 correct answers within the top 1 result, significantly outperforming NCS (33) and UNIF android (25).
  • The NCS model had the lowest performance, with only 33 questions answered correctly in the top 1 result and an MRR of 0.189.
  • UNIF stackoverflow achieved 188 correct answers within the top 10 results, the highest among all models.
  • The Aroma similarity threshold of 0.25 was effective in automatically identifying correct code matches, enabling scalable and reproducible evaluation.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.