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許可獲得許可。