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
–arXiv.org Artificial Intelligence
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.
arXiv.org Artificial Intelligence
Jun-10-2024
- Country:
- Asia
- China
- Chongqing Province > Chongqing (0.04)
- Hubei Province > Wuhan (0.04)
- Shanghai > Shanghai (0.04)
- Middle East > UAE
- Abu Dhabi Emirate > Abu Dhabi (0.04)
- Russia (0.04)
- Singapore (0.04)
- China
- Europe
- Ireland > Leinster
- County Dublin > Dublin (0.04)
- Russia (0.04)
- United Kingdom > England
- Cambridgeshire > Cambridge (0.04)
- Ireland > Leinster
- North America
- Canada > Ontario
- Toronto (0.04)
- Dominican Republic (0.04)
- United States
- New York > New York County
- New York City (0.04)
- Virginia > Arlington County
- Arlington (0.04)
- New York > New York County
- Canada > Ontario
- Oceania > Australia
- New South Wales (0.04)
- Asia
- Genre:
- Research Report > New Finding (0.66)
- Technology: