Privacy computing receives increasing attention but writing privacy computing code remains challenging for developers due to limited library functions that necessitate extensive function implementation from scratch as well as the data-oblivious requirement which contradicts intuitive thinking and usual practices of programmers. Large language models (LLMs) have demonstrated surprising capabilities in coding tasks and achieved state-of-the-art performance across many benchmarks. However, even with extensive prompting, existing LLMs struggle with code translation task for privacy computing, such as translating Python to MP-SPDZ, due to the scarcity of MP-SPDZ data required for effective pre-training or fine-tuning. To address the limitation, this paper proposes SPDZCoder, a rule-based framework to teach LLMs to synthesize privacy computing code without asking experts to write tons of code and by leveraging the instruction-following and in-context learning ability of LLMs. Specifically, SPDZCoder decouples the translation task into the refactoring stage and the generation stage, which can mitigate the semantic-expressing differences at different levels. In addition, SPDZCoder can further improve its performance by a feedback stage. SPDZCoder does not require fine-tuning since it adopts an in-context learning paradigm of LLMs. To evaluate SPDZCoder, we manually created a benchmark dataset, named SPDZEval, containing six classes of difficult tasks to implement in MP-SPDZ. We conduct experiments on SPDZEval and the experimental results shows that SPDZCoder achieves the state-of-the-art performance in pass@1 and pass@2 across six data splits. Specifically, SPDZCoder achieves an overall correctness of 85.94% and 92.01% in pass@1 and pass@2, respectively, significantly surpassing baselines (at most 30.35% and 49.84% in pass@1 and pass@2, respectively) by a large margin.
翻译:隐私计算日益受到关注,但编写隐私计算代码对开发者而言仍具挑战性,原因在于库函数有限需要从零实现大量功能,且数据不可知性要求与程序员的直觉思维和常规实践相悖。大语言模型(LLMs)在编码任务中展现出惊人能力,并在众多基准测试中取得最先进性能。然而,即使采用大量提示,现有LLMs在隐私计算的代码翻译任务(例如将Python代码转换为MP-SPDZ代码)中仍存在困难,这主要由于有效预训练或微调所需的MP-SPDZ数据稀缺。为突破此局限,本文提出SPDZCoder——一个基于规则的框架,旨在无需专家编写大量代码,通过利用LLMs的指令遵循和上下文学习能力,指导LLMs合成隐私计算代码。具体而言,SPDZCoder将翻译任务解耦为重构阶段和生成阶段,从而缓解不同层级的语义表达差异。此外,SPDZCoder可通过反馈阶段进一步提升性能。由于采用LLMs的上下文学习范式,SPDZCoder无需进行微调。为评估SPDZCoder,我们手动构建了基准数据集SPDZEval,其中包含六类在MP-SPDZ中难以实现的任务。我们在SPDZEval上开展实验,结果表明SPDZCoder在六个数据划分的pass@1和pass@2指标上均达到最先进性能。具体而言,SPDZCoder在pass@1和pass@2上的整体正确率分别达到85.94%和92.01%,显著超越基线方法(pass@1和pass@2最高分别仅为30.35%和49.84%),优势明显。