arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2410.05797cs.CL
收藏

CodeCipher:学习对源代码进行混淆以对抗大语言模型

CodeCipher: Learning to Obfuscate Source Code Against LLMs

Shanghai Jiao Tong University(上海交通大学);East China Normal University(华东师范大学)

Yalan Lin, Chengcheng Wan, Yixiong Fang, Xiaodong Gu

AI总结:

针对云端大代码语言模型引发的用户代码隐私风险,提出CodeCipher方法,通过变换嵌入矩阵构建词元混淆映射并采用离散优化策略,在保留模型性能的同时实现源代码隐私混淆。

摘要:

尽管大型代码语言模型在AI辅助编码任务中已取得显著进展,但人们对其带来的隐私挑战的担忧与日俱增。用户代码对云端LLM服务提供商是透明的,这会引发用户代码被未经授权训练、读取和执行的风险。本文提出了CodeCipher,这是一种在保留LLM原始响应的同时,对代码中的隐私信息进行扰动的新方法。CodeCipher对LLM的嵌入矩阵进行变换,使每一行对应原始矩阵中的一个不同单词,形成用于混淆源代码的词元到词元的混淆映射。该新嵌入矩阵通过最小化任务特定的损失函数来优化。为解决词向量空间离散且稀疏的特性带来的挑战,CodeCipher采用了一种离散优化策略:在每次梯度更新前,将更新后的向量对齐到词表中最近的有效词元。我们在代码补全、代码摘要生成和代码翻译三项AI辅助编码任务上验证了该方法的有效性。结果表明,我们的模型成功混淆了源代码中的隐私信息,同时保留了LLM的原始性能。

英文摘要:

While large code language models have made significant strides in AI-assisted coding tasks, there are growing concerns about privacy challenges. The user code is transparent to the cloud LLM service provider, inducing risks of unauthorized training, reading, and execution of the user code. In this paper, we propose CodeCipher, a novel method that perturbs privacy from code while preserving the original response from LLMs. CodeCipher transforms the LLM's embedding matrix so that each row corresponds to a different word in the original matrix, forming a token-to-token confusion mapping for obfuscating source code. The new embedding matrix is optimized by minimizing the task-specific loss function. To tackle the challenge of the discrete and sparse nature of word vector spaces, CodeCipher adopts a discrete optimization strategy that aligns the updated vector to the nearest valid token in the vocabulary before each gradient update. We demonstrate the effectiveness of our approach on three AI-assisted coding tasks including code completion, summarization, and translation. Results show that our model successfully confuses the privacy in source code while preserving the original LLM's performance.

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

↑