Client SDK for BlindAI Confidential Inference Server
Project description
BlindAI Client
BlindAI Client is a python library to create client applications for BlindAI Server (Mithril-security's confidential inference server).
If you wish to know more about BlindAI, please have a look to the project Github repository.
Installation
Using pip
$ pip install blindai
Usage
Uploading a model
from transformers import DistilBertTokenizer
from blindai.client import BlindAiClient, ModelDatumType
import torch
# Create dummy input for export
tokenizer = DistilBertTokenizer.from_pretrained("distilbert-base-uncased")
sentence = "I love AI and privacy!"
inputs = tokenizer(sentence, padding = "max_length", max_length = 8, return_tensors="pt")["input_ids"]
# Export the model
torch.onnx.export(
model, inputs, "./distilbert-base-uncased.onnx",
export_params=True, opset_version=11,
input_names = ['input'], output_names = ['output'],
dynamic_axes={'input' : {0 : 'batch_size'},
'output' : {0 : 'batch_size'}})
# Launch client
client = BlindAiClient()
client.connect_server(addr="localhost", policy="policy.toml", certificate="host_server.pem")
client.upload_model(model="./distilbert-base-uncased.onnx", shape=inputs.shape, dtype=ModelDatumType.I64)
Uploading data
from transformers import DistilBertTokenizer
from blindai.client import BlindAiClient
# Prepare the inputs
tokenizer = DistilBertTokenizer.from_pretrained("distilbert-base-uncased")
sentence = "I love AI and privacy!"
inputs = tokenizer(sentence, padding = "max_length", max_length = 8)["input_ids"]
# Load the client
client = BlindAiClient()
client.connect_server(addr="localhost", policy="policy.toml", certificate="host_server.pem")
# Get prediction
response = client.run_model(inputs)
In order to connect to the BlindAI server, the client needs to acquire the following files from the server:
-
policy.toml : the enclave security policy that defines which enclave is trusted (if you are not using the simulation mode).
-
host_server.pem : TLS certificate for the connection to the untrusted (app) part of the server.
Simulation mode enables to bypass the process of requesting and checking the attestation and will ignore the TLS certificate.
Before you run an example, make sure to get policy.toml
and host_server.pem
(if you are not using the simulation mode) that are generated in the server side.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
License
This project is licensed under Apache 2.0 License.
The project uses the "Intel SGX DCAP Quote Validation Library" for attestation verification, See Intel SGX DCAP Quote Validation Library License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for blindai-0.2.0-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78a9bd5931ab5b919c63321a8f0705fd8a2b0a0c83945bd3c334e9e744a7210b |
|
MD5 | 333c775f28f6bf486b2f13216b6f87d0 |
|
BLAKE2b-256 | 17a1b23753cd6fae9e1b21df3edd86a3601d4dd82636e2d54fa3cca48e606866 |
Hashes for blindai-0.2.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af4376b34271ea4bc910d9ac79d96c1bafb26ebeb58d9990b4a3494e7e7b2cb3 |
|
MD5 | c80032ec4b9080004882e3264bfccc00 |
|
BLAKE2b-256 | 53c4d4c7f8e9449466c2c9cbb692ef6d848b299bb27a26fa644400af361c3a30 |
Hashes for blindai-0.2.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a6d09e557d38e7ea6395049d3f91a9b6533f02d1a4a4ec55320fe6d3cad91e4 |
|
MD5 | 7ff86dc1ce563509b499d095e20fff18 |
|
BLAKE2b-256 | 13c4a53f6fd9716aaa368fe23cc7011d71673c3a26d61f209443a7436acebcbd |
Hashes for blindai-0.2.0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c0b188a97da2355e6a45740c02838151196ee3cc2ec363cc9ffe5a0eafc1970 |
|
MD5 | 0f42bdf742ca72b491c797850b029d6c |
|
BLAKE2b-256 | dd076649b05c264dae78b0fb703ae910311571cfe8cd903f7a99cec8c7075a08 |
Hashes for blindai-0.2.0-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f501bd3071ec95684522bb1af0fc9518be33dc22561153a15d70bd787cae018f |
|
MD5 | abbe3bb0ae5d2c8a6b67c1ef6ddd92c2 |
|
BLAKE2b-256 | 0ae34eefb379c60094656257779482c00593f17ad4ba71a5eb5df7949562efbe |