# CoaCor: Code Annotation for Code Retrieval with Reinforcement Learning

**Authors:** Ziyu Yao, Jayavardhan Reddy Peddamail, Huan Sun

arXiv: 1904.00720 · 2019-04-02

## TL;DR

This paper introduces CoaCor, a reinforcement learning framework that generates detailed code annotations to improve code retrieval accuracy by better capturing the semantic meaning of code snippets.

## Contribution

It presents a novel reinforcement learning approach to jointly optimize code annotation for enhanced code retrieval performance, bridging the gap between the two tasks.

## Key findings

- Generated annotations are more detailed and semantically meaningful.
- The framework significantly improves code retrieval accuracy.
- Annotations enhance the distinguishability of relevant code snippets.

## 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. 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.

## Full text

_Full body text omitted from this summary view._ Fetch the complete paper as Markdown: https://tomesphere.com/paper/1904.00720/full.md

## Figures

2 figures with captions in the complete paper: https://tomesphere.com/paper/1904.00720/full.md

## References

65 references — full list in the complete paper: https://tomesphere.com/paper/1904.00720/full.md

---
Source: https://tomesphere.com/paper/1904.00720