arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2402.04863cs.SE
收藏

SCLA:通过LLMs与控制流提示的自动化智能合约摘要生成

SCLA: Automated Smart Contract Summarization via LLMs and Control Flow Prompt

Hainan University, China(海南大学);Hong Kong Polytechnic University, China(香港理工大学)

Xiaoqi Li, Yingjie Mao, Zexin Lu, Wenkai Li, Zongwei Li

AI总结:

SCLA通过将控制流图和AST语义事实融入提示,增强LLM对智能合约代码结构的理解,在40,000个合约上显著超越SOTA基线,BLEU-4等指标提升14.7%-26.7%。

摘要:

智能合约代码摘要对于高效维护和缓解漏洞至关重要。尽管许多研究使用大语言模型(LLMs)进行摘要生成,但其性能仍不及CodeT5+和CodeBERT等微调模型。一些方法将LLMs与数据流分析相结合,但未能充分捕捉代码的层次结构和控制结构,导致信息丢失并降低摘要质量。我们提出SCLA,一种基于LLM的方法,通过将控制流图(CFG)和来自代码控制流的语义事实整合到语义增强的提示中来提升摘要生成。SCLA使用控制流提取算法从抽象语法树(AST)中的语义节点导出控制流,并构建相应的CFG。代码语义事实指AST中与智能合约相关的显式和隐式信息。该方法使LLMs能够更好地捕捉代码的结构和上下文依赖关系。我们通过在包含40,000个真实世界智能合约的数据集上进行全面实验来验证SCLA的有效性。实验表明,SCLA显著提升了摘要质量,在BLEU-4、METEOR、ROUGE-L和BLEURT分数上分别比SOTA基线提高了26.7%、23.2%、16.7%和14.7%。

英文摘要:

Smart contract code summarization is crucial for efficient maintenance and vulnerability mitigation. While many studies use Large Language Models (LLMs) for summarization, their performance still falls short compared to fine-tuned models like CodeT5+ and CodeBERT. Some approaches combine LLMs with data flow analysis but fail to fully capture the hierarchy and control structures of the code, leading to information loss and degraded summarization quality. We propose SCLA, an LLM-based method that enhances summarization by integrating a Control Flow Graph (CFG) and semantic facts from the code's control flow into a semantically enriched prompt. SCLA uses a control flow extraction algorithm to derive control flows from semantic nodes in the Abstract Syntax Tree (AST) and constructs the corresponding CFG. Code semantic facts refer to both explicit and implicit information within the AST that is relevant to smart contracts. This method enables LLMs to better capture the structural and contextual dependencies of the code. We validate the effectiveness of SCLA through comprehensive experiments on a dataset of 40,000 real-world smart contracts. The experiment shows that SCLA significantly improves summarization quality, outperforming the SOTA baselines with improvements of 26.7%, 23.2%, 16.7%, and 14.7% in BLEU-4, METEOR, ROUGE-L, and BLEURT scores, respectively.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑