Generating Equivalent Representations of Code By A Self-Reflection Approach
Not on the map. Why?
Abstract (arXiv)
Equivalent Representations (ERs) of code are textual representations that preserve the same semantics as the code itself, e.g., natural language comments and pseudocode. ERs play a critical role in software development and maintenance. However, how to automatically generate ERs of code remains an open challenge. In this paper, we propose a self-reflection approach to generating ERs of code. It enables two Large Language Models (LLMs) to work mutually and produce an ER through a reflection process. Depending on whether constraints on ERs are applied, our approach generates ERs in both open and constrained settings. We conduct a empirical study to generate ERs in two settings and obtain eight findings. (1) Generating ERs in the open setting. In the open setting, we allow LLMs to represent code without any constraints, analyzing the resulting ERs and uncovering five key findings. These findings shed light on how LLMs comprehend syntactic structures, APIs, and numerical computations in code. (2) Generating ERs in the constrained setting. In the constrained setting, we impose constraints on ERs, such as natural language comments, pseudocode, and flowcharts. This allows our approach to address a range of software engineering tasks. Based on our experiments, we have three findings demonstrating that our approach can effectively generate ERs that adhere to specific constraints, thus supporting various software engineering tasks. (3) Future directions. We also discuss potential future research directions, such as deriving intermediate languages for code generation, exploring LLM-friendly requirement descriptions, and further supporting software engineering tasks. We believe that this paper will spark discussions in research communities and inspire many follow-up studies.
Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 8 of its 12 references that are in the map. First posted on arXiv 4 Oct 2024.
Builds on
8 of 12 references.
References · 8
- 2023Reflexion: Language Agents with Verbal Reinforcement Learningcited by 4,064
- 2020CodeBLEU: a Method for Automatic Evaluation of Code Synthesiscited by 468
- 2018Learning to Mine Aligned Code and Natural Language Pairs from Stack Overflowcited by 165
- 2023Structured Chain-of-Thought Prompting for Code Generationcited by 136
- 2023Large Language Models are Few-Shot Summarizers: Multi-Intent Comment Generation via In-Context Learningcited by 71
- 2024IRCoder: Intermediate Representations Make Language Models Robust Multilingual Code Generatorscited by 21
- 2023EditSum: A Retrieve-and-Edit Framework for Source Code Summarizationcited by 18
- 2022What does Transformer learn about source code?cited by 9
Built on by
Not cited yet.