CoaCor: Code Annotation for Code Retrieval with Reinforcement Learning

Ziyu Yao, Jayavardhan Reddy Peddamail, Huan Sun
3/13/2019
cs.SEcs.CLcs.IR
rl

Official code: LittleYUYU/CoaCor (37 stars, Python, Apache-2.0, last commit 2020-04-21).

Abstract

To accelerate software development, much research has been performed to help people understand and reuse the huge amount of available code resources. Two important tasks have been widely studied: code retrieval, which aims to retrieve code snippets relevant to a given natural language query from a code base, and code annotation, where the goal is to annotate a code snippet with a natural language description.

Show full abstract

Despite their advancement in recent years, the two tasks are mostly explored separately. In this work, we investigate a novel perspective of Code annotation for Code retrieval (hence called `CoaCor'), where a code annotation model is trained to generate a natural language annotation that can represent the semantic meaning of a given code snippet and can be leveraged by a code retrieval model to better distinguish relevant code snippets from others. To this end, we propose an effective framework based on reinforcement learning, which explicitly encourages the code annotation model to generate annotations that can be used for the retrieval task. Through extensive experiments, we show that code annotations generated by our framework are much more detailed and more useful for code retrieval, and they can further improve the performance of existing code retrieval models significantly.

View on arXivView PDF

Code Implementations(1)

LittleYUYU/CoaCorOfficial100%
Apache-2.0

Code for "CoaCor: Code Annotation for Code Retrieval with Reinforcement Learning" (WWW 2019)

376Python, ShellSep 23, 20186 years agoApache-2.0

Similar Papers

Cite this paper

@article{yao2019coacor,
  title  = {CoaCor: Code Annotation for Code Retrieval with Reinforcement Learning},
  author = {Ziyu Yao and Jayavardhan Reddy Peddamail and Huan Sun},
  year   = {2019},
  eprint = {1904.00720},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/1904.00720}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/1904.00720.svg)](https://codeofpaper.com/paper/1904.00720)

Discussion