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.3.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1afbf5d6624d5a2b81507eb7922126fe5240381739ea218eaf34971e01409d2d |
|
MD5 | 9fbed101d6a6d51eddea9cecf01ad6c2 |
|
BLAKE2b-256 | 776fbb277b72a01ec847cbc575febf9bc36c95f778532fbc57f5dd5ecd235bb8 |
Hashes for blindai-0.3.1-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2a46930c974e3b31802abb3e1cb83aeb9a139b7f9c9316a1c06e81bf5219814 |
|
MD5 | 13a609928827e279e917df50623cc9ae |
|
BLAKE2b-256 | 037048df51dcb169e82b611af10ff71be8187dfd4b4aca2d7592768db02c4b36 |
Hashes for blindai-0.3.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18f355df81d31f75612e8bb624131a8604168bdf34681900ed51dd22c428c0cf |
|
MD5 | d177d0b8e7690ebf921a44a11f94d098 |
|
BLAKE2b-256 | 7b88b2815dee3f4164cdaf0b2bcf830aa6fd39be26d589df7c8a8ef5ba305a39 |
Hashes for blindai-0.3.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8fd7093ffdae397e5dbf9b4eb93015a888d1204f8a65f5d4b3ff22bc1a4ed2d3 |
|
MD5 | 1b1db5402939bcf47136adac20339913 |
|
BLAKE2b-256 | fbd4c65fc318b203a6e4f7e793c60feffbafdf2b238cb88803ca56728b2b24f9 |
Hashes for blindai-0.3.1-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cadb52a7424652a1bfb35429d5f82bd39ec18705d636a7b0264cc9cfb71d47e5 |
|
MD5 | db087e6705c0237e0766cb54591f5634 |
|
BLAKE2b-256 | 663f07923d5231c6f71d810af28ed805f72ce9afa6658e42a3e6f1505d5575f6 |
Hashes for blindai-0.3.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5470677bca1ee4764a53baa20a384c5d19a126293f577452277582a55b830e01 |
|
MD5 | 386e0c7536d233c2c2ee4c75815b5d52 |
|
BLAKE2b-256 | f47ed1597399a58b58ca254c2450e5d7d745b38c1b228fb9399fddc54f79dac1 |
Hashes for blindai-0.3.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebffde8ea13ecd492d78632de6c1731a82fdf281abd69beda48369ea48aed579 |
|
MD5 | bbcfda88d1be445e618da07c2709c158 |
|
BLAKE2b-256 | 34d4f158e60eb52271dce5685128e967caebad002956d7a74bfeed6e873c6323 |
Hashes for blindai-0.3.1-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a65496d30d94b25878fd97b9c84a3c89ada9fb00a3f120438ecb375adcb0ebe0 |
|
MD5 | 512074cb8024bfb27dfe7289f5ac5c29 |
|
BLAKE2b-256 | f66023048ecefc13afaec594a7fc77ea6908d8469f7a11c91d4156dee011526c |
Hashes for blindai-0.3.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc26a261ebadf1f4333c7e72da26a20ee06e6e2a3765dc0134ec705677779e75 |
|
MD5 | 826c94566af0c21e68d1643f78f80d5b |
|
BLAKE2b-256 | fe1bec1a9bcac6fb6027f64b5c74ffa999d8e1c937d5ed567bf806075354a48c |
Hashes for blindai-0.3.1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9db2de9c818296f6741acdb01a91aa792d5c4e14eac151480ebb0cf30bdd202 |
|
MD5 | 75b7a5c302af49d29239e3501f7611ad |
|
BLAKE2b-256 | b0d0de2101de3b5b7929f9937f2f3f041ca4edcde7c377394f96f9df58e7ab8c |
Hashes for blindai-0.3.1-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa5e0f25f7b04445dd572f2a49dd77adab96aeb17576934c25786b2fe0e8fae2 |
|
MD5 | 80dab69251506125dce1be7ef0f91d3e |
|
BLAKE2b-256 | 5f11bc1281ea69ea681970ae88eba4933ceea736178017ab1ad225cc60a70b83 |
Hashes for blindai-0.3.1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fd6b3a5689855fa26311f309fb55a531c4f252d889f060efa75dd934b5d2420 |
|
MD5 | 10dc550d7e0e11b9504e2144ea2439b7 |
|
BLAKE2b-256 | 121dee66ddea33d3544eecff73385c0668c14f1c2fc260a48ec2f37031240e33 |
Hashes for blindai-0.3.1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa190bb68f09d7c28599ffc6e2fcaf9c5ee7b2a2f01104eaf04be4e7b2a3c366 |
|
MD5 | 3557ba697327d2203acb0bd0e5ffd022 |
|
BLAKE2b-256 | 9e5ba13e25577d56344fdc9c6fa20fa2d597970fa4dfe496902bf0094922b493 |
Hashes for blindai-0.3.1-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48caef365c9aaa26b3018531235a1cbe6cf8d4f33ba81b9e39cde58b7d57a162 |
|
MD5 | c098a6ebbc846118bbf0f344ce0469f6 |
|
BLAKE2b-256 | 1e6a6d7b89c1f3b45a79c8cabf8d9df3e1166b7685f1436de7929aef02016a44 |
Hashes for blindai-0.3.1-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0c002a257922df37c91af265df9da300b8d6cf1c3f2cae50a2f05cbe9aa1235 |
|
MD5 | 4970378abc2cb1bab3b6a46c6b9d7dfa |
|
BLAKE2b-256 | c3ace264a1af4e5246129dd2a26ec2c3209b3d507d1a88cddab8649acd599e47 |