arXiv:2601.16354cs.CRcs.AI2026-01被引 2

NOIR让开发者用开源大模型写代码时,隐私不被云平台泄露。

NOIR: Privacy-Preserving Generation of Code with Open-Source LLMs

  • 客户端加密提示词和生成代码,云端只处理加密嵌入。
  • 在Evalplus上准确率达76.7%(Pass@1),仅比原模型低1.77%。
  • 适合对代码隐私要求高的企业级开发场景使用。

尽管大语言模型(LLM)提升了软件开发效率,但其代码生成服务存在知识产权与数据安全风险:云服务商可窥探用户输入的提示词和生成的代码,可能涉及商业机密。为解决此问题,我们提出NOIR,首个保护用户提示词和生成代码免受云平台访问的框架。NOIR在客户端部署编码器与解码器,将提示词嵌入加密后发送至云端,由开源LLM生成丰富嵌入,再由本地解码器还原生成代码。为防止云端通过嵌入反推原始内容,NOIR引入局部差分隐私机制,基于提示词与代码词汇表进行不可区分性保护,并采用数据无关且随机化的客户端分词器,有效抵御重建攻击与频率分析攻击。大量实验表明,使用开源LLM时,NOIR在多个基准测试中显著优于现有方法:Evalplus(MBPP和HumanEval Pass@1分别为76.7和77.4),BigCodeBench(Pass@1为38.7,仅比原模型下降1.77%),在强隐私保障下仍保持高性能。

原文摘要 · Abstract (English)

Although boosting software development performance, large language model (LLM)-powered code generation introduces intellectual property and data security risks rooted in the fact that a service provider (cloud) observes a client's prompts and generated code, which can be proprietary in commercial systems. To mitigate this problem, we propose NOIR, the first framework to protect the client's prompts and generated code from the cloud. NOIR uses an encoder and a decoder at the client to encode and send the prompts' embeddings to the cloud to get enriched embeddings from the LLM, which are then decoded to generate the code locally at the client. Since the cloud can use the embeddings to infer the prompt and the generated code, NOIR introduces a new mechanism to achieve indistinguishability, a local differential privacy protection at the token embedding level, in the vocabulary used in the prompts and code, and a data-independent and randomized tokenizer on the client side. These components effectively defend against reconstruction and frequency analysis attacks by an honest-but-curious cloud. Extensive analysis and results using open-source LLMs show that NOIR significantly outperforms existing baselines on benchmarks, including the Evalplus (MBPP and HumanEval, Pass@1 of 76.7 and 77.4), and BigCodeBench (Pass@1 of 38.7, only a 1.77% drop from the original LLM) under strong privacy against attacks.

代码生成隐私保护LLM安全差分隐私

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。