A Chain of AI-based Solutions for Resolving FQNs and Fixing Syntax Errors in Partial Code

06/21/2023
by   Qing Huang, et al.
0

API documentation, technical blogs and programming Q A sites contain numerous partial code that can be reused in programming tasks, but often these code are uncompilable due to unresolved names and syntax errors. To facilitate partial code reuse, we propose the Partial Code Reuse Chain (PCR-Chain) for resolving fully-qualified names (FQNs) and fixing last-mile syntax errors in partial code based on a giant large language model (LLM) like ChatGPT. Methodologically, PCR-Chain is backed up by the underlying global-level prompt architecture (which combines three design ideas: hierarchical task breakdown, prompt composition, and a mix of prompt-based AI and non-AI units) and the local-level prompt design. Technically, we propose PCR-Chain, which employs in-context learning rather than symbolic, costly training methods. Experimental results demonstrate that in dynamically-typed languages (Python), PCR-Chain outperforms current state-of-the-art (SOTA) 5 languages (Java), our approach achieves high accuracy of 80.5 both non-FQNs and last-mile syntax errors, surpassing SOTA methods (RING) that can only address last-mile syntax errors. The correct execution of the unit, module, and PCR-Chain demonstrates the effectiveness of the prompt design, composition, and architecture and opens up possibilities for building software engineering tools based on LLMs, replacing traditional program analysis methods.

READ FULL TEXT

page 2

page 6

page 12

research
06/01/2023

AI Chain on Large Language Model for Unsupervised Control Flow Graph Generation for Statically-Typed Partial Code

Control Flow Graphs (CFGs) are essential for visualizing, understanding ...
research
08/10/2022

Prompt-tuned Code Language Model as a Neural Knowledge Base for Type Inference in Statically-Typed Partial Code

Partial code usually involves non-fully-qualified type names (non-FQNs) ...
research
02/01/2019

Separating Use and Reuse to Improve Both

Context: Trait composition has inspired new research in the area of code...
research
06/21/2023

Prompt Sapper: A LLM-Empowered Production Tool for Building AI Chains

The emergence of foundation models, such as large language models (LLMs)...
research
02/01/2019

Concrete Syntax with Black Box Parsers

Context: Meta programming consists for a large part of matching, analyzi...
research
02/08/2023

Syntax and Domain Aware Model for Unsupervised Program Translation

There is growing interest in software migration as the development of so...
research
12/21/2021

Chat2Code: Towards conversational concrete syntax for model specification and code generation, the case of smart contracts

The revolutionary potential of automatic code generation tools based on ...

Please sign up or login with your details

Forgot password? Click here to reset