Skip to main content
QUICK REVIEW

[Paper Review] Simplifying Deep-Learning-Based Model for Code Search.

Chao Liu, Xin Xia|arXiv (Cornell University)|May 29, 2020
Software Engineering ResearchComputer Science44 references6 citations
TL;DR

This paper proposes CodeMatcher, a simplified deep-learning-based model for code search that combines keyword-based retrieval with fuzzy matching on method names and bodies, achieving 97% higher MRR and 66x speedup over DeepCS while outperforming state-of-the-art IR models like CodeHow by 73% in MRR on a dataset of 41,000 repositories.

ABSTRACT

To accelerate software development, developers frequently search and reuse existing code snippets from a large-scale codebase, e.g., GitHub. Over the years, researchers proposed many information retrieval (IR) based models for code search, which match keywords in query with code text. But they fail to connect the semantic gap between query and code. To conquer this challenge, Gu et al. proposed a deep-learning-based model named DeepCS. It jointly embeds method code and natural language description into a shared vector space, where methods related to a natural language query are retrieved according to their vector similarities. However, DeepCS' working process is complicated and time-consuming. To overcome this issue, we proposed a simplified model CodeMatcher that leverages the IR technique but maintains many features in DeepCS. Generally, CodeMatcher combines query keywords with the original order, performs a fuzzy search on name and body strings of methods, and returned the best-matched methods with the longer sequence of used keywords. We verified its effectiveness on a large-scale codebase with about 41k repositories. Experimental results showed the simplified model CodeMatcher outperforms DeepCS by 97% in terms of MRR (a widely used accuracy measure for code search), and it is over 66 times faster than DeepCS. Besides, comparing with the state-of-the-art IR-based model CodeHow, CodeMatcher also improves the MRR by 73%. We also observed that: fusing the advantages of IR-based and deep-learning-based models is promising because they compensate with each other by nature; improving the quality of method naming helps code search, since method name plays an important role in connecting query and code.

Motivation & Objective

  • To address the semantic gap between natural language queries and code snippets in code search.
  • To simplify the complex and slow inference process of DeepCS while preserving its semantic matching capability.
  • To improve retrieval accuracy and efficiency by combining keyword-based IR with deep learning-inspired vector alignment.
  • To investigate the effectiveness of fusing IR-based and deep-learning-based approaches for code search.
  • To evaluate the impact of method naming quality on code search performance.

Proposed method

  • CodeMatcher uses query keywords in their original order to form a query sequence for fuzzy matching against method names and bodies.
  • It performs fuzzy string matching on method names and method bodies to identify relevant code snippets.
  • The model returns the best-matched methods based on the length of the keyword sequence used in matching, favoring more comprehensive matches.
  • It leverages the shared vector space concept from DeepCS but avoids end-to-end training, simplifying the architecture.
  • The method maintains semantic relevance by aligning query keywords with code elements while relying on efficient string operations.
  • It integrates the strengths of both IR-based and deep-learning-based models by combining keyword matching with semantic alignment.

Experimental results

Research questions

  • RQ1Can a simplified model maintain DeepCS's semantic matching capability while significantly improving inference speed?
  • RQ2How does the performance of CodeMatcher compare to DeepCS and state-of-the-art IR-based models like CodeHow in terms of MRR and speed?
  • RQ3To what extent do method names contribute to code search effectiveness?
  • RQ4Can combining IR techniques with deep learning principles improve code search accuracy and efficiency?
  • RQ5Does improving method naming quality lead to better code search outcomes?

Key findings

  • CodeMatcher achieves 97% higher MRR than DeepCS on a large-scale codebase of 41,000 repositories.
  • CodeMatcher is over 66 times faster than DeepCS, significantly improving inference efficiency.
  • CodeMatcher improves MRR by 73% compared to the state-of-the-art IR-based model CodeHow.
  • Fusing IR-based and deep-learning-based approaches is promising, as they complement each other’s strengths.
  • Improving method naming quality enhances code search performance, as method names play a critical role in bridging queries and code.

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.