nillion aivm
1.0.0
AIVM是一个辅助使用高级加密协议的尖端框架。使用AIVM,您可以使用提供的示例或自定义模型来部署本地开发网络(DEVNET)来探索私人推理。
创建虚拟环境:
python3 -m venv .venv激活虚拟环境:
在Linux/MacOS上:
source .venv/bin/activate在Windows上:
. v env S cripts a ctivate安装软件包:
如果要执行示例执行:
pip install " nillion-aivm[examples] "否则,如果您要制作自己的代码,则可以:
pip install nillion-aivm启动AIVM DEVNET:
aivm-devnet打开提供的jupyter笔记本示例/启动。IPYNB以在AIVM上运行私人推理示例。
完成任务后,通过按CTRL+C终止DEVNET过程。
有关其他用法,请参阅示例文件夹,该文件夹演示了如何使用AIVM设置私有推理工作流。
import aivm_client as aic
# List all supported models
available_models = aic . get_supported_models ()
print ( available_models ) import torch
# Create a sample input (e.g., for LeNet5 MNIST)
random_input = torch . randn (( 1 , 1 , 28 , 28 )) # Batch size 1, 1 channel, 28x28 pixels # Encrypt the input
encrypted_input = aic . LeNet5Cryptensor ( random_input ) # Get prediction while maintaining privacy
result = aic . get_prediction ( encrypted_input , "LeNet5MNIST" ) get_prediction函数将使用aivm-devnet节点自动处理安全的计算协议,以确保您的输入数据在整个推理过程中保持私密。
您可以将自己的训练有素的模型部署到AIVM,只要它们遵循支持的架构(Berttiny或Lenet5)。
import aivm_client as aic # For BertTiny models
aic . upload_bert_tiny_model ( model_path , "MyCustomBertTiny" )
# For LeNet5 models
aic . upload_lenet5_model ( model_path , "MyCustomLeNet5" ) # For BertTiny models
result = aic . get_prediction ( private_berttiny_input , "MyCustomBertTiny" )
# For LeNet5 models
result = aic . get_prediction ( private_lenet5_input , "MyCustomLeNet5" )该项目已根据MIT许可获得许可。