Direct Code2Code transformation remains challenging to control because it can preserve surface-level syntax while introducing semantic drift, hidden behavioral changes, loss of traceability, non-idiomatic target implementations, or incomplete reconstruction of domain logic. This paper proposes a specification-based Code2Text2Code reengineering framework for LLM-mediated software evolution. The central idea is to transform source code into a neutral textual specification that captures program behavior, identifiers, computational flow, conditions, side effects, data dependencies, and domain-specific intent without directly transferring the source language syntax. The proposed framework combines factual context extraction, Code2Text generation, iterative verification between source code and text specification, Text2Code generation, target code verification, retrieval-augmented grounding, and semantic-aware chunking, and transformation loss estimation. The knowledge representation layer integrates metadata derived from AST, graph-based dependency structures, neutral natural language specifications, technical documentation, business documentation, and architecture-level representations. The conducted experiments include a Code2Text2Code dataset built from multiple programming languages and SQL dialects, comparison of intermediate representations, retrieval evaluation, documentation transformation evaluation, and prompt tuning using DSPy. A graph formalization using structural preservation, reverse compatibility, interface stability, and total graph similarity is implemented to estimate transformation losses. The results support the interpretation of the Code2Text2Code approach not as a simple code transformation, but as a controlled specification-based reengineering process for LLM-mediated software evolution.


翻译:直接进行代码到代码的转换仍然难以控制,因为它可能在保留表面语法结构的同时引入语义漂移、隐藏的行为变化、可追溯性丧失、非惯用目标实现,或领域逻辑的不完整重构。本文提出一种基于规约的代码-文本-代码重构框架,用于大语言模型中介的软件演化。其核心思想是将源代码转换为中立的文本规约,该规约能够捕获程序行为、标识符、计算流程、条件、副作用、数据依赖关系及领域特定意图,而无需直接转移源语言语法。所提出的框架结合了事实上下文抽取、代码到文本生成、源代码与文本规约间的迭代验证、文本到代码生成、目标代码验证、检索增强基座、语义感知分块以及转换损失估计。知识表示层融合了源自抽象语法树的元数据、基于图的依赖结构、中立自然语言规约、技术文档、业务文档以及架构级表示。进行的实验包括:基于多语言编程语言和SQL方言构建的代码-文本-代码数据集、中间表示比较、检索评估、文档转换评估,以及使用DSPy进行提示调优。通过结构保留、反向兼容性、接口稳定性及总图相似度实现了图形式化方法,用于估计转换损失。实验结果支持将代码-文本-代码方法解读为一种受控的基于规约的重构过程,而非简单的代码转换,以服务于大语言模型中介的软件演化。

0
下载
关闭预览

相关内容

代码(Code)是专知网的一个重要知识资料文档板块,旨在整理收录论文源代码、复现代码,经典工程代码等,便于用户查阅下载使用。
通过强化学习增强代码生成中的代码大语言模型:综述
专知会员服务
29+阅读 · 2025年1月1日
《大型语言模型代码生成》综述
专知会员服务
70+阅读 · 2024年6月4日
大语言模型算法演进综述
专知会员服务
81+阅读 · 2024年5月30日
一文看懂AutoEncoder模型演进图谱
AINLP
12+阅读 · 2019年6月17日
深度学习文本分类方法综述(代码)
中国人工智能学会
28+阅读 · 2018年6月16日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
VIP会员
最新内容
学习数据的几何:形状空间分析数学综述
专知会员服务
1+阅读 · 53分钟前
定向能反无人机系统最新发展动态
专知会员服务
3+阅读 · 今天13:50
从燃煤战舰到算法战争:水面指挥的永恒要求
专知会员服务
2+阅读 · 今天13:33
相关基金
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员