arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2308.09932cs.SE
收藏

揭示代码模型中的记忆现象

Unveiling Memorization in Code Models

Zhou Yang, Zhipeng Zhao, Chenyu Wang, Jieke Shi, Dongsun Kim, DongGyun Han, David Lo

AI总结:

本文实证研究大型预训练代码模型对训练数据的记忆现象,构建记忆内容分类体系,揭示模型规模、输出长度和训练数据重复度等关键因素,并提出减少记忆的度量指标与建议。

摘要:

大规模数据集的可用性、先进的架构以及强大的计算资源推动了高效代码模型的发展,这些模型能够自动化多种软件工程活动。这些数据集通常由来自开源和私有代码库的数十亿行代码组成。代码模型会逐字记忆并生成源代码,而这些代码可能包含漏洞、敏感信息或具有严格许可证的代码,从而引发潜在的安全与隐私问题。本文研究一个重要问题:代码模型在多大程度上记忆了其训练数据?我们对大型预训练代码模型中的记忆现象进行了实证研究。我们的研究表明,仅从一个代码模型中提取 20,000 个输出(每个输出包含 512 个 token),就能产生超过 40,125 个从训练数据中记忆而来的代码片段。为了提供更深入的理解,我们构建了一个包含 3 个大类和 14 个子类的记忆内容分类体系。结果表明,发送给代码模型的提示会影响记忆内容的分布。我们识别出若干影响记忆的关键因素。具体而言,在相同架构下,更大的模型会遭受更严重的记忆问题。当允许代码模型生成更长的输出时,它会产生更多的记忆内容。我们还发现,某个输出在训练数据中的出现次数与其在生成输出中的出现次数之间存在强正相关关系,这表明减少记忆的一种潜在方法是去除训练数据中的重复内容。随后,我们识别出能够准确推断输出是否包含记忆内容的有效度量指标。我们还针对记忆问题提出了处理建议。

英文摘要:

The availability of large-scale datasets, advanced architectures, and powerful computational resources have led to effective code models that automate diverse software engineering activities. The datasets usually consist of billions of lines of code from both open-source and private repositories. A code model memorizes and produces source code verbatim, which potentially contains vulnerabilities, sensitive information, or code with strict licenses, leading to potential security and privacy issues. This paper investigates an important problem: to what extent do code models memorize their training data? We conduct an empirical study to explore memorization in large pre-trained code models. Our study highlights that simply extracting 20,000 outputs (each having 512 tokens) from a code model can produce over 40,125 code snippets that are memorized from the training data. To provide a better understanding, we build a taxonomy of memorized contents with 3 categories and 14 subcategories. The results show that the prompts sent to the code models affect the distribution of memorized contents. We identify several key factors of memorization. Specifically, given the same architecture, larger models suffer more from memorization problems. A code model produces more memorization when it is allowed to generate longer outputs. We also find a strong positive correlation between the number of an output's occurrences in the training data and that in the generated outputs, which indicates that a potential way to reduce memorization is to remove duplicates in the training data. We then identify effective metrics that infer whether an output contains memorization accurately. We also make suggestions to deal with memorization.

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

↑