EMNLP 2023long findings0 citations

Syntax-Aware Retrieval Augmented Code Generation

Xiangyu Zhang, Yu Zhou, Guang Yang, Taolue Chen

Abstract

Neural code generation models are nowadays widely adopted to generate code from natural language descriptions automatically. Recently, pre-trained neural models equipped with token-level retrieval capabilities have exhibited great potentials in neural machine translation. However, applying them directly to code generation experience challenges: the use of the retrieval-based mechanism inevitably introduces extraneous noise to the generation process, resulting in even syntactically incorrect code. Computationally, such models necessitate frequent searches of the cached datastore, which turns out to be time-consuming. To address these issues, we propose $k$NN-TRANX, a token-level retrieval augmented code generation method. $k$NN-TRANX allows for searches in smaller datastores tailored for the code generation task. It leverages syntax constraints for the retrieval of datastores, which reduces the impact of retrieve noise. We evaluate $k$NN-TRANX on two public datasets and the experimental results confirm the effectiveness of our approach.

Code GenerationRetrieval Augmented GenerationNeural-Symbolic
BibTeX
@inproceedings{
zhang2023syntaxaware,
title={Syntax-Aware Retrieval Augmented Code Generation},
author={Xiangyu Zhang and Yu Zhou and Guang Yang and Taolue Chen},
booktitle={The 2023 Conference on Empirical Methods in Natural Language Processing},
year={2023},
url={https://openreview.net/forum?id=wFILOtxmxU}
}
Syntax-Aware Retrieval Augmented Code Generation · EMNLP 2023