Skip to main content
QUICK REVIEW

[论文解读] Trained Without My Consent: Detecting Code Inclusion In Language Models Trained on Code

Vahid Majdinasab, Amin Nikanjam|arXiv (Cornell University)|Feb 14, 2024
Natural Language Processing TechniquesComputer Science被引用 3
一句话总结

该论文提出 TraWiC,一种模型无关且可解释的方法,通过成员推理攻击检测特定项目代码是否被包含在大型语言模型的训练数据中。通过屏蔽语法和语义标识符(如变量名、注释),并分析模型预测结果,TraWiC 在检测代码包含性方面实现了 83.87% 的准确率,显著优于标准克隆检测工具 NiCad,后者仅达到 47.64% 的准确率。

ABSTRACT

Code auditing ensures that the developed code adheres to standards, regulations, and copyright protection by verifying that it does not contain code from protected sources. The recent advent of Large Language Models (LLMs) as coding assistants in the software development process poses new challenges for code auditing. The dataset for training these models is mainly collected from publicly available sources. This raises the issue of intellectual property infringement as developers' codes are already included in the dataset. Therefore, auditing code developed using LLMs is challenging, as it is difficult to reliably assert if an LLM used during development has been trained on specific copyrighted codes, given that we do not have access to the training datasets of these models. Given the non-disclosure of the training datasets, traditional approaches such as code clone detection are insufficient for asserting copyright infringement. To address this challenge, we propose a new approach, TraWiC; a model-agnostic and interpretable method based on membership inference for detecting code inclusion in an LLM's training dataset. We extract syntactic and semantic identifiers unique to each program to train a classifier for detecting code inclusion. In our experiments, we observe that TraWiC is capable of detecting 83.87% of codes that were used to train an LLM. In comparison, the prevalent clone detection tool NiCad is only capable of detecting 47.64%. In addition to its remarkable performance, TraWiC has low resource overhead in contrast to pair-wise clone detection that is conducted during the auditing process of tools like CodeWhisperer reference tracker, across thousands of code snippets.

研究动机与目标

  • 解决当训练数据集不可公开访问时,对 LLM 生成代码进行审计的挑战。
  • 克服传统代码克隆检测工具(如 NiCad)的局限性,后者需要原始训练数据访问权限,且在隐藏数据集包含性检测中表现不佳。
  • 开发一种无需微调或访问原始模型训练数据即可检测代码包含性的方法。
  • 实现对代码 LLM 中知识产权侵权行为的可解释且高效的检测,尤其适用于混淆或非语法性代码元素。
  • 为大规模审计场景提供一种可扩展且资源高效的替代方案,以替代成对克隆检测。

提出的方法

  • 从项目中的代码文件中提取唯一的语法和语义标识符(如变量名、函数名、注释、字符串)。
  • 在代码中屏蔽这些标识符,并向目标 LLM 查询被屏蔽元素的预测结果。
  • 使用模型的输出预测结果训练成员推理分类器,以判断原始代码是否存在于训练数据集中。
  • 使用替代模型模拟成员推理行为,并在无需访问原始训练数据的情况下训练分类器。
  • 利用 LLM 的记忆特性,即模型能够重现训练实例,通过分析预测置信度的统计特性来检测包含性。
  • 将该方法应用于非语法元素(如罕见变量名、文档字符串),以提升对混淆攻击的检测鲁棒性。

实验结果

研究问题

  • RQ1在无法访问训练数据的情况下,成员推理攻击能否有效检测某个代码项目是否被包含在 LLM 的训练数据集中?
  • RQ2TraWiC 在检测数据集包含性方面,与传统代码克隆检测工具(如 NiCad)相比表现如何?
  • RQ3当代码通过非语法方式(如重命名变量、修改注释)被混淆或修改时,TraWiC 能在多大程度上检测到代码包含性?
  • RQ4不常见或语义性标识符(如罕见变量名、文档字符串)在提升检测准确率方面起到何种作用?
  • RQ5与成对克隆检测方法相比,TraWiC 在大规模审计场景中的效率和可扩展性如何?

主要发现

  • TraWiC 在识别某个项目代码是否被包含在 LLM 训练数据集中的任务中,实现了 83.87% 的检测准确率。
  • 广泛使用的克隆检测工具 NiCad 在同一任务中仅达到 47.64% 的准确率,表明 TraWiC 显著优于传统方法。
  • TraWiC 展现出极高的召回率——最高达 99.19%,表明其在复杂或混淆场景下仍具有强大的检测敏感性。
  • 该方法对噪声和代码混淆具有鲁棒性,尤其在针对不常见标识符(如罕见变量名或文档字符串)时表现更优。
  • 与成对克隆检测相比,TraWiC 计算开销极低,因其避免了对数千个代码片段进行 exhaustive 比较的需要。
  • 该方法具有模型无关性和可解释性,可在无需微调或访问原始训练数据的情况下,部署于多种代码 LLM 中。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。