SPDZCoder: Combining Expert Knowledge with LLMs for Generating Privacy-Computing Code

📄 arXiv: 2501.00363v2 📥 PDF

作者: Xiaoning Dong, Peilin Xin, Jia Li, Wei Xu

分类: cs.CR, cs.AI, cs.SE

发布日期: 2024-12-31 (更新: 2025-03-21)


💡 一句话要点

SPDZCoder:结合专家知识与LLM生成隐私计算代码,无需额外训练数据。

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 隐私计算 代码生成 大型语言模型 专家知识 MP-SPDZ 代码翻译 规则驱动

📋 核心要点

  1. 现有LLM在将Python翻译为MP-SPDZ等隐私计算代码时面临挑战,主要原因是缺乏足够的MP-SPDZ数据进行训练,且缺乏评估基准。
  2. SPDZCoder结合LLM与专家知识,通过规则驱动的方式将Python代码转换为MP-SPDZ代码,无需额外训练数据。
  3. 实验结果表明,SPDZCoder在SPDZEval基准测试中显著优于现有方法,pass@1和pass@2的正确率分别达到85.94%和92.01%。

📝 摘要(中文)

隐私计算日益受到关注,但编写隐私计算代码对开发者来说仍然具有挑战性,因为库函数有限,需要从头开始实现函数,并且数据不可知的要求与程序员的直觉思维和常用实践相悖。利用大型语言模型自动生成隐私计算代码可以简化开发工作,降低使用隐私计算框架的门槛。然而,由于缺乏有效的预训练或微调所需的MP-SPDZ数据,现有的LLM在隐私保护计算的代码翻译方面仍然面临挑战,例如将Python翻译成MP-SPDZ。此外,缺乏基准进一步复杂化了翻译质量的评估。为了解决这些限制,本文提出了一种基于规则的框架SPDZCoder,该框架结合了LLM和专家知识来生成隐私计算代码,而无需额外的训练数据。具体来说,SPDZCoder采用严格的程序来收集高质量的专家知识,以表示Python和MP-SPDZ之间的语义表达差异,并基于这些知识推导出将Python翻译成MP-SPDZ的转换规则。然后,SPDZCoder使用三阶段流水线中的转换规则逐步将Python代码转换为MP-SPDZ代码。为了评估SPDZCoder,我们手动构建了一个基准数据集SPDZEval,它包含六个数据分割,每个数据分割代表MP-SPDZ实现中不同类别的具有挑战性的任务。大量的实验表明,SPDZCoder取得了优异的性能,显著超过了pass@1和pass@2中的基线。具体来说,SPDZCoder在pass@1和pass@2中分别达到了85.94%和92.01%的总体正确率,而性能最佳的基线分别达到了63.58%和76.36%。

🔬 方法详解

问题定义:论文旨在解决将Python代码自动翻译为MP-SPDZ代码的难题。现有方法,特别是直接使用大型语言模型进行翻译,由于缺乏足够的MP-SPDZ训练数据,导致翻译质量不高。此外,缺乏专门的评估基准也使得评估翻译效果变得困难。

核心思路:论文的核心思路是结合大型语言模型和专家知识,构建一个基于规则的翻译框架。通过人工提取Python和MP-SPDZ之间的语义差异,并将其转化为转换规则,从而指导LLM进行代码翻译。这种方法避免了对大量MP-SPDZ数据的依赖,并利用了专家知识来提高翻译的准确性。

技术框架:SPDZCoder采用三阶段流水线:1) 专家知识收集:收集Python和MP-SPDZ之间的语义表达差异,形成转换规则的基础。2) 规则驱动的转换:利用收集到的转换规则,逐步将Python代码转换为MP-SPDZ代码。3) 代码生成:利用LLM生成最终的MP-SPDZ代码。

关键创新:最重要的技术创新点在于将专家知识融入到LLM的代码生成过程中。与直接使用LLM进行翻译相比,SPDZCoder利用专家知识指导LLM进行更准确的翻译,避免了对大量MP-SPDZ数据的依赖。此外,手动构建的SPDZEval基准数据集也为评估隐私计算代码翻译的质量提供了标准。

关键设计:专家知识的收集和转换规则的制定是关键设计。论文采用严格的程序来收集高质量的专家知识,并将其转化为可用于指导LLM进行代码翻译的转换规则。具体的规则制定方法和LLM的使用方式在论文中未详细说明,属于未知信息。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

SPDZCoder在SPDZEval基准测试中表现出色,显著优于现有方法。在pass@1和pass@2指标上,SPDZCoder分别达到了85.94%和92.01%的正确率,而最佳基线仅为63.58%和76.36%。这表明SPDZCoder在隐私计算代码翻译方面具有显著优势。

🎯 应用场景

该研究成果可应用于自动化隐私计算代码生成,降低隐私计算技术的使用门槛,加速隐私计算技术在金融、医疗、政务等领域的应用。通过自动生成MP-SPDZ代码,可以减少开发人员的工作量,提高开发效率,并促进隐私保护的数据共享和计算。

📄 摘要(原文)

Privacy computing receives increasing attention but writing privacy computing code remains challenging for developers due to limited library functions, necessitating function implementation from scratch, and data-oblivious requirement, contradicting intuitive thinking and usual practices of programmers. Automating the generation of privacy computing code with Large Language Models can streamline development effort and lower the barrier to using privacy computing frameworks. However, existing LLMs still encounter challenges in code translation for privacy-preserving computation, such as translating Python to MP-SPDZ, due to the scarcity of MP-SPDZ data required for effective pre-training or fine-tuning. Moreover, the lack of a benchmark further complicates the evaluation of translation quality. To address the limitations, this work proposes SPDZCoder, a rule-based framework that combines LLMs with expert knowledge for generating privacy-computing code without requiring additional training data. Specifically, SPDZCoder employ a rigorous procedure for collecting high-quality expert knowledge to represent the semantic-expressing differences between Python and MP-SPDZ, and to derive transformation rules for translating Python to MP-SPDZ based on these knowledge. Then, SPDZCoder progressively converts Python code into MP-SPDZ code using transformation rules in a three stage pipeline. To evaluate SPDZCoder, we manually constructed a benchmark dataset, SPDZEval, which comprises six data splits, each representing a distinct class of challenging tasks in MP-SPDZ implementation. Extensive experiments show that SPDZCoder achieves superior performance, significantly surpassing baselines in pass@1 and pass@2. Specifically, SPDZCoder attains an overall correctness of 85.94% and 92.01% in pass@1 and pass@2, respectively, whereas the best-performing baseline achieves 63.58% and 76.36%, respectively.