[论文解读] Converting Transformers to Polynomial Form for Secure Inference Over Homomorphic Encryption
本文提出了首个与同态加密(HE)兼容的多项式形式变换器模型,实现了在不暴露数据或模型权重的情况下进行安全推理。通过用多项式近似替代非多项式操作(如Softmax和LayerNorm)——具体而言,采用缩放σ注意力机制和基于批量归一化(BatchNorm)的归一化方法——作者在WikiText-103(准确率59.1%)和CIFAR-100/Tiny-ImageNet上实现了具有竞争力的性能,首次展示了在极小性能差距下实现全量Transformer模型在同态加密保护下的安全推理。
Designing privacy-preserving deep learning models is a major challenge within the deep learning community. Homomorphic Encryption (HE) has emerged as one of the most promising approaches in this realm, enabling the decoupling of knowledge between the model owner and the data owner. Despite extensive research and application of this technology, primarily in convolutional neural networks, incorporating HE into transformer models has been challenging because of the difficulties in converting these models into a polynomial form. We break new ground by introducing the first polynomial transformer, providing the first demonstration of secure inference over HE with transformers. This includes a transformer architecture tailored for HE, alongside a novel method for converting operators to their polynomial equivalent. This innovation enables us to perform secure inference on LMs with WikiText-103. It also allows us to perform image classification with CIFAR-100 and Tiny-ImageNet. Our models yield results comparable to traditional methods, bridging the performance gap with transformers of similar scale and underscoring the viability of HE for state-of-the-art applications. Finally, we assess the stability of our models and conduct a series of ablations to quantify the contribution of each model component.
研究动机与目标
- 为变换器模型实现同态加密(HE)下的安全推理,此前由于Softmax和LayerNorm等非多项式操作的存在而难以实现。
- 通过开发对HE友好的架构替代方案,弥合HE保护下的变换器与未加密版本之间的性能差距。
- 证明在同态加密下部署完整变换器模型(包括语言建模和图像分类任务)的可行性。
- 提供一个稳定、可扩展的框架,用于注意力和归一化层的多项式转换,推动隐私保护深度学习的广泛应用。
提出的方法
- 提出一种缩放σ注意力机制,用σ函数的多项式近似替代Softmax,实现与HE兼容的计算。
- 在多头注意力和MLP子层中均用BatchNorm替代LayerNorm,以确保与多项式表示的兼容性。
- 引入两阶段训练流程:首先对标准变换器进行预训练,然后使用多项式激活函数和BatchNorm进行微调,以保持性能。
- 在注意力头之间应用长度缩放和二维BatchNorm,以稳定训练并提升多项式变换器变体的准确率。
- 使用HE-SDK(HElayers v1.52)与HEaaN后端,设置参数为128位安全强度、2^15个系数、12层乘法深度和42位小数精度。
- 利用CPU-GPU混合架构(AMD EPYC 7763 + NVIDIA A100)加速HE推理,在6层BERT类模型上实现每轮推理305秒。
实验结果
研究问题
- RQ1变换器能否被有效转换为多项式形式,以实现在同态加密下的安全推理?
- RQ2如何在不造成显著性能下降的前提下,用多项式函数近似Softmax和LayerNorm等非多项式操作?
- RQ3在HE约束下,为稳定多项式变换器的训练与推理,需要进行哪些架构修改?
- RQ4在HE保护下,多项式变换器在自然语言处理和视觉基准测试中能与标准变换器达到多大程度的性能匹配?
- RQ5各组件(如BatchNorm、长度缩放)对HE安全变换器模型的稳定性与准确率有何影响?
主要发现
- 所提出的多项式变换器在WikiText-103上达到59.1%的准确率,采用σ注意力机制并结合所有稳定化技术,与原始Swin变换器的59.4%极为接近。
- 在Tiny-ImageNet上,性能最佳的多项式ViT变体(B+QK+A+S)采用σ注意力机制,准确率达到59.1%,与原始Swin模型性能相当。
- 在注意力头之间引入二维BatchNorm(B+QK)后,准确率从39.0%提升至49.8%(GELU)和38.4%提升至50.1%(ReLU),证明其在稳定性方面具有关键作用。
- 长度缩放(S)进一步提升性能,缩小与原始模型的差距,并使模型在HE约束下具备更好的泛化能力。
- 在6层BERT类模型(5330万参数)上进行安全推理耗时305秒,采用CPU+GPU硬件,优于相同HE设置下的ResNet-152(432秒)。
- 消融研究证实,将BatchNorm应用于MLP、注意力归一化以及引入长度缩放,是实现高准确率多项式变换器的必要组合。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。