Iterative Refinement of Project-Level Code Context for Precise Code Generation with Compiler Feedback

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Bi, Zhangqian, Wan, Yao, Wang, Zheng, Zhang, Hongyu, Guan, Batu, Lu, Fangxin, Zhang, Zili, Sui, Yulei, Jin, Hai, Shi, Xuanhua
Format: Preprint
Veröffentlicht: 2024
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866909220780113920
author Bi, Zhangqian
Wan, Yao
Wang, Zheng
Zhang, Hongyu
Guan, Batu
Lu, Fangxin
Zhang, Zili
Sui, Yulei
Jin, Hai
Shi, Xuanhua
author_facet Bi, Zhangqian
Wan, Yao
Wang, Zheng
Zhang, Hongyu
Guan, Batu
Lu, Fangxin
Zhang, Zili
Sui, Yulei
Jin, Hai
Shi, Xuanhua
contents Large Language Models (LLMs) have shown remarkable progress in automated code generation. Yet, LLM-generated code may contain errors in API usage, class, data structure, or missing project-specific information. As much of this project-specific context cannot fit into the prompts of LLMs, we must find ways to allow the model to explore the project-level code context. We present CoCoGen, a new code generation approach that uses compiler feedback to improve the LLM-generated code. CoCoGen first leverages static analysis to identify mismatches between the generated code and the project's context. It then iteratively aligns and fixes the identified errors using information extracted from the code repository. We integrate CoCoGen with two representative LLMs, i.e., GPT-3.5-Turbo and Code Llama (13B), and apply it to Python code generation. Experimental results show that CoCoGen significantly improves the vanilla LLMs by over 80% in generating code dependent on the project context and consistently outperforms the existing retrieval-based code generation baselines.
format Preprint
id arxiv_https___arxiv_org_abs_2403_16792
institution arXiv
publishDate 2024
record_format arxiv
spellingShingle Iterative Refinement of Project-Level Code Context for Precise Code Generation with Compiler Feedback
Bi, Zhangqian
Wan, Yao
Wang, Zheng
Zhang, Hongyu
Guan, Batu
Lu, Fangxin
Zhang, Zili
Sui, Yulei
Jin, Hai
Shi, Xuanhua
Computation and Language
Software Engineering
Large Language Models (LLMs) have shown remarkable progress in automated code generation. Yet, LLM-generated code may contain errors in API usage, class, data structure, or missing project-specific information. As much of this project-specific context cannot fit into the prompts of LLMs, we must find ways to allow the model to explore the project-level code context. We present CoCoGen, a new code generation approach that uses compiler feedback to improve the LLM-generated code. CoCoGen first leverages static analysis to identify mismatches between the generated code and the project's context. It then iteratively aligns and fixes the identified errors using information extracted from the code repository. We integrate CoCoGen with two representative LLMs, i.e., GPT-3.5-Turbo and Code Llama (13B), and apply it to Python code generation. Experimental results show that CoCoGen significantly improves the vanilla LLMs by over 80% in generating code dependent on the project context and consistently outperforms the existing retrieval-based code generation baselines.
title Iterative Refinement of Project-Level Code Context for Precise Code Generation with Compiler Feedback
topic Computation and Language
Software Engineering
url https://arxiv.org/abs/2403.16792